1
0
mirror of https://github.com/s00500/ESPUI.git synced 2024-06-30 16:24:13 +00:00

Updating example

This commit is contained in:
Lukas Bachschwell 2017-11-13 16:11:42 +01:00
parent 0dc231bc9c
commit 3c26def22a

View File

@ -5,6 +5,7 @@ const char* ssid = "ESP32";
const char* password = ""; const char* password = "";
long oldTime = 0; long oldTime = 0;
bool switchi = false;
void setup(void) { void setup(void) {
Serial.begin(115200); Serial.begin(115200);
@ -31,12 +32,12 @@ void setup(void) {
Serial.println(WiFi.localIP()); Serial.println(WiFi.localIP());
*/ */
ESPUI.label("Status: Stop"); ESPUI.label("Status:", "Stop");
ESPUI.label("0"); ESPUI.label("Millis:","0");
ESPUI.button("Push Button", &buttonCallback); ESPUI.button("Push Button", &buttonCallback);
ESPUI.button("Push Button", &buttonExample); ESPUI.button("Push Button", &buttonExample);
ESPUI.pad("center", true, &padExample); ESPUI.pad("Pad with center", true, &padExample);
ESPUI.pad("NoCenter", false, &padExample); ESPUI.pad("Pad without center", false, &padExample);
ESPUI.switcher("Switch one", false, &switchExample); ESPUI.switcher("Switch one", false, &switchExample);
ESPUI.switcher("Switch two", true, &otherSwitchExample); ESPUI.switcher("Switch two", true, &otherSwitchExample);
@ -46,12 +47,14 @@ void setup(void) {
void loop(void) { void loop(void) {
if (millis() - oldTime > 5000) { if (millis() - oldTime > 5000) {
ESPUI.print(1, String(millis())); ESPUI.print("Millis:", String(millis()));
switchi = !switchi;
ESPUI.updateSwitcher("Switch one", switchi);
oldTime = millis(); oldTime = millis();
} }
} }
void buttonCallback(int id, int type) { void buttonCallback(Control* sender, int type) {
switch (type) { switch (type) {
case B_DOWN: case B_DOWN:
Serial.println("Button DOWN"); Serial.println("Button DOWN");
@ -63,7 +66,7 @@ void buttonCallback(int id, int type) {
} }
void buttonExample(int id, int type) { void buttonExample(Control* sender, int type) {
switch (type) { switch (type) {
case B_DOWN: case B_DOWN:
Serial.println("Status: Start"); Serial.println("Status: Start");
@ -75,7 +78,7 @@ void buttonExample(int id, int type) {
break; break;
} }
} }
void padExample(int id, int value) { void padExample(Control* sender, int value) {
switch (value) { switch (value) {
case P_LEFT_DOWN: case P_LEFT_DOWN:
Serial.print("left down"); Serial.print("left down");
@ -109,10 +112,10 @@ void padExample(int id, int value) {
break; break;
} }
Serial.print(" "); Serial.print(" ");
Serial.println(id); Serial.println(sender->id);
} }
void switchExample(int id, int value) { void switchExample(Control* sender, int value) {
switch (value) { switch (value) {
case S_ACTIVE: case S_ACTIVE:
Serial.print("Active:"); Serial.print("Active:");
@ -122,10 +125,10 @@ void switchExample(int id, int value) {
break; break;
} }
Serial.print(" "); Serial.print(" ");
Serial.println(id); Serial.println(sender->id);
} }
void otherSwitchExample(int id, int value) { void otherSwitchExample(Control* sender, int value) {
switch (value) { switch (value) {
case S_ACTIVE: case S_ACTIVE:
Serial.print("Active:"); Serial.print("Active:");
@ -135,5 +138,5 @@ void otherSwitchExample(int id, int value) {
break; break;
} }
Serial.print(" "); Serial.print(" ");
Serial.println(id); Serial.println(sender->id);
} }