add customMenuHTML

This commit is contained in:
tablatronix
2022-03-29 13:34:58 -05:00
parent 88b97c7caa
commit 6a85acdf85
4 changed files with 40 additions and 12 deletions
@@ -23,7 +23,7 @@ WiFiManager wm;
// TEST OPTION FLAGS
bool TEST_CP = false; // always start the configportal, even if ap found
bool TEST_CP = true; // always start the configportal, even if ap found
int TESP_CP_TIMEOUT = 90; // test cp timeout
bool TEST_NET = true; // do a network test after connect, (gets ntp time)
@@ -90,6 +90,7 @@ void setup() {
// wm.erase();
// setup some parameters
WiFiManagerParameter custom_html("<p style=\"color:pink;font-weight:Bold;\">This Is Custom HTML</p>"); // only custom html
WiFiManagerParameter custom_mqtt_server("server", "mqtt server", "", 40);
WiFiManagerParameter custom_mqtt_port("port", "mqtt port", "", 6);
@@ -143,6 +144,14 @@ void setup() {
custom_html.setValue("test",4);
custom_token.setValue("test",4);
// set custom html head content , inside <head>
const char* headhtml = "<meta name='color-scheme' content='dark light'><style></style><script></script>";
wm.setCustomHeadElement(headhtml);
// set custom html menu content , inside <head>
const char* menuhtml = "<form action='/custom' method='get'><button>Custom</button></form><br/>\n";
wm.setCustomMenuHTML(menuhtml);
// invert theme, dark
wm.setDarkMode(true);
@@ -155,7 +164,7 @@ void setup() {
wm.setMenu(menu,9); // custom menu array must provide length
*/
std::vector<const char *> menu = {"wifi","wifinoscan","info","param","close","sep","erase","update","restart","exit"};
std::vector<const char *> menu = {"wifi","wifinoscan","info","param","custom","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!
@@ -242,7 +251,7 @@ void setup() {
delay(1000);
Serial.println("TEST_CP ENABLED");
wm.setConfigPortalTimeout(TESP_CP_TIMEOUT);
wm.startConfigPortal("WM_ConnectAP");
wm.startConfigPortal("WM_ConnectAP","12345678");
}
else {
//if you get here you have connected to the WiFi