Skip to content

Commit 3747e89

Browse files
committed
Merge branch 'dev'
2 parents 2786220 + 3f0cd98 commit 3747e89

File tree

3 files changed

+32
-25
lines changed

3 files changed

+32
-25
lines changed

examples/CustomPrompt/CustomPrompt/CustomPrompt.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ void setup() {
9696
// delay(1000);
9797
// }
9898

99+
//NOTE: async is disabled now define MENU_ASYNC to activate it
99100
//following code is an async navigation example
100101
//its async because it does not require a known menu state
101102
//because you can indicate the zero indexed option positions separated by /

src/menu.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ prompt* menuNode::seek(idx_t* uri,idx_t len) {
4343
return e.seek(++uri,--len);
4444
} else return NULL;
4545
}
46+
#ifdef MENU_ASYNC
4647
bool menuNode::async(const char *uri,navRoot& root,idx_t lvl) {
4748
trace(Serial<<"menuNode::async"<<endl);
4849
if ((!*uri)||(uri[0]=='/'&&!uri[1])) return this;
@@ -66,6 +67,7 @@ bool menuNode::async(const char *uri,navRoot& root,idx_t lvl) {
6667
//Serial<<"recurse on ["<<n<<"]-"<<operator[](n)<<" uri:"<<uri<<" lvl:"<<lvl<<endl;Serial.flush();
6768
return operator[](n).async(uri,root,++lvl);
6869
}
70+
#endif
6971

7072
void textField::doNav(navNode& nav,navCmd cmd) {
7173
trace(Serial<<"textField::doNav"<<endl);
@@ -664,6 +666,7 @@ navCmd navRoot::exit() {
664666
return escCmd;
665667
}
666668

669+
#ifdef MENU_ASYNC
667670
bool fieldBase::async(const char *uri,navRoot& root,idx_t lvl) {
668671
trace(Serial<<"fieldBase::async"<<endl);
669672
if ((!*uri)||(uri[0]=='/'&&!uri[1])) return true;
@@ -674,6 +677,7 @@ bool fieldBase::async(const char *uri,navRoot& root,idx_t lvl) {
674677
}
675678
return true;
676679
}
680+
#endif
677681

678682
void fieldBase::doNav(navNode& nav,navCmd cmd) {
679683
trace(Serial<<"fieldBase::doNav "<<cmd<<endl);

src/menu.h

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,7 @@ for correcting unsigned values validation
1919
#define RSITE_ARDUINO_MENU_SYSTEM
2020
#include <Arduino.h>
2121
#if defined(DEBUG)
22-
// #ifdef _U8G2LIB_HH
23-
//because U8G2 already uses Streaming
2422
#include <Streaming.h>
25-
// #else
26-
// #include <streamFlow.h>
27-
// #endif
2823
#endif
2924
#include "menuBase.h"
3025
#include "shadows.h"
@@ -104,9 +99,11 @@ for correcting unsigned values validation
10499
inline result operator()(FUNC_PARAMS) const {return (*shadow)(FUNC_VALUES);}
105100
idx_t printRaw(menuOut& out,idx_t len) const;
106101
virtual prompt* seek(idx_t* uri,idx_t len) {return len?NULL:this;}
102+
#ifdef MENU_ASYNC
107103
virtual bool async(const char *uri,navRoot& root,idx_t lvl) {
108104
return ((!*uri)||(uri[0]=='/'&&!uri[1]));
109105
}
106+
#endif
110107

111108
//some functions to use on htmlFmt
112109
// for enumerations:
@@ -167,7 +164,9 @@ for correcting unsigned values validation
167164
bool tunning=false;
168165
fieldBase(constMEM promptShadow& shadow):navTarget(shadow) {}
169166
virtual classes type() const {return fieldClass;}
170-
bool async(const char *uri,navRoot& root,idx_t lvl) override;
167+
#ifdef MENU_ASYNC
168+
bool async(const char *uri,navRoot& root,idx_t lvl) override;
169+
#endif
171170
inline constMEM char* units() {return ((fieldBaseShadow*)shadow)->_units();}
172171
void doNav(navNode& nav,navCmd cmd) override;
173172
virtual bool canTune()=0;
@@ -259,7 +258,9 @@ for correcting unsigned values validation
259258
inline idx_t sz() const {return ((menuNodeShadow*)shadow)->_sz();}
260259
inline prompt* constMEM* data() const {return ((menuNodeShadow*)shadow)->_data();}
261260
prompt* seek(idx_t* uri,idx_t len) override;
262-
bool async(const char *uri,navRoot& root,idx_t lvl=0) override;
261+
#ifdef MENU_ASYNC
262+
bool async(const char *uri,navRoot& root,idx_t lvl=0) override;
263+
#endif
263264
};
264265

265266
//--------------------------------------------------------------------------
@@ -703,32 +704,33 @@ for correcting unsigned values validation
703704
return sleepTask?idleChanged:node().changed(out);
704705
}
705706
inline bool changed(idx_t n) const {return changed(out[n]);}
706-
inline bool async(const char* at) {
707-
navFocus=path[level].target;
708-
return active().async(at, *this, 0);
709-
}
710-
menuOut& printPath(menuOut& o) const {
711-
for(idx_t n=0;n<level;n++) {
712-
o.print('/');
713-
o.print(path[n].sel);
707+
#ifdef MENU_ASYNC
708+
inline bool async(const char* at) {
709+
navFocus=path[level].target;
710+
return active().async(at, *this, 0);
714711
}
715-
return o;
716-
}
712+
menuOut& printPath(menuOut& o) const {
713+
for(idx_t n=0;n<level;n++) {
714+
o.print('/');
715+
o.print(path[n].sel);
716+
}
717+
return o;
718+
}
719+
//async printMenu on arbitrary menuOut device
720+
Used printMenu(menuOut& o) const {
721+
_trace(Serial<<"navRoot::printMenu(menuOut& o)"<<endl);
722+
if ((active().sysStyles()&_parentDraw)&&level)
723+
return o.printMenu(path[level-1]);
724+
else return o.printMenu(node());
725+
}
726+
#endif
717727
Used printMenu() const {
718728
trace(Serial<<"navRoot::printMenu"<<endl);
719729
if ((active().sysStyles()&_parentDraw)&&level)
720730
return out.printMenu(path[level-1]);
721731
else return out.printMenu(node());
722732
}
723733

724-
//async printMenu on arbitrary menuOut device
725-
Used printMenu(menuOut& o) const {
726-
_trace(Serial<<"navRoot::printMenu(menuOut& o)"<<endl);
727-
if ((active().sysStyles()&_parentDraw)&&level)
728-
return o.printMenu(path[level-1]);
729-
else return o.printMenu(node());
730-
}
731-
732734
//menu IO - external iteration functions
733735
void doInput(menuIn& in);
734736
inline void doInput(const char*in) {

0 commit comments

Comments
 (0)