Need help with a Select and Enter type menu
ihmech
Posts: 179
I have been working on building a shop tool for use at my workplace.· I have been tinkering with electronics for the past 15yrs, but I am new to the Basic Stamp and programing, I'm teaching myself and trying to develop a tool at the same time.· My biggest problem is that I have not been able to create a simple menu.· I want a menu that I can display on an LCD, but I can't get the menu part down.· The menu I want works like this:· "Press select to choose machine"· Pressing the·select button will change the menu between "Machine_A and Machine_B" and pressing enter for "Machine_A or B will·start the program and use preset values for the machine selected.· I also need to be able to add more than two options in the future for new machine models.· Any help would greatly be appriciated.· Thanks!
Post Edited (ihmech) : 5/27/2009 2:01:45 AM GMT
Post Edited (ihmech) : 5/27/2009 2:01:45 AM GMT
Comments
What I did was to have a couple of push buttons to the right side of a 4x20 LCD and I displayed on the LCD the menu choices with an arrow pointing to the button to press. Here is an example:
Run Program One --->
Run Program Two --->
Run Program Three -->
Run Program Four -->
The code in your program will loop through and check for the pressing of any of these buttons and branch to the appropriate code in your program (or slot in your BS2 if so equipped). In your case, you may need a hierarchy of menu screens. So for example pressing button one would jump to code that displays another menu on the LCD that applies to Machine A in your case. Push buttons can of course be "re-used" in the sense that the top button is selecting a machine in the first level of the menu system and may be used to turn that machine on in menu level two.
Scanning for pressing of buttons is not difficult and I can provide examples of what I did there if you want.
I hope this helps.
Rick
Rick
:MENU
; display menu to the LCD here...
menubutton1: ' top button
IF IN1=0 THEN GOTO menubutton2
GOTO CODESEG1 ; goto part of program you want to run when button 1 is pressed
menubutton2: ' bottom button
IF IN2=0 THEN GOTO menubutton1
GOTO CODESEG2 ; goto part of program you want to run when button 2 is pressed
:CODESEG1
...
...
GOTO MENU
:CODESEG2
...
...
GOTO MENU
chg············ PIN···· 1·············· 'This is your input pin
cntr··········· VAR···· BYTE
············ '·One routine is IN1 = 1 and the other routine is for IN1 = 0
············ ·' I have use this little Routine a few time when go to a different· routine using a switch
Do
cntr = cntr + 1 * Chg
IF (cntr = 5) THEN···· ·' Or ·EXIT··· cntr = How Long you want to hold the button before it gose to what ever routine you want it to go to
DEBUG· ? Chg··, CR, ?·cntr····················· ' one nice thing about this routine is if your input dose not stay ethier a 1 or 0 for the hole count
·ENDIF········································ ' The Cntr counter gose back to " 0 "
cntr = cntr + 1 * (1 - Chg)
··· IF (cntr = 5) THEN
DEBUG· ? Chg, CR, ?Cntr
ENDIF
LOOP
I hope this helps
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any··that you may have and all of your time finding them
·
·
·
·
Sam
·I'm still working some small bugs out of it though. I'm·pretty stuborn and like to figure thinks out for my self...can't learn unless you fail.·<<<..........>>>> I know what you mean
When you have all of the bug work out of you code routines
Would you Please Post your Project in the Completed Project
Also if you need any help with your code feel free to ask
Thank You
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any··that you may have and all of your time finding them
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 5/28/2009 10:58:50 PM GMT