mirror of
https://github.com/alexhopeoconnor/WiFiManager.git
synced 2026-10-16 16:01:36 +10:00
menuids as vector to deal with size
This kind of makes it a pain in the ass for users, not sure how to make this easier, I can take in an array of string ids, with a count arg, makes it easier, but then users can pass nonsense in, this way its enum ids, but damn it sure is convoluted. Welcome to ideas here...
```c++
std::vector<WiFiManager::menu_page_t> menu = {wm.MENU_WIFI,wm.MENU_INFO,wm.MENU_PARAM,wm.MENU_CLOSE,wm.MENU_SEP,wm.MENU_ERASE,wm.MENU_EXIT};
wm.setMenu(menu);
```
This commit is contained in:
+14
-5
@@ -807,12 +807,14 @@ void WiFiManager::handleParam(){
|
||||
|
||||
String WiFiManager::getMenuOut(){
|
||||
String page;
|
||||
int i;
|
||||
for(i=0;i<sizeof(_menuIds);i++){
|
||||
if(_menuIds[i] == MENU_END) break; // MENU_END
|
||||
if((_menuIds[i] == MENU_PARAM) && (_paramsCount == 0)) continue; // no params set, omit params
|
||||
page += HTTP_PORTAL_MENU[_menuIds[i]];
|
||||
|
||||
for(menu_page_t& v :_menuIds_v ){
|
||||
// DEBUG_WM("menuid:",(String)v);
|
||||
// if(v == MENU_END) break; // MENU_END
|
||||
if((v == MENU_PARAM) && (_paramsCount == 0)) continue; // no params set, omit params
|
||||
page += HTTP_PORTAL_MENU[v];
|
||||
}
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
@@ -1896,6 +1898,12 @@ void WiFiManager::setMenu(menu_page_t menu[], uint8_t size){
|
||||
if(i >= n) _menuIds[i] = MENU_END;
|
||||
else _menuIds[i] = menu[i];
|
||||
}
|
||||
|
||||
// @todo copy into vector if we keep this..
|
||||
}
|
||||
|
||||
void WiFiManager::setMenu(std::vector<menu_page_t>& menu){
|
||||
_menuIds_v = menu;
|
||||
}
|
||||
|
||||
// GETTERS
|
||||
@@ -1936,6 +1944,7 @@ bool WiFiManager::getWiFiIsSaved(){
|
||||
// HELPERS
|
||||
|
||||
// DEBUG
|
||||
// @todo fix DEBUG_WM(0,0);
|
||||
template <typename Generic>
|
||||
void WiFiManager::DEBUG_WM(Generic text) {
|
||||
DEBUG_WM(DEBUG_NOTIFY,text,"");
|
||||
|
||||
Reference in New Issue
Block a user