From c9e82ae920addfbb328e04e13dc72b743bff089e Mon Sep 17 00:00:00 2001 From: Shawn A Date: Fri, 16 Mar 2018 15:55:53 -0500 Subject: [PATCH] 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 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); ``` --- WiFiManager.cpp | 19 ++++++++++++++----- WiFiManager.h | 7 +++++-- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 05fac82..7980c9a 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -807,12 +807,14 @@ void WiFiManager::handleParam(){ String WiFiManager::getMenuOut(){ String page; - int i; - for(i=0;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){ + _menuIds_v = menu; } // GETTERS @@ -1936,6 +1944,7 @@ bool WiFiManager::getWiFiIsSaved(){ // HELPERS // DEBUG +// @todo fix DEBUG_WM(0,0); template void WiFiManager::DEBUG_WM(Generic text) { DEBUG_WM(DEBUG_NOTIFY,text,""); diff --git a/WiFiManager.h b/WiFiManager.h index 9144167..e90c9e5 100644 --- a/WiFiManager.h +++ b/WiFiManager.h @@ -13,6 +13,8 @@ #ifndef WiFiManager_h #define WiFiManager_h +#include + // #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); + + void setMenu(std::vector& 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 _menuIds_v = {MENU_WIFI,MENU_INFO,MENU_EXIT}; // ip configs @todo struct ? IPAddress _ap_static_ip;