Shop OBEX P1 Docs P2 Docs Learn Events
Print Menu on 4x20 LCD? - Page 2 — Parallax Forums

Print Menu on 4x20 LCD?

2»

Comments

  • computer guycomputer guy Posts: 1,113
    edited 2010-01-16 03:36
    Now I just need MagIO2 to explain menuscroll, menu_entry_focus, menu_level_iterator and menu_level_mask to me. smile.gif


    Thank you smile.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "powered by Propeller" domed stickers $1.50 - Find them here
    Check out my Design and Technology project for my Higher School Certificate www.ecosureblog.net
  • computer guycomputer guy Posts: 1,113
    edited 2010-01-16 05:22
    Also, if I change

    LCD.str(@@mainmenu[noparse][[/noparse] i++])
    
    



    to

    LCD.str(@@menuptr[noparse][[/noparse] i++])
    
    



    it stops working because menuptr is an address not an array.
    Is there a way to resolve this?


    Thank you smile.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "powered by Propeller" domed stickers $1.50 - Find them here
    Check out my Design and Technology project for my Higher School Certificate www.ecosureblog.net
  • JonnyMacJonnyMac Posts: 9,208
    edited 2010-01-16 05:35
    I wrote the attached demo for someone else today; it allows to access a z-string in a DAT block using the string's index (0..n).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon McPhalen
    Hollywood, CA
  • computer guycomputer guy Posts: 1,113
    edited 2010-01-16 06:10
    Hey JonnyMac,

    That code uses a different data structure than the one I am using and therefore it just confused me even more.
    Thank you anyway smile.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "powered by Propeller" domed stickers $1.50 - Find them here
    Check out my Design and Technology project for my Higher School Certificate www.ecosureblog.net
  • computer guycomputer guy Posts: 1,113
    edited 2010-01-16 10:39
    Ok.
    LCD.str(@@word[noparse][[/noparse] menuptr][noparse][[/noparse] i++])
    
    


    Works well. However there appears to be something wrong with the code:
    if key == "b"
          menu_level_iterator >>= 4
          menu_entry_mask >>= 4
          menu_entry_focus &= menu_entry_mask        ' delete the part of the previous level
          key:="k"                                                      ' this will then reprint the menu
    
    



    It's meant to go back a level in the menu, however it's not working.


    Thank you smile.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "powered by Propeller" domed stickers $1.50 - Find them here
    Check out my Design and Technology project for my Higher School Certificate www.ecosureblog.net
  • computer guycomputer guy Posts: 1,113
    edited 2010-01-20 02:59
    Ok. Heres where I'm at.

    In mainmenu I have to click "down" once to select first menu item. cry.gif
    In submenu1 if I click "back" it goes to main menu smile.gif however in any other submenu it doesn't cry.gif

    repeat
        key := Get_Button
        if key == "b"
          'if menu_level_iterator == 1
            'return
          menu_level_iterator >>= 4
          menu_entry_mask >>= 4
          menu_entry_focus &= menu_entry_mask        ' delete the part of the previous level
          key:="k"                                   ' this will then reprint the menu
        case key
          "u":
            menu_entry_focus:=menu_entry_focus - menu_level_iterator
            ' check that it's not negative
            ' if focus is outside of the lines currently displayed, call scrollMenu
          "d":
            menu_entry_focus:=menu_entry_focus + menu_level_iterator
            ' check that it's not bigger than the number of entries in the active menu
            ' if focus is outside of the lines currently displayed, call scrollMenu
          "k":
            case menu_entry_focus
              $0:
                printMenu(@mainmenu)
              $1:
                printMenu(@submenu1)
                menu_level_iterator <<= 4
                menu_entry_mask := menu_entry_mask << 4 | $f
              $2:
                printMenu(@submenu2)
                menu_level_iterator <<= 4
                menu_entry_mask := menu_entry_mask << 4 | $f
              $3:
                ' this is not a submenu, so you simply call the function behind this entry
                'callWhatever
              $4:
                LCD.cls
                return  'Exit the menu
    
    



    Thank you smile.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "powered by Propeller" domed stickers $1.50 - Find them here
    Check out my Design and Technology project for my Higher School Certificate www.ecosureblog.net
  • MagIO2MagIO2 Posts: 2,243
    edited 2010-01-20 05:51
    You have to add more case statement cases ... you need one for each menu entry and one for each new submenu.

    The basic idea is that your menu_entry_focus will have the value of the currently highlighted menu entry. When you push the ok-button the case statement needs to find a match for executing something. The menu_entry_focus also stores the complete path you went through the menu.

    $0000_000x is the place where the selection in the main menu is stored. x being 0 is responsible for redisplaying the main menu. Values 1-15 ($1-$f) can be used to either start a function or go down to the next submenu-level.

    In the next submenu we have
    $0000_00yx ... where x will no more be changed and y is there for all entries of submenu 1. y=0 is where you would nee to call printMenu(@submenu1) for redisplaying submenu1 when you come from another level of submenu (lets name it submenu1_1. You only need that case if there are sub-sub-menus for submenu1 at all.

    Of course the next level will use the next nibble:
    $0000_0zyx ... and so on. That's why in this implementation we have a limit of 8 submenu levels and each menu can have max. 15 entries. If you find out that you need more menu entries and less levels, then this can be changed easyly. Giving each level 5 bits instead of 4 means you can have 31 menu entries per level.

    Hope that helped to clarify and did not confuse you more ;o)
  • computer guycomputer guy Posts: 1,113
    edited 2010-01-20 06:11
    So why then will
        if key == "b"
          'if menu_level_iterator == 1
            'return
          menu_level_iterator >>= 4
          menu_entry_mask >>= 4
          menu_entry_focus &= menu_entry_mask        ' delete the part of the previous level
          key:="k"                                   ' this will then reprint the menu
    
    


    take me back to the main menu when menu_entry_mask := $0000_0001 but not when menu_entry_mask := $0000_0002 ?


    Thank you smile.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "powered by Propeller" domed stickers $1.50 - Find them here
    Check out my Design and Technology project for my Higher School Certificate www.ecosureblog.net
  • MagIO2MagIO2 Posts: 2,243
    edited 2010-01-20 07:30
    The mask should not look like that at all. It's initialized with
    menu_level_mask := $f
    Going down one level shifts it to the left and adds another $f. Then it's $0000_00ff.
    Going up one level shifts it to the right.

    The mask is used to 'clear' the submenu-entry when you go up one level. For example:
    Your current position in the menu is $0000_0231 - which means in main-menu you selected entry 1 and got to submenu 1. In submenu 1 you selected entry 3 which also was a submenu and there your current position is entry 2 (whatever it is, function or another submenu).
    The mask is $0000_0fff in this case. If you go up one level it will be shifted to $0000_00ff and the menu_level_mask will be and'ed with this mask to remove the 2.

    ... ah ... I see ... If you go up one level the last 2 need to be set to zero for calling the right printMenu ... but on the other hand you would then end up on top of the menu instead of where you jumped into the submenu.

    I guess I need to try that out on my prop this evening - as I told you, I gave you only the concept without such details ... but first I have to earn some money [noparse]:o[/noparse](

    But now when working on this,·I think it might make sense to add this menu-stuff into my LCD display driver.
  • computer guycomputer guy Posts: 1,113
    edited 2010-01-20 07:36
    Thank you MagIO2. smile.gif

    I look forward to hearing from you.
    This is a small part of a huge project for my final senior year at school and therefore is urgent.
    Everything else is working great so far, just not the menu.


    Thank you smile.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "powered by Propeller" domed stickers $1.50 - Find them here
    Check out my Design and Technology project for my Higher School Certificate www.ecosureblog.net
  • MagIO2MagIO2 Posts: 2,243
    edited 2010-01-20 08:43
    I will PM my bank account details, so you can directly transfer the 10% of your first salary for the following 2 years to that account ;o)

    What's the project about?
  • BradCBradC Posts: 2,601
    edited 2010-01-20 11:09
    computer guy said...

    This is a small part of a huge project for my final senior year at school and therefore is urgent.

    Didn't school finish in December?!? Or are you getting an early start on this year [noparse];)[/noparse] ?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Life may be "too short", but it's the longest thing we ever do.
  • MagIO2MagIO2 Posts: 2,243
    edited 2010-01-20 21:03
    Here you are ... still a few percent missing, but maybe you can do the rest by yourself.

    It's running with the parallax terminal program, as I don't have a LCD setup currently. But it's an easy change.
    The program expects an keyboard input at the beginning, prints a string and waits a second. Then the main menu is printed. Now you can enter "u" for up and "d" for down. Entry 1 and 2 are submenus and you can select em with SPACE. In submenu 1 there is also a submenu defined (entry 1). With backspace you can go up one level.

    What's missing is the reprint of the menu, when you leave the part currently displayed. And the according checks. And of course function calls for entries which are no submenu.
  • computer guycomputer guy Posts: 1,113
    edited 2010-01-21 06:30
    @MagIO2
    The project is in my signature, it's a shower timer that automatically switches on when you enter the shower and turns the water off after 5mins.
    Has a bit more functionality than that, but you get the general idea.
    Thank you for the code, will test it out and let you know how I go. smile.gif

    @BradC
    This is a six month project for Design and Technology. I also have to write a 70 page folio explaining the details about the project (why i'm doing it, how i'm doing it, the design, the building, evaluation, etc). I needed the holidays to get a good start on it. I would like full marks if possible. lol tongue.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "powered by Propeller" domed stickers $1.50 - Find them here
    Check out my Design and Technology project for my Higher School Certificate www.ecosureblog.net
  • MagIO2MagIO2 Posts: 2,243
    edited 2010-01-21 06:55
    Just checked your homepage ... one idea ... maybe you already had the same idea, but anyway ...

    You might have an acceptance problem, if your system simply switches off the water after 5 minutes. You should have a friendly voice which warns you ahead of time that the water will be cut off in a minute ... Or 2 ... maybe make it configurable. But this way you have enough time to wash off all the soap you might have used.

    And when you already have a speaker for that ... why not having a nice shower music ... something soft ... easy listening ... or maybe the sound of animals in the rain forest.

    Mood light ... yep ... you need some full color LEDs.

    ;o)
  • computer guycomputer guy Posts: 1,113
    edited 2010-01-22 08:14
    Just managed to get it to work with the LCD. YAY!!! smile.gif

    Only bug I found, and I can't fix. Is in the main menu if you click down, when you're on item 4 it puts"|<" after item 4 and then at 0,0 (home) and so on.
    That and it starts in sub menu 1.


    Thank you smile.gif

    Edit: Just realised that the first problem is because
    ' MISSING: if focus is outside of the lines currently displayed,
    ' decrease the offset
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "powered by Propeller" domed stickers $1.50 - Find them here
    Check out my Design and Technology project for my Higher School Certificate www.ecosureblog.net

    Post Edited (computer guy) : 1/22/2010 8:42:54 AM GMT
  • MagIO2MagIO2 Posts: 2,243
    edited 2010-01-22 19:26
    Updated the menu.

    Now it is fully functional. I added a constant MENU_SIZE ... this defines the number of rows available for·the menu. So, when you have 2 two line display, set it to 2. If you have the TV text running, set it to 14. Or maybe you want to use a subset of lines ....

    Now entry 5 is also using a submenu to check if going up one level works properly, even if the menu has been scrolled before.

    Enjoy ... you can keep each bug you find from now on ;o)

    But serious, comuter guy, if you have problems with your changed code you should post an archiv here, so we can have a look at it.



    PS: For those who download it the first time, please have a look at the post 4 posts above - you'll need the archiv first.

    Post Edited (MagIO2) : 1/22/2010 10:04:11 PM GMT
  • computer guycomputer guy Posts: 1,113
    edited 2010-01-24 01:17
    Thank you MagIO2. smile.gif

    Apart from it starting in submenu1 it is all working great.
    I would upload my code however it contains the rest of my code which is at some point going to be for a commercial product and I don't want it getting out in the public domain.


    Thank you smile.gif

    Edit: I now have it going to the main menu.

    I had
    If Get_Button == "k"
      Show_Menu
    
    



    I changed it to
    key := Get_Button
    case key
      "k":
          Show_Menu
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "powered by Propeller" domed stickers $1.50 - Find them here
    Check out my Design and Technology project for my Higher School Certificate www.ecosureblog.net

    Post Edited (computer guy) : 1/24/2010 7:34:16 AM GMT
Sign In or Register to comment.