Go Down

Topic: Help with the MenuBackend library (Read 993 times) previous topic - next topic

Derkatwork

Feb 15, 2013, 08:14 pm Last Edit: Feb 15, 2013, 08:21 pm by Derkatwork Reason: 1
I can't fully understand how to use this library.  I'm trying to reverse engineer sample code, but I'm not having much luck.  I want to create an menu system for an LCD with a 4x4 keypad as input.  I think I understand the keypad library (it doesn't seem to hard).  The sending messages with the liquid crystal library isn't too bad either.  I can't wrap my head around how to go about using the MenuBackend library and documentation on it in the playground is very poor.  I also am not very sure on how to manipulate the cursor to select an item.

Code: [Select]
#include <LiquidCrystal.h>
#include <Keypad.h>
#include <Time.h>
#include <MenuBackend.h>

LiquidCrystal lcd(12, 10, 5, 4, 3, 2);

const byte ROWS = 4; //Four rows
const byte COLS = 4; //Four columns
static char key;
char KEYS[ROWS][COLS] = {
 {'1','2','3','A'},
 {'4','5','6','B'},
 {'7','8','9','C'},
 {'*','0','#','D'}
}; //Defines the buttons

byte ROWpins[ROWS]={2,3,4,5}; //connect the row pins
byte COLpins[COLS]={6,7,8,9}; //connect the column pins

Keypad KEYPAD = Keypad(makeKeymap(KEYS), ROWpins, COLpins, ROWS, COLS);

//Setting up the menu
MenuBackend menu = MenuBackend(menuUsed,menuChanged);

 MenuItem menuItem1 = MenuItem("Item1");
  MenuItem menuItem1SubItem1 = MenuItem("Item1subItem1");
  MenuItem menuItem1SubItem2 = MenuItem("Item1subItem2");
 
 MenuItem menuItem2 = MenuItem("Item2");
  MenuItem menuItem2SubItem1 = MenuItem("Item2subItem1");
  MenuItem menuItem2SubItem2 = MenuItem("Item2subItem2");
  MenuItem menuItem2SubItem3 = MenuItem("Item2subItem3");
 MenuItem menuItem3 = MenuItem("Item3");
 

 
void setup()
{
Serial.begin(9600);
lcd.begin(16, 2);
menu.getRoot().add(menuItem1);

menuItem1.addRight(menuItem2).addRight(menuItem3);

menuItem1.add(menuItem1SubItem1).addRight(menuItem1SubItem2);
menuItem2.add(menuItem2SubItem1).addRight(menuItem2SubItem2).addRight(menuItem2SubItem3);

menu.toRoot();
lcd.setCursor(0,0);

}

void loop()
{
 lcd.print("hello, world!");
 key = KEYPAD.getKey(); // Gets the key that was used.
 
 if(key != NO_KEY) //I think it's test code.
 {
 Serial.println(key);
 }
 

}

void menuUsed(MenuUseEvent used){

 }

void navigateMenus(){}

 
void menuChanged(MenuChangeEvent changed) {
 
}


Can someone point me in the right direction on this?

EDIT: I am using a 16x2 RGB LCD and a 4x4 arduino compatible keypad.  Also, ignore the pin locations between the lcd and keypad.  I don't even have the keypad in yet, so I'm hoping to get a start on the menu system while I'm waiting for it.

mstanley


I can't wrap my head around how to go about using the MenuBackend library and documentation on it in the playground is very poor.  I also am not very sure on how to manipulate the cursor to select an item.

Here's a link to another forum post where AlphaBeta is answering questions and fixing problems.  http://arduino.cc/forum/index.php/topic,38053.0.html

It looks like a good place to get a deeper understanding of how his menu system works.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy