LCD Menu For Picaxe- No idea on how/where to start

rs2845

Senior Member
Hi everyone,

Probably my first 'positive' post about my progress with the alarm system I am building...! I am now up to the stage where I need to create the menu structure for my LCD menu... I've been researching for over a week and cannot seem to even get an idea of how to create the hierarchy of commands to make the menu. The closest I got was with one of Tarzan's projects (this one) but there is no code files to accompany- so I am again at square 1.

I've attached a hierarchy diagram of the overall menu I am trying to create, and the menu will be navigated by the touchscreen (I have given each button a unique hex value that is sent to the picaxe) but I don't know how to even have the picaxe code in the 'tree' format for when I want to go 'up' one in the menu structure.

Can anyone provide a basic example for me to see how I can achieve a simple menu? Maybe the 'user 1' branch from my hierarchy diagram?

Just for a working example, the hex commands start from $01 but the back button (which should go 'up' one level) value is $FF.

Looking forward to some examples I can take a look at, it'll help me out loads.
Screen Shot 2013-01-23 at 22.12.11.png
 

rs2845

Senior Member
Why I never find these threads is beyond me! Thank you very much for that Jim, I think this may prove to be very helpful!
 

rs2845

Senior Member
Thank you all for your contributions! I'm beginning to see a general structure and how I can at least adapt some of the examples which is helpful.

Will have a crack at this with my system tomorrow!

I do love this forum. Everyone is so helpful! Thanks once again :)
 

inglewoodpete

Senior Member
Menus 101

I have written several systems using menus. Usually these use just a keypad for input but some use a combination of Keypad, IR Remote, other external inputs and internal timers. Usually, the display is a 16x2 LCD.

With good design, you can minimise the amount of code structures required to run all of the menus. Adding another menu is not such a big task to write and debug. That makes it easier to focus on the code for individual menu items.

I have broken the structure into three levels: Events, Menus and Actions.

Events are any inputs to the menu system. Key pad, serial port, Infra Red, timers and others.
Menus are every set of Actions where functions differ for the same Events. Eg The "up" key will produce a different Action for each Menu.
Actions are the result of each Event as required by each Menu

Code:
'Normally, I use names (symbols) for all variables and constants
'You need to be very organised when programming menus.  For clarity for the uninitiated, I use a mix here.
'This example uses 4 menus but is easily expanded
'
Symbol bEvent = b10
Symbol bMenu = b11
Symbol bNewMenu = b12
Symbol bAction = b13
Symbol MENU0 = 0  'Use a proper name
Symbol MENU1 = 1  'etc etc
'
Do
   'Main loop code goes here
   If bEvent > 0 Then
      GoSub AnalyseEvent
   EndIf
Loop
'
AnalyseEvent:
   bAction = 0
   Select Case bEvent
   Case 1
      '         (for MENU0,MENU1,MENU2,MENU3)
      LookUp bMenu, (0,    0,    2,    0    ), bNewMenu 'Go to a new Menu, when required
      LookUp bMenu, (1,    5,    0,    7    ), bAction  'Action required from Event
   Case 2      '(for MENU0,MENU1,MENU2,MENU3)
      LookUp bMenu, (0,    0,    5,    0    ), bNewMenu 'Go to a new Menu, when required
      LookUp bMenu, (2,    9,    0,    3    ), bAction  'Action required from Event
   Case 3
      etc etc
   EndSelect
   '
   If bNewNemu > 0 Then
      'Write new menu to LCD
      Select Case bNewMenu
      Case MENU0
      Case MENU1
      etc etc
      EndSelect
      bNemu = bNewNemu
   EndIf
   '
   Select Case bAction
   Case 1: GoSub DoAction1
   Case 2: GoSub DoAction2
   Case 3: GoSub DoAction2
   etc etc
   EndSelect
   Return
 

rs2845

Senior Member
Thanks everyone! I am adapting one of the examples and seeing how I get on. Managed to get serial from the display and getting the system to handle the saved variables... I don't know if I will actually need a menu if each menu has hex commands.

Found out my LCD has a software text/numeric keypad so I don't need to make one!


Wish me luck ;)
 
Last edited:

Axel87

Senior Member
Has anyone discovered a "program" that helps write these?
I read something in the latest Nuts and Volts that discussed a program that could output code for Ardunio and Picaxe use.
I have been working on a couple of projects but keep putting this part of it off, seems overwhelming.
If one could make a hierarchy like ravisispal94 (nicely done btw) in a desktop program and have it crap out the basic language? I suppose that would be a dream world eh? ;)
 

westaust55

Moderator
Could be difficult or cumbersome to write an extensive program that takes into account:
1. The controlling device (PICAXE etc)
2. The interface (parallel or serial)
3.if parallel then 4 or 8 bit
4. If serial is it RS232 like (SEROUT) SPI or i2c amongst others.
5. Within serial is it Sparkfun, Wolfenden, Rev Ed or other which each have unique functions
6. The display format 8x1, 16x1, 16x2, 20x2 28x2, 20x4, 20x8 or other

Even the make of some displays have different controllers to the mainstream which needs specific control codes.
 

oracacle

Senior Member
how far do you want to take this

this is a single tear skeleton using c.0 and c.1 to move through the menu choices. teat can be stacked if needs be making use of the same subroutines to find the next selection. work in simulation as well as on hardware.

the same basic of the program have been slightly reworked so that a keypad now selects the menu required with a sort of "cash machine" style (with the button next to the screen corriponing to a menu choice).
how you menu work is going to be very dpendand on how people will be interfacing with the hardware you are using.
 

Attachments

geoff07

Senior Member
One of the simplest keypads to use is an IR remote, with a separate 08M(2) to wait for it and send a command to the main chip. The simplest way to connect them is to send RTS from the remote to the host when a button is pressed, send CTS back to the remote when ready to listen, and then send the command as a serial byte or two on the CTS line. Very reliable and minimal code in the host, and can be polled whenever the main Picaxe is ready (no need for interrupts or scanning).

A problem I found with menus is the sheer volume of text required, so you may need to be clever with ram or LCD pre-programmed sequences.
 
Top