Maker Pro
Maker Pro

User friendly GUI for modifying PIC program

How do I make a GUI that when opened, will have dropboxes, textboxes, etc, apply button at the bottom, that will allow me to change certain parameters/lines of a PIC16 program file once I click apply, rather than having to manually open the program and type in the changes each time.
Kinda like a program configuration GUI.
Like for example there is a line

Code:
movlw d'6'
movwf byte

I would like to have a textbox in the GUI where I can just type in the number I want to change d'6' to and when I click apply it will automatically edit the .asm file.
 

Harald Kapp

Moderator
Moderator
Also avoid placing constant values as literals into your source code. Use constants that are declared at the beginning of your code using equ or #define statements.
Thus you can change all expressions using this value by simply changing it in the declaration. You also avoid the pitfall that opens when by chance the same value is used for different purposes (different constants) within the code. Changing all occurences of the value will change it also in places where no change is required. Using unique constant expressions avoids this.

Example (in pseudocode, sorry, I'm not familiar with PIC code):

Code:
// bad example
// area = width*length
area = d'10'*d'10' // = 100
// change width to 100, using automatic replacement results in
area = d'100'*d'100' //=10 000 - the automatic substitution doesn't know width from length

// better code
length equ 10
width equ 10
area = length * width // = 100
//change width to 100, using constant expression results in
length equ 10
width equ 100
area = length * width // = 1000
 

Harald Kapp

Moderator
Moderator
Use constants, put them into a separate header file, include this header file into you code and you're done. Any change to constants has to be done in the header file only. The "GUI" then is the editor of your choice.
 
And the users have the capability of assembling a file and programming the chip?

Bob
Yes, the users will be provided with mpasm.exe.
So the idea is it can be for idiots or normal people. All they have to do is open the "GUI", enter a value for 'byte' from 1 to 100, Check or uncheck if they want to have certain features of the program, and then click apply. Once apply has been clicked the .asm file will be immedialtely edited. Then the user will run mpasm.exe or mpasmwin.exe, select the .asm file, click compile/build, then exit. Then the user will connect a PICkit to the computer's USB port, run the PICKit software, select the .hex file built by mpasm.exe, and click Program Device.
Does that sound like a ridiculous scheme or okay? The point is that the user can select certain options and configurations of the device without ever having to look at a single line of code, especially because said code is written in assembly.
In another forum I also asked, someone said to use the sed command from UNIX... Don't know if that's the most straightforward way to get this done though..

Harald Kapp's idea up top seems functional, but perhaps not a presentable GUI. I'm looking more to make something like an object-based GUI or even a command line menu GUI where the user is presented with the options and the user chooses by typing, kinda like the old DOS menus..
 
Last edited:

Harald Kapp

Moderator
Moderator
What's wrong with the use of constants in a single header file, possibly augmented with lots of helpful hints so the user knows wehre to make changes?

SED is a powerful tool, but someone who is able to use SED imho doesn't need to be guided for changing a single value. Use of SED is also hampered by the fact that SED will not be able to distinguish between several occurences of the same literal in teh source code and will change them all (or only the first one, depending on the exact command line handed to SED).
 
What's wrong with the use of constants in a single header file, possibly augmented with lots of helpful hints so the user knows wehre to make changes?

SED is a powerful tool, but someone who is able to use SED imho doesn't need to be guided for changing a single value. Use of SED is also hampered by the fact that SED will not be able to distinguish between several occurences of the same literal in teh source code and will change them all (or only the first one, depending on the exact command line handed to SED).
I didn't say there was anything wrong with it. All I mean to say about it is that it seems more like it's for a technician or administrator, rather than a proper menu for an end user, like my sister for example...
Part of what engineers/developers design is presentability factor, no?
 

Harald Kapp

Moderator
Moderator
I didn't say there was anything wrong with it. All I mean to say about it is that it seems more like it's for a technician or administrator, rather than a proper menu for an end user, like my sister for example...
Part of what engineers/developers design is presentability factor, no?

I still insist on this technique. It is a technique useful anyways, regardless of your quest for a GUI.
You could even use your supposed GUI to change the right header constants - even present the user with a "speaking" name for the variable to be changed (you could even include a comment for each header constant which will be shown to the user of the GUI as a help in deciding which constant to change or which value to use.
Such a GUI could easily be written from some lines of Visual Basic, C, C+ Python or whatever language that comes with the right libraries to create a simple windows Interface:
  • read the header file
  • separate constants an possibly comments as help text
  • present constants and help text to the user in a window
  • take user input to change constant values
  • write text file.

On the other hand, if you are able to "educate" your sister to properly using MPASM and PICKIT, make all the right connections and press all the rigt menu buttons, showing her how to change a constant in a text file should be easy as pie.
 
Top