Go Down

Topic: LCD menu problems and condensing sketch (Read 400 times) previous topic - next topic

gr0p3r

Hi
im trying to implement a LCD (16x2) menu into a project ive already got working. It would benefit greatly from a LCD menu. Ive got the menu structure working, and the options working. there's just a little tweak that i cant seem to work out. ive been trying for days and now its driving me mental.

the menu structure is
Code: [Select]
     main menu - start
                     - Setup - Brightness - 0%
                                |                - ...
                                |                - 100%
                                - PumpMax - 0%
                                                 - ...
                                                 - 100%


I just want to remove that "main menu" bit so that the root of the menu has start and setup. even if it just automatically moves right. Ive tried adding "menu.moveRight();" into the " if(newMenuItem.getName()=="MenuRoot") { }" (at the top of void menuChanged) and that hasnt worked.

ive looked at the library but thats way outta my league.

This is where i am thinking the changes need to be made (?)
Code: [Select]
void menuChanged(MenuChangeEvent changed){
 
 MenuItem newMenuItem=changed.to; //get the destination menu
 
 lcd.setCursor(0,1); //set the start position for lcd printing to the second row
 
 if(newMenuItem.getName()=="MenuRoot") {
     lcd.setCursor(0,0);
     lcd.print("Still Controller     ");
     lcd.setCursor(0,1);
     lcd.print("> Menu               ");
     delay(500);
 }


changed into...

 if(newMenuItem.getName()=="MenuRoot") {
    menu.moveRight();
 }




gr0p3r

heres my code in it entirety.
as you can see, ive borrowed heavily from http://www.coagula.org/content/pages/tutorial-manage-menu-and-lcd-display-arduino
Also, im sure that this code can be shrunk alot. there looks like a lot of stuff that is repeated that could be done in a lot fewer lines.

ericklil

Hi there I am working on a similar project where I need LCD control I have tried the coagula.org sample but it did not exactly work for me.

However trying the code you posted, seems to work, with one issue: I noticed once I set a Brightness of a LEd connected to D6, how does one get back out of the menu, to home....

have you found a way yet to get this in your compete sketch such that the menu can be invoked while the rest of the sketch continues or is on hold for that matter.....?

Many thanks look forward to any ideas

erick

gr0p3r

Glad this could help someone, yet it doesnt solve my problem.

then answer to your question is, just below 100%, there is a < home option. you could move it to the top if it confusing?

gr0p3r



have you found a way yet to get this in your compete sketch such that the menu can be invoked while the rest of the sketch continues or is on hold for that matter.....?


you could use interrupts attached to a button to jump out of a loop, disable interrupts, attach the buttons, perform the menu operations then once an item selected, attache interrupts again.
Or have 2 adruinos on the go. one to run your loop and the other doing the menu. There are many ways to network them and data from the menu arduino could be read from the other one performing the actions.

Go Up