-
-
Notifications
You must be signed in to change notification settings - Fork 196
Menu definition
##Menu definition macros
This macros define read-only static menu structure (PROGMEM on system that support it).
OP - define a prompt with associated action function
OP(text,action,event mask)
result goFun() {Serial.println("done!");return proceed;}
...
OP("Go!",goFun,enterEvent)
Creates an 'anonymous' option as a parent's menu element. This option is associated with an action function to be called according to elements mask.
Prompt's are the menu basic structure, all other elements will share its poroperties. That is all can have a title, an action function and an event mask.
The action function will be called on every event occurrence.
The action function can send back some 'result' information to be interpreted by the caller. The meaning of this result depends on the caller and it might ignore it.
It is annonymous because no variable representing this particular option will be created on your code. Therefor it can only be accessible by indexing the menu that holds it, like menu[0] for indexing into the first option.
MENU - define a menu
MENU( id, title, action, events mask, styles, Option, Option, [Option,...])
a menu object 'id' is statically created and can be refered in your sketch by its 'id'.
MENU(myMenu,"Schedule",doNothing,noEvent,wrapStyle
,OP("Op A", actionA,enterEvent)
,OP("Op B",actionB,enterEvent)
,OP("Op C",actionC,enterEvent)
,FIELD(test,"Test","%",0,100,10,1,doNothing,noEvent,wrapStyle)
);
disabling an option.
myMenu[2].disable();//example of disabling a menu option
FIELD - numeric field for editing and range validate a numeric variable (int, float, double, unsigned int, etc...)
FIELD(var.name, title, units, min., max., step size,fine step size, action, events mask, styles)
int pwm=0;
...
FIELD(pwm,"Power","%",0,100,10,1,doNothing,noEvent,noStyle)
SELECT - define varible value by selecting from an enumerated list of possible values. Click to start, select, click to end.
SELECT(var.name, id, title, action, events meask, styles, value, value [, value ...])
This creates a static menu like structure associated with a variable, enumeratin all possible variable values. Changing the selection will change the variable value and also reflects variable changes done elsewhere.
int mode=0;
SELECT(mode,selMenu,"Select",doNothing,noEvent,noStyle
,VALUE("Eco",0,doNothing,noEvent)
,VALUE("Normal",1,doNothing,noEvent)
,VALUE("Full",2,doNothing,noEvent)
);
MENU(myMenu,"Schedule",doNothing,noEvent,wrapStyle
,SUBMENU(selMenu)
,...
)
TOGGLE - set a variable value by toggling from an enumerated list of possible values. Change value every click.
TOGGLE(var.name, id, title, action, event mask, styles, value, value [,value ...])
int dir=LOW;
TOGGLE(dir,dirPinMenu,"Dir: ",doNothing,noEvent,wrapStyle
,VALUE("Up",HIGH,doNothing,noEvent)
,VALUE("Down",LOW,doNothing,noEvent)
);
//hooking the toggle to a menu
MENU(myMenu,"Schedule",doNothing,noEvent,wrapStyle
,SUBMENU(dirPinMenu)
,...
);
Creates a menu-like structure enumerating all possible values of the associated var.
CHOOSE - define varible value by chosing from an enumerated list of possible values. Enumerated list of values shown as a submenu.
CHOOSE(var.name, id, title, action, evant mask, styles, value, value [,valu ...])
int chooseTest=-1;//some variable used by your code (not necessarly an int)
CHOOSE(chooseTest,chooseMenu,"Choose",doNothing,noEvent,noStyle
,VALUE("First",1,doNothing,noEvent)
,VALUE("Second",2,doNothing,noEvent)
,VALUE("Third",3,doNothing,noEvent)
,VALUE("Last",-1,doNothing,noEvent)
);
MENU(mainMenu,"Main menu",doNothing,noEvent,wrapStyle
,SUBMENU(chooseMenu)
,...
);
Creates a static menu like structure enumerating all possible values of the associated varible.
SUBMENU - include a menu as submenu or a SELECT|TOGGLE|CHOOSE field.
MENU(myMenu,"Schedule",doNothing,noEvent,wrapStyle
,OP("Op A", actionA,enterEvent)
,OP("Op B",actionB,enterEvent)
,OP("Op C",actionC,enterEvent)
,FIELD(test,"Test","%",0,100,10,1,doNothing,noEvent,wrapStyle)
);
MENU(mainMenu,"Main menu",doNothing,noEvent,wrapStyle
,SUBMENU(myMenu)
,...
);
include a menu or menu like structure as element of the current menu.
EXIT - quick define special option to leave current menu.
EXIT("<Back")
Create an option that exits the curremt menu as default action.
Elements can have this static styles.
noStyle accepts system defaults to this elements
wrapStyle element values list have a circular arrangement.
##events
this is used to for the filter mask and also send as a parameter to the event handler function.
noEvent no event (use if you do not want an handler function)
activateEvent the item is about to be active (system event)
enterEvent entering navigation level (this menu is now active)
exitEvent leaving navigation level
returnEvent entering previous level (return)
focusEvent element just gained focus
blurEvent element about to lose focus
selFocusEvent child just gained focus
selBlurEvent child about to lose focus
anyEvent all events
events can be combined like:
enterEvent | exitEvent
These commands are for semi-automated mode. User code can call the navigation root with them.
example:
nav.doNav(upCmd);
see navigation commands for a list of available commands.