-
-
Notifications
You must be signed in to change notification settings - Fork 195
Menu structure objects
Menu structure objects are somehow complicated in great extent due to flash memory (PROGMEM) usage and the AVR architecture along with the bad combination of C++.
That said, you should take some caution when messing around with them, specially do not try to read pointers to flash, and there are some on menu structures, with regular reading memory functions like print or println or any other that read data from ram.
Anyway I will only present some basic aspects of the objects and its hierarchy.
Prompts are the most basic menu structure it derives from an Action and associate it with a text.
They can be constructed by macro OP. (see menu definition)
Here is an example of initializing an option without macros for an non-AVR (PROGMEM) device.
//define "Op 1"
void op1Func();
promptShadow op1Info("Op 1",(callback)op1Func,enterEvent);
prompt op1(op1Info);
And here the same for an AVR (PROGMEM) device.
//define "Op 1"
void op1Func();
const char op1Text[] PROGMEM="Op 1";
const promptShadowRaw op1InfoRaw PROGMEM={(callback)op1Func,\_noStyle,op1Text,enterEvent,noStyle};
const promptShadow& op1Info=*(promptShadow*)&op1InfoRaw;
prompt op1(op1Info);
OP macro automates all of that, but it must be used inside a MENU macro.
public prompt
This is an intermediate class of all menu elements that can process keys by definming:
parse one character from the input in the given navigation context.
where:
nav navigation context pointing to current menu with information about selection (see navNode).
in the input stream.
execute the navigation command within the navigation context
nav navigation context pointing to current menu with information about selection (see navNode).
cmd the navigation command (see navCmds)
public navTarget
All menu elements that contain a list of other menu elements (like: menu, toggle, choose, select).
access sub-element by index
where:
i the index number of the element
returns true if this element needs to be redraw on the output devices
where:
nav the navigation context
out the output device
sub true to also check sub elements
returns the numbers of contained elements (list size)
get the array of data, caution this might be on flash memory
experimental function for assync navigation and web interface
experimental function for assync navigation and web interface
public menuNode
Just a raw menu implementation straight from its base class menuNode. no extra functions added.
public navTarget
interact with a ranged numeric value by changing and trimming it inside bounds.
true if the field edition is on fine tuning phase.
a copy of the last edited value to detect external changes and signal changed to reflect the change back to the menu user.
print this element on a menu output device
return: the remaining space
where:
root the navigation root
sel is this element selected
out the output device
idx the given index in case device needs to print accelerators
len allowed length to be used
get the original target value
get units string, caution this might be on flash memory.
get lower bound
get upper bound
get the increment step
get the tuning step
## void clamp()
force value into bounds
public prompt
represents the allowed values on enumerated fields (Toggle, Select, Choice)
public menuNode
base for all enumerated fields (Toggle, select, Choice)
Synchronize the selected value with the variable (assuming that the variable can not have values other than the enumerated ones)
Synchronize the variable value with the selection
get the selected index
public menuVariant<T>
enumerated field, click and scroll to select value in place.
public menuVariant<T>
enumerated field, click to change value
public menuVariant<T>
enumerated field, click to select value as a sub-menu