1
0
mirror of https://github.com/s00500/ESPUI.git synced 2024-06-24 11:24:14 +00:00
ESPUI/src/EasyUI.h

65 lines
2.2 KiB
C
Raw Normal View History

2017-05-18 22:05:32 +00:00
#ifndef EasyUI_h
#define EasyUI_h
2017-10-16 13:00:53 +00:00
#define HARDWARE "esp32"
//ifdef 8266
//#include "Hash.h"
2017-05-18 22:05:32 +00:00
#include "Arduino.h"
#include "stdlib_noniso.h"
#include "ArduinoJson.h"
2017-10-16 13:00:53 +00:00
//#include "FS.h"
#include "WiFi.h"
#include <AsyncTCP.h>
#include <ESPAsyncWebServer.h>
2017-05-18 22:05:32 +00:00
class EasyUIClass{
public:
void begin(); // Begin HTTP Server + WebSocketsServer & Initalize All Elements
void title(const char* _title); // Define Webpage Header Name and title
void toggleButton(uint8_t pin, const char* tbutton_label, int start_state = 0, bool swap_state = false); // Create Toggle Button
2017-10-16 13:00:53 +00:00
void button(uint8_t pin, const char* tbutton_label, int start_state = 0, bool swap_state = false); // Create Toggle Button
2017-05-18 22:05:32 +00:00
void label(const char* label_name, const char* label_val); // Create Label
void loop(); // Do All Loop Work
// Variables ---
const char* ui_title = "EasyUI"; // Store UI Title and Header Name
int tb_index; // Calculate How Many Toggle Buttons
int l_index; // Calculate How Many Labels
bool tbutton_swap[10];
uint8_t tbutton_pinout[10]; // Stores GPIO Values - MAX 10
const char* label_value[10]; // Stores Label Values - MAX 10
const char* tbuttontitle[10]; // Stores Toggle Button Titles - MAX 10
const char* label_title[10]; // Stores Label Titles - MAX 10
// const char* variable_type[10]; // un-used feature for now // Stores Label Types, Like 'C' , 'F' or '%' - MAX 10
String webpage; // Coverts Arduino elements to JSON elements
2017-10-16 13:00:53 +00:00
String wsString = ""; // Stores Websockets Script
2017-05-18 22:05:32 +00:00
// Don't Issue the Below functions in your Sketch! - These are Resposible for Webpage functioning.
void tbClick(String _index, String _status);
void tbuttonStatus();
void handleWebpage();
private:
2017-10-16 13:00:53 +00:00
std::unique_ptr<AsyncWebServer> server; // Create Unique Instance for Webserver
std::unique_ptr<AsyncWebSocket> ws; // Create Unique Instance for WebSocketsServer
2017-05-18 22:05:32 +00:00
2017-10-16 13:00:53 +00:00
void handleRoot(AsyncWebServerRequest *request); // Handle MainPage
2017-05-18 22:05:32 +00:00
void handleNotFound(); // Handle Page Not-Found
2017-10-16 13:00:53 +00:00
void handleSockets(AsyncWebServerRequest *request); // Handle Sockets Script
2017-05-18 22:05:32 +00:00
};
extern EasyUIClass EasyUI;
#endif