Pages: [1]   Go Down
Author Topic: LCD menu problems and condensing sketch  (Read 393 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 0
Posts: 91
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
     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:
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();
  }


Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 91
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

* LCD_Menu.ino (20.01 KB - downloaded 5 times.)
Logged

Aix en Provence, France
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 91
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 91
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


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.
Logged

Pages: [1]   Go Up
Jump to: