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 22:10:48 +00:00
|
|
|
#include "FS.h"
|
|
|
|
#include "SPIFFS.h"
|
2017-10-16 13:00:53 +00:00
|
|
|
#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
|
|
|
|
// 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
|
|
|
|
|
|
|
void tbClick(String _index, String _status);
|
|
|
|
void tbuttonStatus();
|
2017-10-16 22:10:48 +00:00
|
|
|
void handleWebpage(AsyncWebSocketClient * client);
|
2017-05-18 22:05:32 +00:00
|
|
|
|
|
|
|
private:
|
2017-10-16 22:10:48 +00:00
|
|
|
AsyncWebServer* server; // Create Unique Instance for Webserver
|
|
|
|
AsyncWebSocket* ws;
|
2017-05-18 22:05:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern EasyUIClass EasyUI;
|
|
|
|
#endif
|