Shop OBEX P1 Docs P2 Docs Learn Events
Menu on LCD — Parallax Forums

Menu on LCD

SamTheManSamTheMan Posts: 43
edited 2009-06-24 18:07 in General Discussion
I'm trying to make a menu on LCD. I am using JonnyMac LCD_STR sub
will this work? it there is a better idea to make a selection list on the LCD

tmpw=@menu 'get menu address

do
lcd_str tmpw

do
loop until button=1 ' loop until key is pressed

tmpw=tmpw+10 'get next in menu list
inc tmp2 'next Param
loop until tmp2=5

SUB LCD_STR
sAddr VAR __WPARAM12 ' address of string
sChar VAR __PARAM1 ' character from string

DO
READINC sAddr, sChar ' get a character
IF sChar = 0 THEN EXIT ' if 0, we're done
LCD_OUT sChar ' print the character
LOOP
ENDSUB
menu:

data "Slow Time",0
data "Fast Time",0
data "Cam Time",0
data "Stop Time",0
data "Last Floor",0

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

Comments

  • natpienatpie Posts: 35
    edited 2009-06-24 16:14
    SamTheMan said...
    do
    loop until button=1 ' loop until key is pressed
    This might end up causing you some problems.· Unless only press the button for a nannosecond it will cycle through your whole program when you press the button.·· You need to only pass once per press.·· You can do this by tracking the previous known state of the button.·· So if the button is pressed, and last time I checked it was pressed, then this is not a new press so don't move on yet.··· But if the button is pressed, and last time it checked it was not then this is a new button press and we can move on.··
    In addition you may need to debounce your signal (when you press the button as it is making contact it will turn on and off rapidly untill the contacts are firmly touching).· This can be addresed by checking the button and not counting the press untill you get the same result several times in a row.
  • JonnyMacJonnyMac Posts: 9,213
    edited 2009-06-24 16:31
    See the attached program -- it should point you in a direction that's helpful.
  • SamTheManSamTheMan Posts: 43
    edited 2009-06-24 18:07
    Thank you JonnyMac,
    I will study your program

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


Sign In or Register to comment.