mirror of
https://github.com/s00500/ESPUI.git
synced 2024-11-22 04:00:55 +00:00
Update examples
This commit is contained in:
parent
a8ce83df64
commit
4043274aff
@ -1,36 +0,0 @@
|
|||||||
/*
|
|
||||||
* Author: Ayush Sharma (ayushsharma82) Github
|
|
||||||
* Library: EasyUI
|
|
||||||
* - This is a Test Code of EasyUI Library
|
|
||||||
* - It Will Use the OnBoard LED of ESP8266 and toggle it.
|
|
||||||
*/
|
|
||||||
#include <ESP8266WiFi.h>
|
|
||||||
#include <WiFiClient.h>
|
|
||||||
#include <EasyUI.h>
|
|
||||||
|
|
||||||
const char* ssid = ".........";
|
|
||||||
const char* password = "..........";
|
|
||||||
|
|
||||||
void setup(void) {
|
|
||||||
Serial.begin(115200);
|
|
||||||
WiFi.begin(ssid, password);
|
|
||||||
Serial.println("");
|
|
||||||
// Wait for connection
|
|
||||||
while (WiFi.status() != WL_CONNECTED) {
|
|
||||||
delay(500);
|
|
||||||
Serial.print(".");
|
|
||||||
}
|
|
||||||
Serial.println("");
|
|
||||||
Serial.print("IP address: ");
|
|
||||||
Serial.println(WiFi.localIP());
|
|
||||||
|
|
||||||
// Detects Internet Connectivity and Switches to Online CDN. (For STA Mode Only)
|
|
||||||
EasyUI.detectCDN(true);
|
|
||||||
EasyUI.label("Label","123");
|
|
||||||
EasyUI.toggleButton(2, "LED", HIGH, true); // LED Toggle Button
|
|
||||||
EasyUI.begin();
|
|
||||||
}
|
|
||||||
|
|
||||||
void loop(void) {
|
|
||||||
EasyUI.loop();
|
|
||||||
}
|
|
@ -1,7 +1,7 @@
|
|||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
#include <EasyUI.h>
|
#include <EasyUI.h>
|
||||||
|
|
||||||
const char* ssid = "LARSUI";
|
const char* ssid = "ESP32";
|
||||||
const char* password = "";
|
const char* password = "";
|
||||||
|
|
||||||
long oldTime = 0;
|
long oldTime = 0;
|
||||||
@ -16,21 +16,38 @@ void setup(void) {
|
|||||||
Serial.print("IP address: ");
|
Serial.print("IP address: ");
|
||||||
Serial.println(WiFi.softAPIP());
|
Serial.println(WiFi.softAPIP());
|
||||||
|
|
||||||
EasyUI.label("Status: Maxim Stop");
|
// change the beginning to this if you want to join an existing network
|
||||||
EasyUI.label("0");
|
/*
|
||||||
EasyUI.button("MaximDance Button", &callback2);
|
Serial.begin(115200);
|
||||||
EasyUI.pad("center", true, &callback3);
|
WiFi.begin(ssid, password);
|
||||||
EasyUI.pad("NoCenter", false, &callback3);
|
Serial.println("");
|
||||||
|
// Wait for connection
|
||||||
|
while (WiFi.status() != WL_CONNECTED) {
|
||||||
|
delay(500);
|
||||||
|
Serial.print(".");
|
||||||
|
}
|
||||||
|
Serial.println("");
|
||||||
|
Serial.print("IP address: ");
|
||||||
|
Serial.println(WiFi.localIP());
|
||||||
|
*/
|
||||||
|
|
||||||
EasyUI.begin("LARS Control");
|
EasyUI.label("Status: Stop");
|
||||||
|
EasyUI.label("0");
|
||||||
|
EasyUI.button("Push Button", &buttonExample);
|
||||||
|
EasyUI.pad("center", true, &padExample);
|
||||||
|
EasyUI.pad("NoCenter", false, &padExample);
|
||||||
|
EasyUI.switcher("Switch one", false, &switchExample);
|
||||||
|
EasyUI.switcher("Switch two", true, &otherSwitchExample);
|
||||||
|
|
||||||
|
EasyUI.begin("ESP32 Control");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop(void) {
|
void loop(void) {
|
||||||
if(millis()-oldTime> 5000){
|
if (millis() - oldTime > 5000) {
|
||||||
EasyUI.print(1, String(millis()));
|
EasyUI.print(1, String(millis()));
|
||||||
oldTime = millis();
|
oldTime = millis();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void callback1(int id, int type) {
|
void callback1(int id, int type) {
|
||||||
@ -45,50 +62,77 @@ void callback1(int id, int type) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void callback2(int id, int type) {
|
void buttonExample(int id, int type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case B_DOWN:
|
case B_DOWN:
|
||||||
Serial.println("Maxim Start DAnce######################");
|
Serial.println("Status: Start");
|
||||||
EasyUI.print(0, "Status: Maxim Start");
|
EasyUI.print(0, "Status: Start");
|
||||||
break;
|
break;
|
||||||
case B_UP:
|
case B_UP:
|
||||||
Serial.println("Maxim STOP DAnce######################");
|
Serial.println("Status: Stop");
|
||||||
EasyUI.print(0, "Status: Maxim Start");
|
EasyUI.print(0, "Status: Stop");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void callback3(int id, int value) {
|
void padExample(int id, int value) {
|
||||||
switch (value) {
|
switch (value) {
|
||||||
case P_LEFT_DOWN:
|
case P_LEFT_DOWN:
|
||||||
Serial.println("left down");
|
Serial.print("left down");
|
||||||
break;
|
break;
|
||||||
case P_LEFT_UP:
|
case P_LEFT_UP:
|
||||||
Serial.println("left up");
|
Serial.print("left up");
|
||||||
break;
|
break;
|
||||||
case P_RIGHT_DOWN:
|
case P_RIGHT_DOWN:
|
||||||
Serial.println("right down");
|
Serial.print("right down");
|
||||||
break;
|
break;
|
||||||
case P_RIGHT_UP:
|
case P_RIGHT_UP:
|
||||||
Serial.println("right up");
|
Serial.print("right up");
|
||||||
break;
|
break;
|
||||||
case P_FOR_DOWN:
|
case P_FOR_DOWN:
|
||||||
Serial.println("for down");
|
Serial.print("for down");
|
||||||
break;
|
break;
|
||||||
case P_FOR_UP:
|
case P_FOR_UP:
|
||||||
Serial.println("for up");
|
Serial.print("for up");
|
||||||
break;
|
break;
|
||||||
case P_BACK_DOWN:
|
case P_BACK_DOWN:
|
||||||
Serial.println("back down");
|
Serial.print("back down");
|
||||||
break;
|
break;
|
||||||
case P_BACK_UP:
|
case P_BACK_UP:
|
||||||
Serial.println("back up");
|
Serial.print("back up");
|
||||||
break;
|
break;
|
||||||
case P_CENTER_DOWN:
|
case P_CENTER_DOWN:
|
||||||
Serial.println("center down");
|
Serial.print("center down");
|
||||||
break;
|
break;
|
||||||
case P_CENTER_UP:
|
case P_CENTER_UP:
|
||||||
Serial.println("center up");
|
Serial.print("center up");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Serial.print(" ");
|
||||||
|
Serial.println(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
void switchExample(int id, int value) {
|
||||||
|
switch (value) {
|
||||||
|
case S_ACTIVE:
|
||||||
|
Serial.print("Active:");
|
||||||
|
break;
|
||||||
|
case S_INACTIVE:
|
||||||
|
Serial.print("Inactive");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Serial.print(" ");
|
||||||
|
Serial.println(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
void otherSwitchExample(int id, int value) {
|
||||||
|
switch (value) {
|
||||||
|
case S_ACTIVE:
|
||||||
|
Serial.print("Active:");
|
||||||
|
break;
|
||||||
|
case S_INACTIVE:
|
||||||
|
Serial.print("Inactive");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Serial.print(" ");
|
||||||
Serial.println(id);
|
Serial.println(id);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user