Help making menu
David92680
Posts: 10
SEROUT 14, 84, [noparse][[/noparse]148," N",151,"RT",154, "LT",157, "FD",160, "R", 162, "SP" ]
Above is the menu list that I am trying to program. my display is a Parallax 2x16 Serial LCD (Backlit) 27977. I'm having problems coming up with a program that will allow me to rotate threw the menu. For example I'm going to have 2 buttons one to shift the menu left and the other to shift it right. Some how i've got to I think make a program that will add and subtract numbers from letter location.
Menu1 [noparse][[/noparse]148," N",151,"RT",154, "LT",157, "FD",160, "R", 162, "SP" ]
Menu2 [noparse][[/noparse]148,"RT",151,"LT",154, "FD",157, "R",160, "SP", 162, " N" ]
Menu3 [noparse][[/noparse]148,"LT",151,"FD",154, "R",157, "SP",160, " N", 162, "RT" ]
Menu4 [noparse][[/noparse]148,"FD",151,"R",154, "SP",157, " N",160, "RT", 162, "LT" ]
Menu5 [noparse][[/noparse]148,"R",151,"SP",154, "N",157, "RT",160, "LT", 162, "FD" ]
Menu6 [noparse][[/noparse]148,"SP",151,"N",154, "RT",157, "LT",160, "FD", 162, "R" ]
Above is the menu list that I am trying to program. my display is a Parallax 2x16 Serial LCD (Backlit) 27977. I'm having problems coming up with a program that will allow me to rotate threw the menu. For example I'm going to have 2 buttons one to shift the menu left and the other to shift it right. Some how i've got to I think make a program that will add and subtract numbers from letter location.
Menu1 [noparse][[/noparse]148," N",151,"RT",154, "LT",157, "FD",160, "R", 162, "SP" ]
Menu2 [noparse][[/noparse]148,"RT",151,"LT",154, "FD",157, "R",160, "SP", 162, " N" ]
Menu3 [noparse][[/noparse]148,"LT",151,"FD",154, "R",157, "SP",160, " N", 162, "RT" ]
Menu4 [noparse][[/noparse]148,"FD",151,"R",154, "SP",157, " N",160, "RT", 162, "LT" ]
Menu5 [noparse][[/noparse]148,"R",151,"SP",154, "N",157, "RT",160, "LT", 162, "FD" ]
Menu6 [noparse][[/noparse]148,"SP",151,"N",154, "RT",157, "LT",160, "FD", 162, "R" ]
Comments
DATA statements are stored in the eeprom starting at location zero. So, you can access those bytes through the eeprom address using "READ".
End the DATA entry with a 0. Then output the messages stopping at that zero.
The BS2 has 26 bytes of 'RAM' (actually register space). Everything is 'global'.
' {$STAMP BS2}
' {$PBASIC 2.5}
LCD1 DATA "This is the LCD1 screen", 0
LCD2 DATA "This is the LCD2 screen", 0
ButtonHit VAR Byte
MenuState VAR Byte
LCD_Msg·· VAR Word
I·········· ·· VAR Word
SendByte· VAR Byte
MenuState = 0· ' zero is the 'starting' menu.
MAIN:
· GOSUB Read_Buttons· ' Sets ButtonHit to whatever button was hit, or zero if timeout
· GOSUB SendLCD······· ' Sends the LCD message, based on "ButtonHit' and 'MenuState'
· GOTO MAIN
Read_Buttons:
· ' Whatever it takes to read the buttons
· ' and set "ButtonHit"
· RETURN
SendLCD:
· IF MenuState = 0 THEN
··· LCD_Msg· = LCD1
· ENDIF
· GOSUB OutputLCD
· RETURN
OutputLCD:
· I = LCD_Msg
· READ I, SendByte
· DO WHILE SendByte <> 0
··· ' Write SendByte to LCD Port
··· I = I + 1
··· READ I, SendByte
· LOOP
· RETURN
Though, in your case you'd probably use:
Menu1 DATA 148, " N", 151, "RT", 154, "LT", 157, "FD", 160, "R", 162, "SP", 0
Post Edited (allanlane5) : 5/6/2008 1:27:20 AM GMT
' Write SendByte to LCD Port
Well, you replace that line with a SEROUT to pin 14 with the right baud rate to keep your LCD happy -- and output a byte at a time until you get to the "NULL" (zero valued byte).
' {$STAMP BS2}
' {$PBASIC 2.5}
#SELECT $STAMP
#CASE BS2, BS2E, BS2PE
T2400 CON 396
T9600 CON 84
T19K2 CON 32
#CASE BS2SX, BS2P
T2400 CON 1021
T9600 CON 240
T19K2 CON 110
#ENDSELECT
Menu1 DATA 148, " N", 151, "RT", 154, "LT", 157, "FD", 160, "R", 162, "SP", 0
Menu2 DATA 148, "RT", 151, "LT", 154, "FD", 157, "R", 160, "SP", 162, " N", 0
TX PIN 14 ' serial output to LCD
%0LF`Baud CON T19K2
ButtonHit VAR Byte
MenuState VAR Byte
LCD_Msg VAR Word
I VAR Word
SendByte VAR Byte
MenuState = 0 ' zero is the 'starting' menu.
MAIN:
GOSUB Read_Buttons ' Sets ButtonHit to whatever button was hit, or zero if timeout
GOSUB SendLCD ' Sends the LCD message, based on "ButtonHit' and 'MenuState'
GOTO MAIN
Read_Buttons:
' Whatever it takes to read the buttons
' and set "ButtonHit"
RETURN
SendLCD:
IF MenuState = 0 THEN
LCD_Msg = Menu1
ENDIF
GOSUB OutputLCD
RETURN
OutputLCD:
I = LCD_Msg
READ I, SendByte
DO WHILE SendByte <> 0
SEROUT TX, T19K2, ' Write SendByte to LCD Port
I = I + 1
READ I, SendByte
LOOP
RETURN
Try: SEROUT TX, T19K2, [noparse][[/noparse]SendByte]