Libraries
\ MenuItem
Reference for Wiring version 1.0 Build 0100+ If you have a previous version, use the reference included with your software. If see any errors or have any comments, let us know.
Name |
MenuItem |
Examples |
#include <MenuBackend.h>
MenuBackend menu = MenuBackend(menuUseEvent,menuChangeEvent);
MenuItem settings = MenuItem(menu, "Settings", 1);
MenuItem pin = MenuItem(menu, "Pin", 2);
MenuItem debug = MenuItem(menu, "Debug", 2);
MenuItem options = MenuItem(menu, "Options", 1);
MenuItem setDelay = MenuItem(menu, "Delay",'D', 2);
MenuItem d100 = MenuItem(menu, "100 ms", 3);
MenuItem d200 = MenuItem(menu, "200 ms", 3);
MenuItem d300 = MenuItem(menu, "300 ms", 3);
MenuItem d400 = MenuItem(menu, "400 ms", 3);
void menuSetup()
{
Serial.println("Setting up menu...");
menu.getRoot().add(settings);
settings.addAfter(options);
options.addAfter(settings);
settings.addLeft(settings);
settings.addRight(pin);
debug.addLeft(settings);
pin.addBefore(debug);
pin.addAfter(debug);
debug.addBefore(pin);
debug.addAfter(pin);
options.addLeft(options);
options.addRight(setDelay);
setDelay.addRight(d100);
d100.addBefore(d100);
d100.addAfter(d200);
d200.addAfter(d300);
d300.addAfter(d400);
d400.addAfter(d100);
d100.addLeft(setDelay);
d200.addLeft(setDelay);
d300.addLeft(setDelay);
d400.addLeft(setDelay);
}
void menuUseEvent(MenuUseEvent used)
{
Serial.print("Menu use ");
Serial.println(used.item.getName());
if (used.item.isEqual(setDelay))
{
Serial.println("menuUseEvent found Delay (D)");
}
}
void menuChangeEvent(MenuChangeEvent changed)
{
Serial.print("Menu change ");
Serial.print(changed.from.getName());
Serial.print(" ");
Serial.println(changed.to.getName());
}
void setup()
{
Serial.begin(9600);
menuSetup();
Serial.println("Starting navigation:rnUp:w Down:s Left:a Right:d Use: e");
}
void loop()
{
if (Serial.available())
{
byte read = Serial.read();
switch (read)
{
case 'w':
menu.moveUp();
break;
case 's':
menu.moveDown();
break;
case 'd':
menu.moveRight();
break;
case 'a':
menu.moveLeft();
break;
case 'e':
menu.use();
break;
}
}
}
|
Description |
There are to ways to work with menuItem. the basic item with a name and an optional mnemonic or a complex item that will use item change events. |
Syntax |
MenuItem(itemName, shortKey)
MenuItem(mb, itemName, lvl, shortKey)
|
Methods |
|
Parameters |
itemName |
The name of the item. |
shortKey |
The mnemonic 'shortkey'. |
mb |
The menu backend that controls this item. |
lvl |
The level of this item in the hierachy. |
|
Returns |
None |
Usage |
Application |
Updated on July 07, 2011 11:10:51pm PDT