Shop OBEX P1 Docs P2 Docs Learn Events
User selectable settings without dip switches [ SOLUTION FOUND ] — Parallax Forums

User selectable settings without dip switches [ SOLUTION FOUND ]

beazleybubbeazleybub Posts: 102
edited 2008-08-16 07:02 in BASIC Stamp
I would like to have a user configureable menu using my BS2 or BS2sx that can be seen with my serial lcd.

I would like to use·three buttons one to access the menu·one to scroll through selections and one to save the selection.

I do know how to write to memory and also how to use the serial lcd but am unsure how to approach the menu.

Thanks


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
How can there be·nothing? Nothing is something!

Post Edited (beazleybub) : 8/15/2008 6:52:40 PM GMT

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-08-03 22:16
    First experiment with the display, figuring out how to get it to look the way you want it to. Use the real menu text and see how it looks. End up with a program that just does the menu stuff. It reads 3 buttons and writes text to the display. It doesn't matter how you write the program. You're just working with the appearance including the behavior of the buttons. You will throw out the code when you're done and will redo it. Some things will depend on the capabilities of the display ... whether it rolls up and down or you have to rewrite the whole thing when a line changes.
  • Mike GreenMike Green Posts: 23,101
    edited 2008-08-05 18:57
    For a start, buttons need to be "debounced". The easiest way to do this with a Stamp is to use the BUTTON statement. Look at the description in the manual. It works kind-of like an IF statement, but does the bookkeeping needed for debouncing and a repeat if desired (when the button is held down).

    In your case, the only BUTTON statement in your main program would be the one to test for the 1st button in order to enter the menu routine.
    You'd need to keep a counter for the different menu choices, initialized to zero. Whenever you press the 2nd button (while you're in the menu routine), the counter would be incremented (and wrap around), then the display menu routine would update the LCD contents based on the counter value. If the 3rd button is pressed while you're in the menu routine, the counter value would be used to do whatever is selected after the LCD is updated to show that a choice was made, then the menu routine would exit. If you want, if the 1st button is pressed while in the menu routine, you could just return (so it would work like a CANCEL).
  • beazleybubbeazleybub Posts: 102
    edited 2008-08-10 21:19
    Attached·is my newest version of a menu routine. I have added an exit menu feature. This is a work in progress and improvement is welcome.

    Unfortuneately it now uses 32% of the eeprom but I hope experienced users will have a go with it and make·some improvements if possible.

    Thank you.

    Edited:· August 15 2008
    Reason: Removed Obsolete File


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    How can there be·nothing? Nothing is something!

    Post Edited (beazleybub) : 8/15/2008 6:44:25 PM GMT
  • beazleybubbeazleybub Posts: 102
    edited 2008-08-15 18:40
    Ureka! I've done it.

    Here is the newest menu I have created using the BS2sx.

    I have managed to use scratchpad RAM freeing up quite a bit of regular RAM leaving plenty of room for variables.

    This program is intended for the BS2sx or equivalent only because of the program size (85% EEPROM slot).
    I think·it is well suited for slot useage.

    The program is attached......roll.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    How can there be·nothing? Nothing is something!
  • GICU812GICU812 Posts: 289
    edited 2008-08-16 06:53
    I think you could cut down a lot of code using a subroutine to output. Forgive my syntax, Ive been coding a couple of diffrent languages lately (VBnet PB, some others) and its late now, but you get the idea
    Exmaple:

    Dsp1:
    text$·= "First Option"
    Printer
    ·Return

    Dsp2:
    text$ = "Second Option"
    Printer
    return


    Printer:

    DEBUG CRSRXY, 0, 10, CLREOL, text$
    GET 54, Work
    DEBUG CRSRXY, 0, 11, CLREOL, DEC Work
    RETURN

    ... Wait, can you nest returns like that with a stamp? I dont remember. Its 3AM, im going to bed, lol

    ... Or instead of calling DspX just set text$ = , then call printer... Thought I was going to bed...

    Post Edited (GICU812) : 8/16/2008 7:03:33 AM GMT
  • beazleybubbeazleybub Posts: 102
    edited 2008-08-16 07:02
    Yeah, that would give the slot back about 10% of it's space.hop.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    How can there be·nothing? Nothing is something!
Sign In or Register to comment.