diff --git a/examples/gui-generic-api/gui-generic-api.ino b/examples/gui-generic-api/gui-generic-api.ino index 46e4324..51fee86 100644 --- a/examples/gui-generic-api/gui-generic-api.ino +++ b/examples/gui-generic-api/gui-generic-api.ino @@ -11,16 +11,15 @@ DNSServer dnsServer; #include #endif -// true for verbose, false for quiet -ESPUIClass ESPUI(Verbosity::VerboseJSON); - const char *ssid = "ESPUI"; const char *password = "espui"; -const char *hostname = "EspuiTest"; +const char *hostname = "espui"; uint16_t button1; -void numberCall(Control *sender, int type) { Serial.println(sender->value); } +void numberCall( Control* sender, int type ) { + Serial.println( sender->value ); +} void textCall(Control *sender, int type) { Serial.print("Text: ID: "); @@ -153,6 +152,7 @@ void otherSwitchExample(Control *sender, int value) { } void setup(void) { + ESPUI.setVerbosity(Verbosity::VerboseJSON); Serial.begin(115200); #if defined(ESP32) @@ -166,9 +166,9 @@ void setup(void) { Serial.print("\n\nTry to connect to existing network"); { - uint8_t timeout = 5; + uint8_t timeout = 10; - // Wait for connection, 2.5s timeout + // Wait for connection, 5s timeout do { delay(500); Serial.print("."); @@ -227,14 +227,20 @@ void setup(void) { * If you want to serve the files from SPIFFS use ESPUI.beginSPIFFS * (.prepareFileSystem has to be run in an empty sketch before) */ - ESPUI.begin("ESPUI Control"); + + // Enable this option if you want sliders to be continuous (update during move) and not discrete (update on stop) + // ESPUI.sliderContinuous = true; + /* * Optionally you can use HTTP BasicAuth. Keep in mind that this is NOT a * SECURE way of limiting access. * Anyone who is able to sniff traffic will be able to intercept your password - * since it is transmitted in cleartext. Just add a username and password, - * for example begin("ESPUI Control", "username", "password") + * since it is transmitted in cleartext. Just add a string as username and + * password, for example begin("ESPUI Control", "username", "password") */ + + + ESPUI.begin("ESPUI Control"); } void loop(void) { @@ -247,6 +253,7 @@ void loop(void) { ESPUI.updateControlValue(millisLabelId, String(millis())); testSwitchState = !testSwitchState; ESPUI.updateControlValue("Switch one", testSwitchState ? "1" : "0"); + oldTime = millis(); } } diff --git a/examples/gui/gui.ino b/examples/gui/gui.ino index 0071792..50d5db3 100644 --- a/examples/gui/gui.ino +++ b/examples/gui/gui.ino @@ -16,9 +16,6 @@ const char *password = "espui"; const char *hostname = "espui"; -long oldTime = 0; - -bool testSwitchState = false; int statusLabelId; int graphId; int millisLabelId; @@ -217,6 +214,9 @@ void setup(void) { * If you want to serve the files from SPIFFS use ESPUI.beginSPIFFS * (.prepareFileSystem has to be run in an empty sketch before) */ + + // Enable this option if you want sliders to be continuous (update during move) and not discrete (update on stop) + // ESPUI.sliderContinuous = true; /* * Optionally you can use HTTP BasicAuth. Keep in mind that this is NOT a @@ -226,8 +226,6 @@ void setup(void) { * password, for example begin("ESPUI Control", "username", "password") */ - // Enable this option if you want sliders to be continuous (update during move) and not discrete (update on stop) - // ESPUI.sliderContinuous = true; ESPUI.begin("ESPUI Control"); } @@ -235,6 +233,9 @@ void setup(void) { void loop(void) { dnsServer.processNextRequest(); + static long oldTime = 0; + static bool testSwitchState = false; + if (millis() - oldTime > 5000) { ESPUI.print(millisLabelId, String(millis())); @@ -242,7 +243,7 @@ void loop(void) { testSwitchState = !testSwitchState; ESPUI.updateSwitcher(testSwitchId, testSwitchState); - + oldTime = millis(); } } \ No newline at end of file diff --git a/examples/tabbedGui/tabbedGui.ino b/examples/tabbedGui/tabbedGui.ino index a9298f6..423390a 100644 --- a/examples/tabbedGui/tabbedGui.ino +++ b/examples/tabbedGui/tabbedGui.ino @@ -11,12 +11,9 @@ DNSServer dnsServer; #include #endif -// true for verbose, false for quiet -ESPUIClass ESPUI( Verbosity::VerboseJSON ); - const char* ssid = "ESPUI"; const char* password = "espui"; -const char* hostname = "EspuiTest"; +const char* hostname = "espui"; uint16_t button1; @@ -166,9 +163,9 @@ void setup( void ) { Serial.print( "\n\nTry to connect to existing network" ); { - uint8_t timeout = 5; + uint8_t timeout = 10; - // Wait for connection, 2.5s timeout + // Wait for connection, 5s timeout do { delay( 500 ); Serial.print( "." ); @@ -233,14 +230,19 @@ void setup( void ) { * (.prepareFileSystem has to be run in an empty sketch before) */ + // Enable this option if you want sliders to be continuous (update during move) and not discrete (update on stop) + // ESPUI.sliderContinuous = true; + /* * Optionally you can use HTTP BasicAuth. Keep in mind that this is NOT a * SECURE way of limiting access. * Anyone who is able to sniff traffic will be able to intercept your password - * since it is transmitted in cleartext. Just add a username and password, - * for example begin("ESPUI Control", "username", "password") + * since it is transmitted in cleartext. Just add a string as username and + * password, for example begin("ESPUI Control", "username", "password") */ - ESPUI.begin( "ESPUI Control" ); + + + ESPUI.begin("ESPUI Control"); } void loop( void ) { @@ -253,6 +255,7 @@ void loop( void ) { ESPUI.updateControl( "Millis:", String( millis() ) ); switchi = !switchi; ESPUI.updateControl( "Switch one", switchi ? "1" : "0" ); + oldTime = millis(); } }