Shop OBEX P1 Docs P2 Docs Learn Events
Menus on the Parallax 4X20 Serial LCD Screen. — Parallax Forums

Menus on the Parallax 4X20 Serial LCD Screen.

Doc54963Doc54963 Posts: 1
edited 2012-12-16 08:15 in Propeller 1
Hi Everyone,

Please forgive my ignorance but I just started to program. Also thanks in advance for all your help.

My first real project uses the Parallax 4X20 Serial LCD screen (Found Here) for operation selection and data Input. The initial menu of the project will allow the selection of different "operations". Once selected a sub-menu the user will be prompted to enter parameters needed for this operation.

Ideally I would like to user a Special Character as a pointer that will move down the list until it reaches line 4. At that point it will move to the next page and the pointer will go back to line 1. At that point the process will start over again. These movements will be controlled by 5 buttons (L, R, Up, Dwn, Enter).

Once in a sub-menu I would like Previous operation name be the determinant heading allowing lines 2-4 to be for data input.

I would love to get some input form the community about how I would go about programing such Menus for the prop.

Thank You
Leonard

Comments

  • rogersydrogersyd Posts: 223
    edited 2012-08-14 16:58
    There are many practical (and ridiculous) ways to skin that cat. Without knowing much about your skill level in spin, I would suggest just breaking the problem down to its simplest goal. Essentially, all you need to do is replace one line of text with another. I built a menu system similar to your requirements when i was messing around with sidcog. I've attached my project code, you may be able to decipher something useful out of it. The zip file contains everything you would need to compile, but the file you might find helpful is prmopt2_lcd_pushbutton.spin.

    To implement a scrolling cursor type of interface (which is not demonstrated in this code), all you need to do is repeatedly modify the last character of each row. This would be pretty easy to accomplish in a "for y = 0 to 3" loop. You would move the cursor to the last colum of line one, place the char, pause, replace that char with a space, move to the last column of the next row, place the car, pause..... during the pause, check for a button push. if the button was pushed during that time use the value of y as your selection result.

    That type of approach would work best in less demanding applications and is not meant to be efficient, but it is simple, and would get the job done... The attached is only slightly more sophisticated than that.

    Might be time to dust this sid project off... great there goes the next few hours :)
  • mojorizingmojorizing Posts: 249
    edited 2012-08-15 00:05
    Leonard,

    Attached is code for the 4x20 LCD and 4 buttons (Up, Down, Select, Escape) that scrolls thru main menu, then the selected submenu, etc.
    Menus will scroll on the screen with a prompt at the current menu. I removed a cog that deals with proprietary code, but this should start you off.
  • Don MDon M Posts: 1,653
    edited 2012-12-10 18:29
    mojorizing wrote: »
    Leonard,

    Attached is code for the 4x20 LCD and 4 buttons (Up, Down, Select, Escape) that scrolls thru main menu, then the selected submenu, etc.
    Menus will scroll on the screen with a prompt at the current menu. I removed a cog that deals with proprietary code, but this should start you off.

    mojorizing- I was wanting to play with your code. I can't get it to do anything other than display the initial screen. I have it running on a PPDB using the pin assignments described in your code. I have the 4 buttons mentioned in your object (Btn_Up, Btn_Down, Btn_Select and Btn_Escape) connected to 4 push buttons on the PPDB on P11 - P14. They are tied high and pulled low when pressed. Is this the way your code interprets them?

    Thanks.
    Don
  • mojorizingmojorizing Posts: 249
    edited 2012-12-10 19:05
    Don,

    no...all are tied low, pulled high on button pushed
  • Don MDon M Posts: 1,653
    edited 2012-12-10 19:26
    Ok. I'll change my circuit. Once changed am I supposed to be able to navigate through the menus with the code as is?
  • Don MDon M Posts: 1,653
    edited 2012-12-10 19:45
    I tied all 4 inputs to ground via 10K resistors. I still don't get any menu cursor movement when pressing any of the buttons.

    Your code is fairly advanced for me to follow so I have trouble figuring it out but I want to learn from it. Any suggestions as to what might be wrong?

    Thanks.
    Don
  • Don MDon M Posts: 1,653
    edited 2012-12-10 20:02
    I added PST object to the code for debugging and am displaying "oldstate" in binary format and I can see the individual bits go hi or low depending on which button is being pressed so I know that part of the input code works....
  • mojorizingmojorizing Posts: 249
    edited 2012-12-10 20:44
    Don,

    I cut too much code out of my first example - the "UPDATES_LCD" OBJECT should be repeating...and updating as buttons are pushed.

    Try this example
  • Don MDon M Posts: 1,653
    edited 2012-12-11 04:40
    Thanks. I can scroll up and down through the menus but when I select any sub menu it locks up. Any chance of making that work. Sorry to be a pain but this code looks interesting and I want to understand it if I can.

    Thanks.
  • mojorizingmojorizing Posts: 249
    edited 2012-12-11 13:33
    Don,

    What's not show is somewhat proprietary....basically, when you press "select", the code will know where the prompt is, what the user has selected, and what to do from there.
  • Don MDon M Posts: 1,653
    edited 2012-12-11 15:15
    I figured that's what it would do. But I saw the sub menus down in the dat section so thought that since they were shown in the code that they would then pop up on the screen when selected. I figured you probably set some flags so your other software would know what to do when selected. That part I don't care about. It was the nesting of the menus that caught my attention and wanted to experience how smooth the transition would be going into and out of the submenus. That all.
  • mojorizingmojorizing Posts: 249
    edited 2012-12-11 15:27
    Don,

    There's also an article on a menu system here>>

    http://www.parallaxsemiconductor.com/an013

    I never really got a good understanding of it, but it's worth a read.
  • Don MDon M Posts: 1,653
    edited 2012-12-16 08:15
    Don M wrote: »
    Thanks. I can scroll up and down through the menus but when I select any sub menu it locks up. Any chance of making that work. Sorry to be a pain but this code looks interesting and I want to understand it if I can.

    Thanks.

    I dug this setup out again today to play with and figured out why it did not go into the submenu.

    In the Button_Push method change this:
      
      If xstate & |<2 AND Button_Push_Flag := Off
    
    

    to:
      
      If xstate & |<2 AND Button_Push_Flag == Off
    
    

    Hope this helps anyone else playing with this code example.
Sign In or Register to comment.