mirror of
https://github.com/s00500/ESPUI.git
synced 2025-07-04 06:10:18 +00:00
Color feature, and API changes
This commit is contained in:
65
src/ESPUI.h
65
src/ESPUI.h
@ -5,26 +5,26 @@
|
||||
|
||||
#define debug true
|
||||
|
||||
//ifdef 8266
|
||||
// ifdef 8266
|
||||
//#include "Hash.h"
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "stdlib_noniso.h"
|
||||
#include "ArduinoJson.h"
|
||||
#include "FS.h"
|
||||
#include "SPIFFS.h"
|
||||
#include "WiFi.h"
|
||||
#include "stdlib_noniso.h"
|
||||
|
||||
#include <AsyncTCP.h>
|
||||
#include <ESPAsyncWebServer.h>
|
||||
|
||||
typedef struct Control
|
||||
{
|
||||
typedef struct Control {
|
||||
unsigned int type;
|
||||
unsigned int id; // just mirroring the id here for practical reasons
|
||||
const char *label;
|
||||
void (*callback)(Control*, int);
|
||||
void (*callback)(Control, int);
|
||||
String value;
|
||||
unsigned int color;
|
||||
} Control;
|
||||
|
||||
// Types
|
||||
@ -39,7 +39,7 @@ typedef struct Control
|
||||
|
||||
// Values
|
||||
#define B_DOWN -1
|
||||
#define B_UP 1
|
||||
#define B_UP 1
|
||||
|
||||
#define P_LEFT_DOWN -2
|
||||
#define P_LEFT_UP 2
|
||||
@ -55,36 +55,49 @@ typedef struct Control
|
||||
#define S_INACTIVE 7
|
||||
|
||||
|
||||
// Colors
|
||||
#define COLOR_TURQUOISE 0
|
||||
#define COLOR_EMERALD 1
|
||||
#define COLOR_PETERRIVER 2
|
||||
#define COLOR_WETASPHALT 3
|
||||
#define COLOR_SUNFLOWER 4
|
||||
#define COLOR_CARROT 5
|
||||
#define COLOR_ALIZARIN 6
|
||||
|
||||
|
||||
class ESPUIClass {
|
||||
|
||||
public:
|
||||
void begin(const char* _title); // Setup servers and page
|
||||
void begin(const char *_title); // Setup servers and page
|
||||
|
||||
// Creating Elements
|
||||
void label(const char* label, String value = ""); // Create Label
|
||||
void button(const char* label, void (* callBack)(Control*, int), String value = ""); // Create Event Button
|
||||
void switcher(const char* label, bool startState, void (* callBack)(Control*, int)); // Create Toggle Button
|
||||
void pad(const char* label, bool centerButton, void (* callBack)(Control*, int)); // Create Pad Control
|
||||
// Creating Elements
|
||||
void label(const char *label, int color, String value = ""); // Create Label
|
||||
void button(const char *label, void (*callBack)(Control, int), int color,
|
||||
String value = ""); // Create Event Button
|
||||
void switcher(const char *label, bool startState,
|
||||
void (*callBack)(Control, int),
|
||||
int color); // Create Toggle Button
|
||||
void pad(const char *label, bool centerButton, void (*callBack)(Control, int),
|
||||
int color); // Create Pad Control
|
||||
|
||||
// Update Elements
|
||||
void print(int id, String value);
|
||||
void print(String label, String value);
|
||||
// Update Elements
|
||||
void print(int id, String value);
|
||||
void print(String label, String value);
|
||||
|
||||
void updateSwitcher(int id, bool nValue);
|
||||
void updateSwitcher(String label, bool nValue);
|
||||
void updateSwitcher(int id, bool nValue);
|
||||
void updateSwitcher(String label, bool nValue);
|
||||
|
||||
// Variables ---
|
||||
const char* ui_title = "ESPUI"; // Store UI Title and Header Name
|
||||
int cIndex = 0; // Control index
|
||||
Control* controls[25];
|
||||
void jsonDom(AsyncWebSocketClient * client);
|
||||
int getIdByLabel(String label);
|
||||
bool labelExists(String label);
|
||||
// Variables ---
|
||||
const char *ui_title = "ESPUI"; // Store UI Title and Header Name
|
||||
int cIndex = 0; // Control index
|
||||
Control *controls[25];
|
||||
void jsonDom(AsyncWebSocketClient *client);
|
||||
int getIdByLabel(String label);
|
||||
bool labelExists(String label);
|
||||
|
||||
private:
|
||||
AsyncWebServer* server;
|
||||
AsyncWebSocket* ws;
|
||||
AsyncWebServer *server;
|
||||
AsyncWebSocket *ws;
|
||||
};
|
||||
|
||||
extern ESPUIClass ESPUI;
|
||||
|
Reference in New Issue
Block a user