mirror of
https://github.com/s00500/ESPUI.git
synced 2024-11-21 22:50:55 +00:00
sync up examples
This commit is contained in:
parent
f00f7601f4
commit
daede8799a
@ -11,16 +11,15 @@ DNSServer dnsServer;
|
|||||||
#include <ESP8266WiFi.h>
|
#include <ESP8266WiFi.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// true for verbose, false for quiet
|
|
||||||
ESPUIClass ESPUI(Verbosity::VerboseJSON);
|
|
||||||
|
|
||||||
const char *ssid = "ESPUI";
|
const char *ssid = "ESPUI";
|
||||||
const char *password = "espui";
|
const char *password = "espui";
|
||||||
const char *hostname = "EspuiTest";
|
const char *hostname = "espui";
|
||||||
|
|
||||||
uint16_t button1;
|
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) {
|
void textCall(Control *sender, int type) {
|
||||||
Serial.print("Text: ID: ");
|
Serial.print("Text: ID: ");
|
||||||
@ -153,6 +152,7 @@ void otherSwitchExample(Control *sender, int value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setup(void) {
|
void setup(void) {
|
||||||
|
ESPUI.setVerbosity(Verbosity::VerboseJSON);
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
|
|
||||||
#if defined(ESP32)
|
#if defined(ESP32)
|
||||||
@ -166,9 +166,9 @@ void setup(void) {
|
|||||||
Serial.print("\n\nTry to connect to existing network");
|
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 {
|
do {
|
||||||
delay(500);
|
delay(500);
|
||||||
Serial.print(".");
|
Serial.print(".");
|
||||||
@ -227,14 +227,20 @@ void setup(void) {
|
|||||||
* If you want to serve the files from SPIFFS use ESPUI.beginSPIFFS
|
* If you want to serve the files from SPIFFS use ESPUI.beginSPIFFS
|
||||||
* (.prepareFileSystem has to be run in an empty sketch before)
|
* (.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
|
* Optionally you can use HTTP BasicAuth. Keep in mind that this is NOT a
|
||||||
* SECURE way of limiting access.
|
* SECURE way of limiting access.
|
||||||
* Anyone who is able to sniff traffic will be able to intercept your password
|
* 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,
|
* since it is transmitted in cleartext. Just add a string as username and
|
||||||
* for example begin("ESPUI Control", "username", "password")
|
* password, for example begin("ESPUI Control", "username", "password")
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
ESPUI.begin("ESPUI Control");
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop(void) {
|
void loop(void) {
|
||||||
@ -247,6 +253,7 @@ void loop(void) {
|
|||||||
ESPUI.updateControlValue(millisLabelId, String(millis()));
|
ESPUI.updateControlValue(millisLabelId, String(millis()));
|
||||||
testSwitchState = !testSwitchState;
|
testSwitchState = !testSwitchState;
|
||||||
ESPUI.updateControlValue("Switch one", testSwitchState ? "1" : "0");
|
ESPUI.updateControlValue("Switch one", testSwitchState ? "1" : "0");
|
||||||
|
|
||||||
oldTime = millis();
|
oldTime = millis();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,9 +16,6 @@ const char *password = "espui";
|
|||||||
|
|
||||||
const char *hostname = "espui";
|
const char *hostname = "espui";
|
||||||
|
|
||||||
long oldTime = 0;
|
|
||||||
|
|
||||||
bool testSwitchState = false;
|
|
||||||
int statusLabelId;
|
int statusLabelId;
|
||||||
int graphId;
|
int graphId;
|
||||||
int millisLabelId;
|
int millisLabelId;
|
||||||
@ -217,6 +214,9 @@ void setup(void) {
|
|||||||
* If you want to serve the files from SPIFFS use ESPUI.beginSPIFFS
|
* If you want to serve the files from SPIFFS use ESPUI.beginSPIFFS
|
||||||
* (.prepareFileSystem has to be run in an empty sketch before)
|
* (.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
|
* 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")
|
* 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");
|
ESPUI.begin("ESPUI Control");
|
||||||
}
|
}
|
||||||
@ -235,6 +233,9 @@ void setup(void) {
|
|||||||
void loop(void) {
|
void loop(void) {
|
||||||
dnsServer.processNextRequest();
|
dnsServer.processNextRequest();
|
||||||
|
|
||||||
|
static long oldTime = 0;
|
||||||
|
static bool testSwitchState = false;
|
||||||
|
|
||||||
if (millis() - oldTime > 5000) {
|
if (millis() - oldTime > 5000) {
|
||||||
ESPUI.print(millisLabelId, String(millis()));
|
ESPUI.print(millisLabelId, String(millis()));
|
||||||
|
|
||||||
@ -242,7 +243,7 @@ void loop(void) {
|
|||||||
|
|
||||||
testSwitchState = !testSwitchState;
|
testSwitchState = !testSwitchState;
|
||||||
ESPUI.updateSwitcher(testSwitchId, testSwitchState);
|
ESPUI.updateSwitcher(testSwitchId, testSwitchState);
|
||||||
|
|
||||||
oldTime = millis();
|
oldTime = millis();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -11,12 +11,9 @@ DNSServer dnsServer;
|
|||||||
#include <ESP8266WiFi.h>
|
#include <ESP8266WiFi.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// true for verbose, false for quiet
|
|
||||||
ESPUIClass ESPUI( Verbosity::VerboseJSON );
|
|
||||||
|
|
||||||
const char* ssid = "ESPUI";
|
const char* ssid = "ESPUI";
|
||||||
const char* password = "espui";
|
const char* password = "espui";
|
||||||
const char* hostname = "EspuiTest";
|
const char* hostname = "espui";
|
||||||
|
|
||||||
uint16_t button1;
|
uint16_t button1;
|
||||||
|
|
||||||
@ -166,9 +163,9 @@ void setup( void ) {
|
|||||||
Serial.print( "\n\nTry to connect to existing network" );
|
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 {
|
do {
|
||||||
delay( 500 );
|
delay( 500 );
|
||||||
Serial.print( "." );
|
Serial.print( "." );
|
||||||
@ -233,14 +230,19 @@ void setup( void ) {
|
|||||||
* (.prepareFileSystem has to be run in an empty sketch before)
|
* (.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
|
* Optionally you can use HTTP BasicAuth. Keep in mind that this is NOT a
|
||||||
* SECURE way of limiting access.
|
* SECURE way of limiting access.
|
||||||
* Anyone who is able to sniff traffic will be able to intercept your password
|
* 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,
|
* since it is transmitted in cleartext. Just add a string as username and
|
||||||
* for example begin("ESPUI Control", "username", "password")
|
* password, for example begin("ESPUI Control", "username", "password")
|
||||||
*/
|
*/
|
||||||
ESPUI.begin( "ESPUI Control" );
|
|
||||||
|
|
||||||
|
ESPUI.begin("ESPUI Control");
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop( void ) {
|
void loop( void ) {
|
||||||
@ -253,6 +255,7 @@ void loop( void ) {
|
|||||||
ESPUI.updateControl( "Millis:", String( millis() ) );
|
ESPUI.updateControl( "Millis:", String( millis() ) );
|
||||||
switchi = !switchi;
|
switchi = !switchi;
|
||||||
ESPUI.updateControl( "Switch one", switchi ? "1" : "0" );
|
ESPUI.updateControl( "Switch one", switchi ? "1" : "0" );
|
||||||
|
|
||||||
oldTime = millis();
|
oldTime = millis();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user