Pages: [1]   Go Down
Author Topic: Help with the MenuBackend library  (Read 730 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 30
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
#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.
« Last Edit: February 15, 2013, 02:21:02 pm by Derkatwork » Logged

Phillipsburg, NJ
Offline Offline
Full Member
***
Karma: 6
Posts: 184
Author: Matrix Keypad Library
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pages: [1]   Go Up
Jump to: