MenuBackend, new menu managment library
i created new library menu managment.
it has no limits kind of logical layout want.
[size=14]menubackend 1.0[/size]
every item can thought of cross directional connections in these direcitons: above, right, belov, left.
you can add item item @ these locations. have 2 items, called a , b.
if want these ordered horizontal menu being first item, add b @ right position.
a.addright(b);
now menu support these actions (if have added item menu):
both menu setup , menu navigation demonstrated in example below.
this menu support backstepping. demonstrated in example below.
i'd glad if test , give me feedback. unfortunantly have no arduino available @ moment.
it has no limits kind of logical layout want.
[size=14]menubackend 1.0[/size]
every item can thought of cross directional connections in these direcitons: above, right, belov, left.
you can add item item @ these locations. have 2 items, called a , b.
if want these ordered horizontal menu being first item, add b @ right position.
a.addright(b);
now menu support these actions (if have added item menu):
code: [select]
menu.moveright(); //now menu.getcurrent() == b
menu.moveleft(); //now menu.getcurrent() == aboth menu setup , menu navigation demonstrated in example below.
this menu support backstepping. demonstrated in example below.
quote
#include <menubackend.h>
/*
this program demonstrates a menu modeled after the menubar in the arduino ide
+root
+file +edit +sketch +tools +help
+new +cut +verify (v) +autoformat +environment
+open
+examples
+arduinoisp
*/
//this controls the menu backend and the event generation
menubackend menu = menubackend(menuuseevent,menuchangeevent);
//beneath list of menu items needed build menu
menuitem mifile = menuitem("file");
menuitem minew = menuitem("new");
menuitem miopen = menuitem("open");
menuitem miexamples = menuitem("examples");
menuitem miarduinoisp = menuitem("arduinoisp");
menuitem miedit = menuitem("edit");
menuitem micut = menuitem("cut");
menuitem miskecth = menuitem("sketch");
menuitem miverify = menuitem("verify",'v');
menuitem mitools = menuitem("tools");
menuitem miautoformat = menuitem("autoformat");
menuitem mihelp = menuitem("help");
menuitem mienvironment = menuitem("environment");
//this function builds the menu and connects the correct items together
void menusetup()
{
serial.println("setting menu...");
//add file menu menu root
//when add used, opposed addx see below, item added below item it's added to
menu.getroot().add(mifile);
//add items below file file menu item,
//notice arduino isp item added _to right_ of examples item
mifile.add(minew).add(miopen).add(miexamples).addright(miarduinoisp);
//because edit item right of file item, use addright method when inserting item
//then add cut item, because below edit
mifile.addright(miedit).add(micut);
miedit.addright(miskecth).add(miverify);
miskecth.addright(mitools).add(miautoformat);
mitools.addright(mihelp).add(mienvironment);
}
/*
this is an important function
here all use events are handled
this is where you define a behaviour for a menu item
*/
void menuuseevent(menuuseevent used)
{
serial.print("menu use ");
serial.println(used.item.getname());
if (used.item == "arduinoisp") //comparison using string literal
{
serial.println("menuuseevent found arduinoisp");
}
if (used.item == miverify) //comparison agains known item
{
serial.println("menuuseevent found verify (v)");
}
}
/*
this is an important function
here we get a notification whenever the user changes the menu
that is, when the menu is navigated
*/
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 (see source description):");
menu.movedown(); //move file
menu.movedown(); //move new
menu.movedown(); //move open
menu.movedown(); //move examples
menu.moveright(); //move arduinoisp
menu.use(); //use arduniisp
menu.moveleft(); //move examples
menu.moveup(); //move open
menu.moveup(); //move new
menu.moveup(); //move file
menu.moveright(); //move edit
menu.moveright(); //move sketch
menu.movedown(); //move verify
menu.use(); //use verify
menu.moveback(); //move sketch
menu.moveback(); //move edit
menu.moveback(); //move file
menu.moveback(); //move new
menu.use(); //use new
menu.use('v'); //use verify based on shortkey 'v'
}
void loop()
{
//
}
i'd glad if test , give me feedback. unfortunantly have no arduino available @ moment.
hi,
it works me. i use rbbb clones.
curious why develop .h file? you throw newbies loop.
i want extend use lcd , buttons, see no reason why not work.
great job, thanks.
it works me. i use rbbb clones.
curious why develop .h file? you throw newbies loop.
i want extend use lcd , buttons, see no reason why not work.
great job, thanks.
Arduino Forum > Forum 2005-2010 (read only) > Software > Development > MenuBackend, new menu managment library
arduino
Comments
Post a Comment