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,"");
|
||||
|
||||
+5
-2
@@ -13,6 +13,8 @@
|
||||
#ifndef WiFiManager_h
|
||||
#define WiFiManager_h
|
||||
|
||||
#include <vector>
|
||||
|
||||
// #define WM_MDNS // also set MDNS with sethostname
|
||||
// #define WM_FIXERASECONFIG // use erase flash fix
|
||||
// #define WM_ERASE_NVS // esp32 erase(true) will erase NVS
|
||||
@@ -220,8 +222,8 @@ class WiFiManager
|
||||
// show erase wifi onfig button on info page, true
|
||||
void setShowInfoErase(boolean enabled);
|
||||
// set custom menu
|
||||
|
||||
// void setMenu(const std:vector<menu_page_t>& menu);
|
||||
|
||||
void setMenu(std::vector<menu_page_t>& menu);
|
||||
void setMenu(menu_page_t menu[], uint8_t size);
|
||||
|
||||
// get last connection result, includes autoconnect and wifisave
|
||||
@@ -254,6 +256,7 @@ class WiFiManager
|
||||
} wm_debuglevel_t;
|
||||
|
||||
menu_page_t _menuIds[10] = {MENU_WIFI,MENU_INFO,MENU_EXIT,MENU_END};
|
||||
std::vector<menu_page_t> _menuIds_v = {MENU_WIFI,MENU_INFO,MENU_EXIT};
|
||||
|
||||
// ip configs @todo struct ?
|
||||
IPAddress _ap_static_ip;
|
||||
|
||||
Reference in New Issue
Block a user