@@ -16,22 +16,81 @@ Extensible: Yes
1616#include < menuPrint.h>
1717// #include <streamFlow.h>
1818
19- int param;
19+ #define LEDPIN 13
20+
21+ // aux vars
22+ int ledCtrl=0 ;
23+ int percent;// just testing changing this var
24+ double fps=0 ;
25+ int counter=0 ;
26+
27+ // /////////////////////////////////////////////////////////////////////////
28+ // functions to wire as menu actions
29+ bool ledOn () {
30+ Serial.println (" set led on!" );
31+ digitalWrite (LEDPIN,ledCtrl=1 );
32+ return false ;
33+ }
34+
35+ bool ledOff () {
36+ Serial.println (" set led off!" );
37+ digitalWrite (LEDPIN,ledCtrl=0 );
38+ return false ;
39+ }
40+
41+ bool quit () {
42+ Serial.println (" Quiting after action call" );
43+ return true ;
44+ }
2045
2146// ///////////////////////////////////////////////////////////////////////
2247// MENU DEFINITION
2348// here we define the menu structure and wire actions functions to it
24- bool test=false ;
25- TOGGLE (test,onoff_tog," led: " ,
26- VALUE (" On" ,HIGH),
27- VALUE(" Off" ,LOW)
49+ // empty options are just for scroll testing
50+
51+ /* bool setLed() {
52+ digitalWrite(LEDPIN,ledCtrl);
53+ return false;
54+ }*/
55+ TOGGLE (ledCtrl,setLed," Led: " ,
56+ VALUE (" On" ,HIGH,ledOn),
57+ VALUE(" Off" ,LOW,ledOff)
58+ );
59+
60+ int selTest=0 ;
61+ SELECT (selTest,selMenu," Select" ,
62+ VALUE (" Zero" ,0 ),
63+ VALUE(" One" ,1 ),
64+ VALUE(" Two" ,2 )
2865);
2966
67+ int chooseTest=-1 ;
68+ CHOOSE (chooseTest,chooseMenu," Choose " ,
69+ VALUE (" First" ,1 ),
70+ VALUE(" Second" ,2 ),
71+ VALUE(" Third" ,3 ),
72+ VALUE(" Last" ,-1 )
73+ );
74+
75+ MENU (subMenu," SubMenu"
76+ ,OP(" A" ,quit)
77+ ,OP(" B" ,quit)
78+ ,OP(" C" ,quit)
79+ ,OP(" D" ,quit)
80+ ,OP(" E" ,quit)
81+ ,OP(" F" ,quit)
82+ ,OP(" G" ,quit)
83+ ,OP(" H" ,quit)
84+ );
3085
3186MENU (mainMenu," Main menu" ,
32- OP (" Disabled option" ,menu::nothing),
33- SUBMENU(onoff_tog),
34- FIELD(param," Name" ," %" ,0 ,100 ,10 ,1 )
87+ SUBMENU (setLed),
88+ OP(" LED On" ,ledOn),
89+ OP(" LED Off" ,ledOff),
90+ SUBMENU(selMenu),
91+ SUBMENU(chooseMenu),
92+ SUBMENU(subMenu),
93+ FIELD(percent," Percent" ," %" ,0 ,100 ,10 ,1 )
3594);
3695
3796menuPrint menu_out (Serial);// describe output device
@@ -40,11 +99,11 @@ void setup() {
4099 Serial.begin (115200 );
41100 while (!Serial);
42101 Serial.println (" menu system test" );
43- pinMode (13 ,OUTPUT);
102+ pinMode (LEDPIN ,OUTPUT);
44103 mainMenu.data [0 ]->enabled =false ;
45104}
46105
47106void loop () {
48107 mainMenu.poll (menu_out,Serial);
49- digitalWrite (13 ,test );
108+ digitalWrite (LEDPIN,ledCtrl );
50109}
0 commit comments