Shop OBEX P1 Docs P2 Docs Learn Events
Help making menu — Parallax Forums

Help making menu

David92680David92680 Posts: 10
edited 2008-05-06 01:49 in BASIC Stamp
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" ]

Comments

  • allanlane5allanlane5 Posts: 3,815
    edited 2008-05-06 01:01
    The typical way to do this is with "DATA" statements.

    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.
  • David92680David92680 Posts: 10
    edited 2008-05-06 01:13
    How would I go about using the data statements with the menu list that I have. So I would have to make a counter that would count to 6 and loop. what ever number the counter is on is the menu the main would display. Havent used Data statements all that much especially with a display.
  • allanlane5allanlane5 Posts: 3,815
    edited 2008-05-06 01:21
    It's pretty simple.
    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
  • David92680David92680 Posts: 10
    edited 2008-05-06 01:24
    how does it know what pin I have the Display hooked up to. mine is pin14
  • allanlane5allanlane5 Posts: 3,815
    edited 2008-05-06 01:26
    You see that line that says:

    ' 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).
  • David92680David92680 Posts: 10
    edited 2008-05-06 01:40
    I know I don't have any inputs hooked up to it but its not working and i've tried putting what you said in to the code.

    ' {$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
  • allanlane5allanlane5 Posts: 3,815
    edited 2008-05-06 01:49
    It looks like your SEROUT is not quite correct yet.

    Try: SEROUT TX, T19K2, [noparse][[/noparse]SendByte]
Sign In or Register to comment.