Menu Template for LCD Display
Carlinux
Posts: 15
Hi All,
I'm new to this forum and this is my small contribution to the forum !
Thanks,
Carl
I'm new to this forum and this is my small contribution to the forum !
Thanks,
Carl
' ========================================================================= ' File...... menu1.bsp ' Version... 1.0 ' Date...... August 2008 ' Purpose... Menu Template for LCD 16x2 and BS2p serie ' Author.... Carl Gosselin ' E-mail.... carlgosselin@yahoo.com ' {$STAMP BS2px} ' {$PBASIC 2.5} ' ' -----[noparse][[/noparse] I/O Definitions ]------------------------------------------------- Lcd PIN 0 ' LCD Enable Pin btn_plus PIN 11 ' btn_minus PIN 12 ' btn_menu PIN 13 ' ' -----[noparse][[/noparse] Variables ]------------------------------------------------------- i VAR Byte menu1_value VAR Byte menu2_value VAR Byte menu3_value VAR Word ' -----[noparse][[/noparse] Default Values ]------------------------------------------------------- menu1_value=15 menu2_value=140 menu3_value=300 ' -----[noparse][[/noparse] LCD Initialization ]-------------------------------------------------- Init_Lcd: PAUSE 1000 FOR i = 0 TO 2 LCDCMD Lcd, 48 ' Reset LCD (Send 3 times) PAUSE 5 ' Delay Require By LCD Specs NEXT LCDCMD Lcd, 32 ' Set 4-bit Mode LCDCMD Lcd, 40 ' Set 2-line Mode LCDCMD Lcd, 12 ' Turn On Display With No Cursor LCDCMD Lcd, 6 ' Set To Auto-Increment Cursor LCDCMD Lcd, 1 ' Clear Display ' -----[noparse][[/noparse] Main Routine ]---------------------------------------------------- Main: LCDOUT Lcd,128+1, [noparse][[/noparse]"Menu"] LCDOUT Lcd,128+70, [noparse][[/noparse]"Examples"] PAUSE 3000 LCDCMD Lcd, 1 ' Clear Display DO LCDOUT Lcd, 2, [noparse][[/noparse]"Main Page"] PAUSE 5 ' Stops Display flickering '#### '# Your Code Here '#### IF btn_menu = 0 THEN ' Call the menus sub routine if the button is pressed GOSUB menu ENDIF '#### '# Your Code Here '#### LOOP END ' -----[noparse][[/noparse] Sub Routines ]---------------------------------------------------- menu: DO GOSUB menu_one GOSUB menu_two GOSUB menu_three LCDCMD Lcd, 1 RETURN LOOP RETURN menu_one: LCDOUT Lcd, 1, [noparse][[/noparse]"2.Menu One"] PAUSE 200 DO LCDOUT Lcd, 128+64,[noparse][[/noparse]"[noparse][[/noparse]-]"] LCDOUT Lcd, 128+77,[noparse][[/noparse]"[noparse][[/noparse]+]"] LCDOUT Lcd, 128+67,[noparse][[/noparse]" "] LCDOUT Lcd, 128+69,[noparse][[/noparse]DEC menu1_value, " Sec"] IF btn_menu = 0 THEN LCDCMD Lcd, 1 PAUSE 300 RETURN ENDIF IF btn_plus = 0 THEN menu1_value=menu1_value+1 PAUSE 200 ELSEIF btn_minus = 0 THEN menu1_value=menu1_value-1 PAUSE 200 ENDIF IF menu1_value < 10 THEN menu1_value=10 IF menu1_value > 30 THEN menu1_value=30 LOOP PAUSE 1000 LCDCMD Lcd, 1 RETURN menu_two: LCDOUT Lcd, 1, [noparse][[/noparse]"2.Menu Two"] PAUSE 200 DO LCDOUT Lcd, 128+64,[noparse][[/noparse]"[noparse][[/noparse]-]"] LCDOUT Lcd, 128+77,[noparse][[/noparse]"[noparse][[/noparse]+]"] LCDOUT Lcd, 128+67,[noparse][[/noparse]" "] LCDOUT Lcd, 128+70,[noparse][[/noparse]DEC menu2_value,"F"] IF btn_menu = 0 THEN LCDCMD Lcd, 1 PAUSE 300 RETURN ENDIF IF btn_plus = 0 THEN menu2_value=menu2_value+5 PAUSE 200 ELSEIF btn_minus = 0 THEN menu2_value=menu2_value-5 PAUSE 200 ENDIF IF menu2_value < 120 THEN menu2_value=120 IF menu2_value > 190 THEN menu2_value=190 LOOP PAUSE 1000 LCDCMD Lcd, 1 RETURN menu_three: LCDOUT Lcd, 1, [noparse][[/noparse]"3.Menu Three"] PAUSE 200 DO LCDOUT Lcd, 128+64,[noparse][[/noparse]"[noparse][[/noparse]-]"] LCDOUT Lcd, 128+77,[noparse][[/noparse]"[noparse][[/noparse]+]"] LCDOUT Lcd, 128+67,[noparse][[/noparse]" "] LCDOUT Lcd, 128+70,[noparse][[/noparse]DEC menu3_value,"Hz"] IF btn_menu = 0 THEN LCDCMD Lcd, 1 PAUSE 300 RETURN ENDIF IF btn_plus = 0 THEN menu3_value=menu3_value+50 PAUSE 200 ENDIF IF btn_minus = 0 THEN menu3_value=menu3_value-50 PAUSE 200 ENDIF IF menu3_value < 200 THEN menu3_value=200 IF menu3_value > 600 THEN menu3_value=600 LOOP PAUSE 1000 LCDCMD Lcd, 1 RETURN
Comments
Welcome to Parallax Forum
Very nice·work
Thanks for sharing it········
······························································ · s
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any··that you may have and all of your time finding them
·
·
·
·
Sam
Any chance something like this could be done for the BS2?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Deus tantum me iudicabit