From fcc662c70a14479f41d91d0d4b62ba744c952434 Mon Sep 17 00:00:00 2001 From: tablatronix Date: Fri, 15 Jan 2021 13:32:59 -0600 Subject: [PATCH] add setDarkMode alias --- WiFiManager.cpp | 12 ++++++++++++ WiFiManager.h | 12 ++++++++---- .../OnDemandConfigPortal.ino | 15 +++++++++------ .../OnDemandNonBlocking/onDemandNonBlocking.ino | 6 ++++-- strings_en.h | 16 +++++++++++----- 5 files changed, 44 insertions(+), 17 deletions(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 20e5c35..c93d0ab 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -2907,6 +2907,18 @@ void WiFiManager::setClass(String str){ _bodyClass = str; } +/** + * setDarkMode + * @param bool enable, enable dark mode via invert class + */ +void WiFiManager::setDarkMode(bool enable){ + _bodyClass = enable ? "invert" : ""; +} + +/** + * setHttpPort + * @param uint16_t port webserver port number default 80 + */ void WiFiManager::setHttpPort(uint16_t port){ _httpPort = port; } diff --git a/WiFiManager.h b/WiFiManager.h index 9163730..532c6d6 100644 --- a/WiFiManager.h +++ b/WiFiManager.h @@ -55,7 +55,7 @@ #include #endif - #define WIFI_getChipId() ESP.getChipId() + #define WIFI_getChipId() ESP.getChipId() #define WM_WIFIOPEN ENC_TYPE_NONE #elif defined(ESP32) @@ -349,9 +349,12 @@ class WiFiManager // set the country code for wifi settings, CN void setCountry(String cc); - // set body class (invert), may be used for hacking in alt classes in the future + // set body class (invert), may be used for hacking in alt classes void setClass(String str); + // set dark mode via invert class + void setDarkMode(bool enable); + // get default ap esp uses , esp_chipid etc String getDefaultAPName(); @@ -587,11 +590,12 @@ class WiFiManager // build debuglevel support // @todo use DEBUG_ESP_x? - // Testing debug level memory + // Set default debug level #ifndef WM_DEBUG_LEVEL - #define WM_DEBUG_LEVEL DEBUG_DEV + #define WM_DEBUG_LEVEL DEBUG_DEV // development default, not release #endif + // override debug level OFF #ifdef WM_NODEBUG #undef WM_DEBUG_LEVEL #endif diff --git a/examples/DEV/OnDemandConfigPortal/OnDemandConfigPortal.ino b/examples/DEV/OnDemandConfigPortal/OnDemandConfigPortal.ino index 032bd10..b96b067 100644 --- a/examples/DEV/OnDemandConfigPortal/OnDemandConfigPortal.ino +++ b/examples/DEV/OnDemandConfigPortal/OnDemandConfigPortal.ino @@ -84,10 +84,7 @@ void setup() { //reset settings - for testing // wm.resetSettings(); - // wm.erase(); - - // invert theme, dark - wm.setClass("invert"); + // wm.erase(); // setup some parameters WiFiManagerParameter custom_html("

This Is Custom HTML

"); // only custom html @@ -119,14 +116,20 @@ void setup() { custom_html.setValue("test",4); custom_token.setValue("test",4); + // invert theme, dark + wm.setDarkMode(true); + + // show scan RSSI as percentage, instead of signal stength graphic + // wm.setScanDispPerc(true); + /* Set cutom menu via menu[] or vector const char* menu[] = {"wifi","wifinoscan","info","param","close","sep","erase","restart","exit"}; wm.setMenu(menu,9); // custom menu array must provide length */ - std::vector menu = {"wifi","wifinoscan","info","param","close","sep","erase","restart","exit"}; - // wm.setMenu(menu); // custom menu, pass vector + std::vector menu = {"wifi","wifinoscan","info","param","close","sep","erase","update","restart","exit"}; + wm.setMenu(menu); // custom menu, pass vector // wm.setParamsPage(true); // move params to seperate page, not wifi, do not combine with setmenu! diff --git a/examples/NonBlocking/OnDemandNonBlocking/onDemandNonBlocking.ino b/examples/NonBlocking/OnDemandNonBlocking/onDemandNonBlocking.ino index 3813356..649b120 100644 --- a/examples/NonBlocking/OnDemandNonBlocking/onDemandNonBlocking.ino +++ b/examples/NonBlocking/OnDemandNonBlocking/onDemandNonBlocking.ino @@ -51,13 +51,15 @@ void loop() { void doWiFiManager(){ // is auto timeout portal running if(portalRunning){ - wm.process(); + wm.process(); // do processing + + // check for timeout if((millis()-startTime) > (timeout*1000)){ Serial.println("portaltimeout"); portalRunning = false; if(startAP){ wm.stopConfigPortal(); - } + } else{ wm.stopWebPortal(); } diff --git a/strings_en.h b/strings_en.h index cd4ffee..01e5e96 100644 --- a/strings_en.h +++ b/strings_en.h @@ -14,16 +14,22 @@ #define _WM_STRINGS_H_ #ifndef WIFI_MANAGER_OVERRIDE_STRINGS -// !!! THIS DOES NOT WORK, you cannot define in a sketch, if anyone one knows how to order includes to be able to do this help! +// !!! ABOVE WILL NOT WORK if you define in your sketch, must be build flag, if anyone one knows how to order includes to be able to do this it would be neat.. I have seen it done.. + +const char HTTP_HEAD_START[] PROGMEM = "" +"" +"" +"" +"" +"{v}"; -const char HTTP_HEAD_START[] PROGMEM = "{v}"; const char HTTP_SCRIPT[] PROGMEM = ""; +"if(p)document.getElementById('p').focus();}"; // @todo add button states, disable on click , show ack , spinner etc -const char HTTP_HEAD_END[] PROGMEM = "
"; +const char HTTP_HEAD_END[] PROGMEM = "
"; // {c} = _bodyclass // example of embedded logo, base64 encoded inline, No styling here // const char HTTP_ROOT_MAIN[] PROGMEM = "

{v}

WiFiManager

"; const char HTTP_ROOT_MAIN[] PROGMEM = "

{v}

WiFiManager

"; @@ -43,7 +49,7 @@ const char * const HTTP_PORTAL_MENU[] PROGMEM = { // const char HTTP_PORTAL_OPTIONS[] PROGMEM = strcat(HTTP_PORTAL_MENU[0] , HTTP_PORTAL_MENU[3] , HTTP_PORTAL_MENU[7]); const char HTTP_PORTAL_OPTIONS[] PROGMEM = ""; const char HTTP_ITEM_QI[] PROGMEM = ""; // rssi icons -const char HTTP_ITEM_QP[] PROGMEM = "
{r}%
"; // rssi percentage +const char HTTP_ITEM_QP[] PROGMEM = "
{r}%
"; // rssi percentage {h} = hidden showperc pref const char HTTP_ITEM[] PROGMEM = "
{v}{qi}{qp}
"; // {q} = HTTP_ITEM_QI, {r} = HTTP_ITEM_QP // const char HTTP_ITEM[] PROGMEM = "
{v} {R} {r}% {q} {e}
"; // test all tokens