1
0
mirror of https://github.com/s00500/ESPUI.git synced 2024-12-22 19:30:50 +00:00

sync up examples

This commit is contained in:
Lukas Bachschwell 2019-12-28 21:30:57 +01:00
parent f00f7601f4
commit daede8799a
Signed by: lbsadmin
GPG Key ID: CCC6AA87CC8DF425
3 changed files with 36 additions and 25 deletions

View File

@ -11,16 +11,15 @@ DNSServer dnsServer;
#include <ESP8266WiFi.h>
#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();
}
}

View File

@ -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();
}
}

View File

@ -11,12 +11,9 @@ DNSServer dnsServer;
#include <ESP8266WiFi.h>
#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();
}
}