@@ -22,6 +22,8 @@ for encoders, joysticks, keyboards or touch a stream must be made out of them
2222 #define RSITE_ARDUINOP_MENU_SYSTEM
2323
2424 #include < Stream.h>
25+ #include < HardwareSerial.h>
26+ #include " ../utils/streamFlow.h"
2527
2628 class prompt ;
2729 class menu ;
@@ -98,14 +100,14 @@ for encoders, joysticks, keyboards or touch a stream must be made out of them
98100 menu id (text,sizeof (id##_data)/sizeof(prompt*),id##_data);
99101
100102 #define OP (...) OP_(__COUNTER__,__VA_ARGS__)
101- #define FIELD_INT (...) FIELD_INT_ (__COUNTER__,__VA_ARGS__)
103+ #define FIELD (...) FIELD_ (__COUNTER__,__VA_ARGS__)
102104
103105 #define DECL_OP_ (cnt,...) prompt op##cnt(__VA_ARGS__);
104- #define DECL_FIELD_INT_ (cnt,...) menuField<int > _menuField_int ##cnt(__VA_ARGS__);
106+ #define DECL_FIELD_ (cnt,type, ...) menuField<type> _menuField ##cnt(__VA_ARGS__);
105107 #define DECL_SUBMENU (id )
106108
107109 #define DEF_OP_ (cnt,...) &op##cnt
108- #define DEF_FIELD_INT_ (cnt,...) &_menuField_int ##cnt
110+ #define DEF_FIELD_ (cnt,type, ...) &_menuField ##cnt
109111 #define DEF_SUBMENU (id ) &id
110112
111113
@@ -128,13 +130,15 @@ for encoders, joysticks, keyboards or touch a stream must be made out of them
128130 virtual void setCursor (int x,int y)=0;
129131 virtual void print (char ch)=0;
130132 virtual void print (const char *text)=0;
131- virtual void println (const char *text)=0;
133+ virtual void println (const char *text= " " )=0;
132134 virtual void print (int )=0;
133135 virtual void println (int )=0;
134136 virtual void print (double )=0;
135137 virtual void println (double )=0;
136138 virtual void print (prompt &o,bool selected,int idx,int posY,int width)=0;
137- virtual void print (menuField<int > &o,bool selected,int idx,int posY,int width)=0;
139+ virtual void print (menuField<int > &o,bool selected,int idx,int posY,int width) {
140+ println (" Ok, this is it" );
141+ }
138142 virtual void printMenu (menu&,bool drawExit)=0;
139143 };
140144
@@ -169,11 +173,17 @@ for encoders, joysticks, keyboards or touch a stream must be made out of them
169173 const char *text;
170174 promptAction action;
171175 bool enabled;
172- prompt (const char * text, bool enabled= true ):text(text),enabled(enabled ) {}
176+ prompt (const char * text):text(text),enabled(true ) {}
173177 prompt (const char * text,promptAction action)
174178 :text(text),action(action),enabled(true ) {}
175- virtual size_t printTo (Print& p) {p.print (text);return strlen (text);}
176- virtual void activate (menuOut& p,Stream&c,bool ) {action (*this ,p,c);}
179+ virtual size_t printTo (Print& p) {
180+ // Serial<<"printing prompt"<<endl;
181+ p.print (text);return strlen (text);
182+ }
183+ virtual void activate (menuOut& p,Stream&c,bool ) {
184+ // Serial<<"activating prompt "<<text<<endl;
185+ action (*this ,p,c);
186+ }
177187 };
178188
179189 // a menu or sub-menu
@@ -185,14 +195,19 @@ for encoders, joysticks, keyboards or touch a stream must be made out of them
185195 static char disabledCursor;// to be used when navigating over disabled options
186196 static prompt exitOption;// option to append to menu allowing exit when no escape button/key is available
187197 static menu* activeMenu;
188- menu* previousMenu;
189198 const int sz;
199+ menu* previousMenu;
190200 int sel;// selection
191201 prompt* const * data PROGMEM;
192202 menu (const char * text,int sz,prompt* const data[]):prompt(text),sz(sz),data(data),sel(0 ),width(16 ),previousMenu(NULL ) {}
193203
204+ virtual size_t printTo (Print& p) {
205+ Serial<<" printing menu..." <<endl;
206+ }
194207 int menuKeys (menuOut &p,Stream& c,bool drawExit);
195- inline void printMenu (menuOut& p,bool drawExit) {p.printMenu (*this ,drawExit);}
208+ inline void printMenu (menuOut& p,bool drawExit) {
209+ p.printMenu (*this ,drawExit);
210+ }
196211
197212 void activate (menuOut& p,Stream& c,bool canExit=false );
198213
0 commit comments