Skip to content

Commit 757962d

Browse files
committed
async functions passed to conditional compile
1 parent 5198bb0 commit 757962d

File tree

2 files changed

+31
-20
lines changed

2 files changed

+31
-20
lines changed

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 & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,11 @@ for correcting unsigned values validation
104104
inline result operator()(FUNC_PARAMS) const {return (*shadow)(FUNC_VALUES);}
105105
idx_t printRaw(menuOut& out,idx_t len) const;
106106
virtual prompt* seek(idx_t* uri,idx_t len) {return len?NULL:this;}
107+
#ifdef MENU_ASYNC
107108
virtual bool async(const char *uri,navRoot& root,idx_t lvl) {
108109
return ((!*uri)||(uri[0]=='/'&&!uri[1]));
109110
}
111+
#endif
110112

111113
//some functions to use on htmlFmt
112114
// for enumerations:
@@ -167,7 +169,9 @@ for correcting unsigned values validation
167169
bool tunning=false;
168170
fieldBase(constMEM promptShadow& shadow):navTarget(shadow) {}
169171
virtual classes type() const {return fieldClass;}
170-
bool async(const char *uri,navRoot& root,idx_t lvl) override;
172+
#ifdef MENU_ASYNC
173+
bool async(const char *uri,navRoot& root,idx_t lvl) override;
174+
#endif
171175
inline constMEM char* units() {return ((fieldBaseShadow*)shadow)->_units();}
172176
void doNav(navNode& nav,navCmd cmd) override;
173177
virtual bool canTune()=0;
@@ -259,7 +263,9 @@ for correcting unsigned values validation
259263
inline idx_t sz() const {return ((menuNodeShadow*)shadow)->_sz();}
260264
inline prompt* constMEM* data() const {return ((menuNodeShadow*)shadow)->_data();}
261265
prompt* seek(idx_t* uri,idx_t len) override;
262-
bool async(const char *uri,navRoot& root,idx_t lvl=0) override;
266+
#ifdef MENU_ASYNC
267+
bool async(const char *uri,navRoot& root,idx_t lvl=0) override;
268+
#endif
263269
};
264270

265271
//--------------------------------------------------------------------------
@@ -703,32 +709,33 @@ for correcting unsigned values validation
703709
return sleepTask?idleChanged:node().changed(out);
704710
}
705711
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);
712+
#ifdef MENU_ASYNC
713+
inline bool async(const char* at) {
714+
navFocus=path[level].target;
715+
return active().async(at, *this, 0);
714716
}
715-
return o;
716-
}
717+
menuOut& printPath(menuOut& o) const {
718+
for(idx_t n=0;n<level;n++) {
719+
o.print('/');
720+
o.print(path[n].sel);
721+
}
722+
return o;
723+
}
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+
#endif
717732
Used printMenu() const {
718733
trace(Serial<<"navRoot::printMenu"<<endl);
719734
if ((active().sysStyles()&_parentDraw)&&level)
720735
return out.printMenu(path[level-1]);
721736
else return out.printMenu(node());
722737
}
723738

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-
732739
//menu IO - external iteration functions
733740
void doInput(menuIn& in);
734741
inline void doInput(const char*in) {

0 commit comments

Comments
 (0)