1
0
mirror of https://github.com/s00500/ESPUI.git synced 2024-11-25 03:50:54 +00:00

Controls Label in flash and other fixes

This commit is contained in:
Nikola Kirov 2024-01-06 14:10:38 +02:00
parent e5f53d5118
commit 9184ae0e8b
4 changed files with 514 additions and 414 deletions

View File

@ -650,7 +650,16 @@ uint16_t ESPUIClass::addControl(
Control * ctrl = new Control(type, label, nullptr, value, color, true, parentControl); Control * ctrl = new Control(type, label, nullptr, value, color, true, parentControl);
if (auto_update_values && ctrl) if (auto_update_values && ctrl)
ctrl->auto_update_value = true; ctrl->auto_update_value = true;
return addControl(type, label, value, color, parentControl, ctrl); return addControl(ctrl);
}
uint16_t ESPUIClass::addControl(
ControlType type, const __FlashStringHelper* label, const String& value, ControlColor color, uint16_t parentControl)
{
Control* ctrl = new Control(type, label, nullptr, value, color, true, parentControl);
if (auto_update_values && ctrl)
ctrl->auto_update_value = true;
return addControl(ctrl);
} }
uint16_t ESPUIClass::addControl(ControlType type, const char* label, const String& value, ControlColor color, uint16_t ESPUIClass::addControl(ControlType type, const char* label, const String& value, ControlColor color,
@ -662,8 +671,16 @@ uint16_t ESPUIClass::addControl(ControlType type, const char* label, const Strin
return id; return id;
} }
uint16_t ESPUIClass::addControl( uint16_t ESPUIClass::addControl(ControlType type, const __FlashStringHelper* label, const String& value, ControlColor color,
ControlType type, const char* label, const String& value, ControlColor color, uint16_t parentControl, Control* control) uint16_t parentControl, std::function<void(Control*, int)> callback)
{
uint16_t id = addControl(type, label, value, color, parentControl);
// set the original style callback
getControl(id)->callback = callback;
return id;
}
uint16_t ESPUIClass::addControl(Control* control)
{ {
#ifdef ESP32 #ifdef ESP32
xSemaphoreTake(ControlsSemaphore, portMAX_DELAY); xSemaphoreTake(ControlsSemaphore, portMAX_DELAY);
@ -788,6 +805,10 @@ uint16_t ESPUIClass::button(const char* label, std::function<void(Control*, int)
return addControl(ControlType::Button, label, value, color, Control::noParent, callback); return addControl(ControlType::Button, label, value, color, Control::noParent, callback);
} }
uint16_t ESPUIClass::button(const __FlashStringHelper* label, const __FlashStringHelper* text, std::function<void(Control*, int)> callback, uint16_t parentControl, ControlColor color){
return addControl(ControlType::Button, label, text, color, parentControl, callback);
}
uint16_t ESPUIClass::switcher(const char* label, std::function<void(Control*, int)> callback, ControlColor color, bool startState) uint16_t ESPUIClass::switcher(const char* label, std::function<void(Control*, int)> callback, ControlColor color, bool startState)
{ {
return addControl(ControlType::Switcher, label, startState ? "1" : "0", color, Control::noParent, callback); return addControl(ControlType::Switcher, label, startState ? "1" : "0", color, Control::noParent, callback);
@ -1015,7 +1036,25 @@ void ESPUIClass::updateControlLabel(Control* control, const char* value, int cli
#endif #endif
return; return;
} }
control->label = value; control->label_r = value;
control->lablel_is_in_flash = 0;
updateControl(control, clientId);
}
void ESPUIClass::updateControlLabel(Control* control, const __FlashStringHelper* value, int clientId)
{
if (!control)
{
#if defined(DEBUG_ESPUI)
if (verbosity)
{
ESPU_DBGf_P(PSTR("Error: updateControlLabel Control: There is no control with the requested ID \n"));
}
#endif
return;
}
control->label_f = value;
control->lablel_is_in_flash = 1;
updateControl(control, clientId); updateControl(control, clientId);
} }

View File

@ -132,13 +132,18 @@ public:
uint16_t addControl(ControlType type, const char* label, const String& value); uint16_t addControl(ControlType type, const char* label, const String& value);
uint16_t addControl(ControlType type, const char* label, const String& value, ControlColor color); uint16_t addControl(ControlType type, const char* label, const String& value, ControlColor color);
uint16_t addControl(ControlType type, const char* label, const String& value, ControlColor color, uint16_t parentControl); uint16_t addControl(ControlType type, const char* label, const String& value, ControlColor color, uint16_t parentControl);
uint16_t addControl(ControlType type, const __FlashStringHelper* label, const String& value, ControlColor color, uint16_t parentControl);
uint16_t addControl(ControlType type, const char* label, const String& value, ControlColor color, uint16_t parentControl, std::function<void(Control*, int)> callback); uint16_t addControl(ControlType type, const char* label, const String& value, ControlColor color, uint16_t parentControl, std::function<void(Control*, int)> callback);
uint16_t addControl(ControlType type, const __FlashStringHelper * label, const String& value, ControlColor color, uint16_t parentControl, std::function<void(Control*, int)> callback);
bool removeControl(uint16_t id, bool force_rebuild_ui = false); bool removeControl(uint16_t id, bool force_rebuild_ui = false);
// create Elements // create Elements
// Create Event Button // Create Event Button
uint16_t button(const char* label, std::function<void(Control*, int)> callback, ControlColor color, const String& value = ""); uint16_t button(const char* label, std::function<void(Control*, int)> callback, ControlColor color, const String& value = "");
uint16_t button(const __FlashStringHelper* label, const __FlashStringHelper* value,
std::function<void(Control*, int)> callback, uint16_t parentControl = Control::noParent, ControlColor color = ControlColor::Dark);
uint16_t switcher(const char* label, std::function<void(Control*, int)> callback, ControlColor color, bool startState = false); // Create Toggle Button uint16_t switcher(const char* label, std::function<void(Control*, int)> callback, ControlColor color, bool startState = false); // Create Toggle Button
uint16_t pad(const char* label, std::function<void(Control*, int)> callback, ControlColor color); // Create Pad Control uint16_t pad(const char* label, std::function<void(Control*, int)> callback, ControlColor color); // Create Pad Control
uint16_t padWithCenter(const char* label, std::function<void(Control*, int)> callback, ControlColor color); // Create Pad Control with Centerbutton uint16_t padWithCenter(const char* label, std::function<void(Control*, int)> callback, ControlColor color); // Create Pad Control with Centerbutton
@ -168,6 +173,7 @@ public:
void updateControlLabel(uint16_t control, const char * value, int clientId = -1); void updateControlLabel(uint16_t control, const char * value, int clientId = -1);
void updateControlLabel(Control* control, const char * value, int clientId = -1); void updateControlLabel(Control* control, const char * value, int clientId = -1);
void updateControlLabel(Control* control, const __FlashStringHelper* value, int clientId = -1);
void updateControl(uint16_t id, int clientId = -1); void updateControl(uint16_t id, int clientId = -1);
void updateControl(Control* control, int clientId = -1); void updateControl(Control* control, int clientId = -1);
@ -285,7 +291,7 @@ protected:
bool basicAuth = true; bool basicAuth = true;
uint16_t controlCount = 0; uint16_t controlCount = 0;
uint16_t addControl(ControlType type, const char* label, const String& value, ControlColor color, uint16_t parentControl, Control* control); uint16_t addControl(Control* control);
#define ClientUpdateType_t ESPUIclient::ClientUpdateType_t #define ClientUpdateType_t ESPUIclient::ClientUpdateType_t
void NotifyClients(ClientUpdateType_t newState); void NotifyClients(ClientUpdateType_t newState);

View File

@ -1,282 +1,302 @@
#include "ESPUI.h" #include "ESPUI.h"
static uint16_t idCounter = 0; static uint16_t idCounter = 0;
static const String ControlError = "*** ESPUI ERROR: Could not transfer control ***"; static const String ControlError = "*** ESPUI ERROR: Could not transfer control ***";
Control::Control(ControlType type, const char* label, std::function<void(Control*, int)> callback, const String& value, Control::Control(ControlType type, const char* label, std::function<void(Control*, int)> callback, const String& value,
ControlColor color, bool visible, uint16_t parentControl) ControlColor color, bool visible, uint16_t parentControl)
: type(type), : label_r(label),
label(label), callback(callback),
callback(callback), next(nullptr),
value(value), value(value),
color(color), type(type),
visible(visible), color(color),
wide(false), parentControl(parentControl),
vertical(false), options(CTRL_OPT_ENABLED),
enabled(true), ControlChangeID(1)
auto_update_value(false), {
parentControl(parentControl), this->visible = visible;
next(nullptr) id = ++idCounter;
{ }
id = ++idCounter;
ControlChangeID = 1; Control::Control(ControlType type, const __FlashStringHelper* label, std::function<void(Control*, int)> callback,
} const String& value, ControlColor color, bool visible, uint16_t parentControl)
: label_f(label),
Control::Control(const Control& Control) callback(callback),
: type(Control.type), next(nullptr),
id(Control.id), value(value),
label(Control.label), type(type),
callback(Control.callback), color(color),
value(Control.value), parentControl(parentControl),
color(Control.color), options(CTRL_OPT_ENABLED | CTRL_OPT_LABEL_IN_FLASH),
visible(Control.visible), ControlChangeID(1)
parentControl(Control.parentControl), {
next(Control.next), this->visible = visible;
ControlChangeID(Control.ControlChangeID) id = ++idCounter;
{ } }
void Control::SendCallback(int type) Control::Control(const Control& Control)
{ : label_r(Control.label_r),
if(callback) callback(Control.callback),
{ next(Control.next),
callback(this, type); value(Control.value),
} type(Control.type),
} color(Control.color),
id(Control.id),
void Control::DeleteControl() parentControl(Control.parentControl),
{ visible(Control.visible),
_ToBeDeleted = true; ControlChangeID(Control.ControlChangeID)
callback = nullptr; {
} options = Control.options;
if (lablel_is_in_flash)
void Control::MarshalControl(JsonObject & _item, bool refresh, uint32_t StartingOffset) label_f = Control.label_f;
{ }
JsonObject & item = _item;
uint32_t length = value.length(); void Control::SendCallback(int type)
uint32_t maxLength = uint32_t(double(ESPUI.jsonInitialDocumentSize) * 0.75); {
if((length > maxLength) || StartingOffset) if(callback)
{ {
/* callback(this, type);
Serial.println(String("MarshalControl:Start Fragment Processing")); }
Serial.println(String("MarshalControl:id: ") + String(id)); }
Serial.println(String("MarshalControl:length: ") + String(length));
Serial.println(String("MarshalControl:StartingOffset: ") + String(StartingOffset)); void Control::DeleteControl()
Serial.println(String("MarshalControl:maxLength: ") + String(maxLength)); {
_ToBeDeleted = true;
if(0 == StartingOffset) callback = nullptr;
{ }
Serial.println(String("MarshalControl: New control to fragement. ID: ") + String(id));
} void Control::MarshalControl(JsonObject & _item, bool refresh, uint32_t StartingOffset)
else {
{ JsonObject & item = _item;
Serial.println(String("MarshalControl: Next fragement. ID: ") + String(id)); uint32_t length = value.length();
} uint32_t maxLength = uint32_t(double(ESPUI.jsonInitialDocumentSize) * 0.75);
*/ if((length > maxLength) || StartingOffset)
{
// indicate that no additional controls should be sent /*
_item[F("type")] = uint32_t(ControlType::Fragment); Serial.println(String("MarshalControl:Start Fragment Processing"));
_item[F("id")] = id; Serial.println(String("MarshalControl:id: ") + String(id));
Serial.println(String("MarshalControl:length: ") + String(length));
length = min((length - StartingOffset), maxLength); Serial.println(String("MarshalControl:StartingOffset: ") + String(StartingOffset));
// Serial.println(String("MarshalControl:Final length: ") + String(length)); Serial.println(String("MarshalControl:maxLength: ") + String(maxLength));
_item[F("offset")] = StartingOffset; if(0 == StartingOffset)
_item[F("length")] = length; {
_item[F("total")] = value.length(); Serial.println(String("MarshalControl: New control to fragement. ID: ") + String(id));
item = _item.createNestedObject(F("control")); }
} else
{
item[F("id")] = id; Serial.println(String("MarshalControl: Next fragement. ID: ") + String(id));
ControlType TempType = (ControlType::Password == type) ? ControlType::Text : type; }
if(refresh) */
{
item[F("type")] = uint32_t(TempType) + uint32_t(ControlType::UpdateOffset); // indicate that no additional controls should be sent
} _item[F("type")] = uint32_t(ControlType::Fragment);
else _item[F("id")] = id;
{
item[F("type")] = uint32_t(TempType); length = min((length - StartingOffset), maxLength);
} // Serial.println(String("MarshalControl:Final length: ") + String(length));
item[F("label")] = label; _item[F("offset")] = StartingOffset;
item[F ("value")] = (ControlType::Password == type) ? F ("--------") : value.substring(StartingOffset, length + StartingOffset); _item[F("length")] = length;
item[F("visible")] = visible; _item[F("total")] = value.length();
item[F("color")] = (int)color; item = _item.createNestedObject(F("control"));
item[F("enabled")] = enabled; }
if (!panelStyle.isEmpty()) {item[F("panelStyle")] = panelStyle;} item[F("id")] = id;
if (!elementStyle.isEmpty()) {item[F("elementStyle")] = elementStyle;} ControlType TempType = (ControlType::Password == type) ? ControlType::Text : type;
if (!inputType.isEmpty()) {item[F("inputType")] = inputType;} if(refresh)
if (wide == true) {item[F("wide")] = true;} {
if (vertical == true) {item[F("vertical")] = true;} item[F("type")] = uint32_t(TempType) + uint32_t(ControlType::UpdateOffset);
if (parentControl != Control::noParent) }
{ else
item[F("parentControl")] = String(parentControl); {
} item[F("type")] = uint32_t(TempType);
}
// special case for selects: to preselect an option, you have to add
// "selected" to <option> if (lablel_is_in_flash)
if (ControlType::Option == type) item[F("label")] = label_f;
{ else
Control* ParentControl = ESPUI.getControlNoLock(parentControl); item[F("label")] = label_r;
if (nullptr == ParentControl) item[F ("value")] = (ControlType::Password == type) ? F ("--------") : value.substring(StartingOffset, length + StartingOffset);
{ item[F("visible")] = visible;
item[F("selected")] = emptyString; item[F("color")] = (int)color;
} item[F("enabled")] = enabled;
else if (ParentControl->value == value)
{ if (!panelStyle.isEmpty()) {item[F("panelStyle")] = panelStyle;}
item[F("selected")] = F("selected"); if (!elementStyle.isEmpty()) {item[F("elementStyle")] = elementStyle;}
} if (!inputType.isEmpty()) {item[F("inputType")] = inputType;}
else if (wide == true) {item[F("wide")] = true;}
{ if (vertical == true) {item[F("vertical")] = true;}
item[F("selected")] = ""; if (parentControl != Control::noParent)
} {
} item[F("parentControl")] = String(parentControl);
} }
void Control::MarshalErrorMessage(JsonObject & item) // special case for selects: to preselect an option, you have to add
{ // "selected" to <option>
item[F("id")] = id; if (ControlType::Option == type)
item[F("type")] = uint32_t(ControlType::Label); {
item[F("label")] = ControlError.c_str(); Control* ParentControl = ESPUI.getControlNoLock(parentControl);
item[F("value")] = ControlError; if (nullptr == ParentControl)
item[F("visible")] = true; {
item[F("color")] = (int)ControlColor::Carrot; item[F("selected")] = emptyString;
item[F("enabled")] = true; }
else if (ParentControl->value == value)
if (parentControl != Control::noParent) {
{ item[F("selected")] = F("selected");
item[F("parentControl")] = String(parentControl); }
} else
} {
item[F("selected")] = "";
void Control::onWsEvent(String & cmd, String& data) }
{ }
do // once }
{
// Serial.println(String(F("Control::onWsEvent"))); void Control::MarshalErrorMessage(JsonObject & item)
SetControlChangedId(ESPUI.GetNextControlChangeId()); {
item[F("id")] = id;
int arg = 0; item[F("type")] = uint32_t(ControlType::Label);
item[F("label")] = ControlError.c_str();
if (cmd.equals(F("bdown"))) item[F("value")] = ControlError;
{ item[F("visible")] = true;
arg = B_DOWN; item[F("color")] = (int)ControlColor::Carrot;
} item[F("enabled")] = true;
else if (cmd.equals(F("bup")))
{ if (parentControl != Control::noParent)
arg = B_UP; {
} item[F("parentControl")] = String(parentControl);
else if (cmd.equals(F("pfdown"))) }
{ }
arg = P_FOR_DOWN;
} void Control::onWsEvent(String & cmd, String& data)
else if (cmd.equals(F("pfup"))) {
{ do // once
arg = P_FOR_UP; {
} // Serial.println(String(F("Control::onWsEvent")));
else if (cmd.equals(F("pldown"))) SetControlChangedId(ESPUI.GetNextControlChangeId());
{
arg = P_LEFT_DOWN; int arg = 0;
}
else if (cmd.equals(F("plup"))) if (cmd.equals(F("bdown")))
{ {
arg = P_LEFT_UP; arg = B_DOWN;
} }
else if (cmd.equals(F("prdown"))) else if (cmd.equals(F("bup")))
{ {
arg = P_RIGHT_DOWN; arg = B_UP;
} }
else if (cmd.equals(F("prup"))) else if (cmd.equals(F("pfdown")))
{ {
arg = P_RIGHT_UP; arg = P_FOR_DOWN;
} }
else if (cmd.equals(F("pbdown"))) else if (cmd.equals(F("pfup")))
{ {
arg = P_BACK_DOWN; arg = P_FOR_UP;
} }
else if (cmd.equals(F("pbup"))) else if (cmd.equals(F("pldown")))
{ {
arg = P_BACK_UP; arg = P_LEFT_DOWN;
} }
else if (cmd.equals(F("pcdown"))) else if (cmd.equals(F("plup")))
{ {
arg = P_CENTER_DOWN; arg = P_LEFT_UP;
} }
else if (cmd.equals(F("pcup"))) else if (cmd.equals(F("prdown")))
{ {
arg = P_CENTER_UP; arg = P_RIGHT_DOWN;
} }
else if (cmd.equals(F("sactive"))) else if (cmd.equals(F("prup")))
{ {
if (auto_update_value) arg = P_RIGHT_UP;
value = "1"; }
arg = S_ACTIVE; else if (cmd.equals(F("pbdown")))
} {
else if (cmd.equals(F("sinactive"))) arg = P_BACK_DOWN;
{ }
if (auto_update_value) else if (cmd.equals(F("pbup")))
value = "0"; {
arg = S_INACTIVE; arg = P_BACK_UP;
} }
else if (cmd.equals(F("slvalue"))) else if (cmd.equals(F("pcdown")))
{ {
if (auto_update_value) arg = P_CENTER_DOWN;
value = data; }
arg = SL_VALUE; else if (cmd.equals(F("pcup")))
} {
else if (cmd.equals(F("nvalue"))) arg = P_CENTER_UP;
{ }
if (auto_update_value) else if (cmd.equals(F("sactive")))
value = data; {
arg = N_VALUE; if (auto_update_value)
} value = "1";
else if (cmd.equals(F("tvalue"))) arg = S_ACTIVE;
{ }
if (auto_update_value) else if (cmd.equals(F("sinactive")))
value = data; {
arg = T_VALUE; if (auto_update_value)
} value = "0";
else if (cmd.equals(F("tabvalue"))) arg = S_INACTIVE;
{ }
arg = 0; else if (cmd.equals(F("slvalue")))
} {
else if (cmd.equals(F("svalue"))) if (auto_update_value)
{ value = data;
if (auto_update_value) arg = SL_VALUE;
value = data; }
arg = S_VALUE; else if (cmd.equals(F("nvalue")))
} {
else if (cmd.equals(F("time"))) if (auto_update_value)
{ value = data;
if (auto_update_value) arg = N_VALUE;
value = data; }
arg = TM_VALUE; else if (cmd.equals(F("tvalue")))
} {
else if (auto_update_value)
{ value = data;
#if defined(DEBUG_ESPUI) arg = T_VALUE;
if (ESPUI.verbosity) }
{ else if (cmd.equals(F("tabvalue")))
Serial.println(F("Control::onWsEvent:Malformed message from the websocket")); {
} arg = 0;
#endif }
break; else if (cmd.equals(F("svalue")))
} {
if (auto_update_value)
if (!HasCallback()) value = data;
{ arg = S_VALUE;
#if defined(DEBUG_ESPUI) }
if (ESPUI.verbosity) else if (cmd.equals(F("time")))
{ {
Serial.println(String(F("Control::onWsEvent:No callback found for ID ")) + String(id)); if (auto_update_value)
} value = data;
#endif arg = TM_VALUE;
} }
else else
{ {
// Serial.println("Control::onWsEvent:Generating callback"); #if defined(DEBUG_ESPUI)
SendCallback(arg); if (ESPUI.verbosity)
} {
Serial.println(F("Control::onWsEvent:Malformed message from the websocket"));
} while (false); }
} #endif
break;
}
if (!HasCallback())
{
#if defined(DEBUG_ESPUI)
if (ESPUI.verbosity)
{
Serial.println(String(F("Control::onWsEvent:No callback found for ID ")) + String(id));
}
#endif
}
else
{
// Serial.println("Control::onWsEvent:Generating callback");
SendCallback(arg);
}
} while (false);
}

View File

@ -1,127 +1,162 @@
#pragma once #pragma once
#include <Arduino.h> #include <Arduino.h>
#include <ArduinoJson.h> #include <ArduinoJson.h>
#include <functional> #include <functional>
enum ControlType : uint8_t enum ControlType : uint8_t
{ {
// fixed Controls // fixed Controls
Title = 0, Title = 0,
// updatable Controls // updatable Controls
Pad, Pad,
PadWithCenter, PadWithCenter,
Button, Button,
Label, Label,
Switcher, Switcher,
Slider, Slider,
Number, Number,
Text, Text,
Graph, Graph,
GraphPoint, GraphPoint,
Tab, Tab,
Select, Select,
Option, Option,
Min, Min,
Max, Max,
Step, Step,
Gauge, Gauge,
Accel, Accel,
Separator, Separator,
Time, Time,
Fragment, Fragment,
Password = 99, Password = 99,
UpdateOffset = 100, UpdateOffset = 100,
}; };
enum ControlColor : uint8_t enum ControlColor : uint8_t
{ {
Turquoise, Turquoise,
Emerald, Emerald,
Peterriver, Peterriver,
Wetasphalt, Wetasphalt,
Sunflower, Sunflower,
Carrot, Carrot,
Alizarin, Alizarin,
Dark, Dark,
None = 0xFF None = 0xFF
}; };
class Control #define CTRL_OPT_ENABLED 0x01
{ #define CTRL_OPT_VISIBLE 0x02
public: #define CTRL_OPT_LABEL_IN_FLASH 0x04
ControlType type; #define CTRL_OPT_AUTO_UPDATE_VALUE 0x08
uint16_t id; // just mirroring the id here for practical reasons #define CTRL_OPT_WIDE 0x10
const char* label; #define CTRL_OPT_VERTICAL 0x20
std::function<void(Control*, int)> callback;
String value; class Control
ControlColor color; {
bool visible; public:
bool wide; static constexpr uint16_t noParent = 0xffff;
bool vertical;
bool enabled; // Pointers
bool auto_update_value; union
uint16_t parentControl; {
String panelStyle; const char* label_r;
String elementStyle; const __FlashStringHelper* label_f;
String inputType; };
Control* next; std::function<void(Control*, int)> callback;
Control* next;
static constexpr uint16_t noParent = 0xffff;
// Strings
Control(ControlType type, String value;
const char* label, String panelStyle;
std::function<void(Control*, int)> callback, String elementStyle;
const String& value, String inputType;
ControlColor color,
bool visible, //enums
uint16_t parentControl); ControlType type;
ControlColor color;
Control(const Control& Control);
// uint16_t
void SendCallback(int type); uint16_t id; // just mirroring the id here for practical reasons
bool HasCallback() { return (nullptr != callback); } uint16_t parentControl;
void MarshalControl(ArduinoJson::JsonObject& item, bool refresh, uint32_t DataOffset);
void MarshalErrorMessage(ArduinoJson::JsonObject& item); union
void DeleteControl(); {
void onWsEvent(String& cmd, String& data); struct
inline bool ToBeDeleted() { return _ToBeDeleted; } {
inline bool NeedsSync(uint32_t lastControlChangeID) {return (false == _ToBeDeleted) && (lastControlChangeID < ControlChangeID);} uint16_t enabled : 1 ;
void SetControlChangedId(uint32_t value) {ControlChangeID = value;} uint16_t visible : 1;
uint16_t lablel_is_in_flash : 1;
private: uint16_t auto_update_value : 1;
bool _ToBeDeleted = false; uint16_t wide : 1;
uint32_t ControlChangeID = 0; uint16_t vertical : 1;
}; };
uint16_t options;
#define UI_TITLE ControlType::Title };
#define UI_LABEL ControlType::Label
#define UI_BUTTON ControlType::Button Control(ControlType type,
#define UI_SWITCHER ControlType::Switcher const char* label,
#define UI_PAD ControlType::Pad std::function<void(Control*, int)> callback,
#define UI_CPAD ControlType::Cpad const String& value,
#define UI_SLIDER ControlType::Slider ControlColor color,
#define UI_NUMBER ControlType::Number bool visible,
#define UI_TEXT_INPUT ControlType::Text uint16_t parentControl);
#define UI_GRAPH ControlType::Graph
#define UI_ADD_GRAPH_POINT ControlType::GraphPoint Control(ControlType type,
const __FlashStringHelper* label,
#define UPDATE_LABEL ControlType::UpdateLabel std::function<void(Control*, int)> callback,
#define UPDATE_SWITCHER ControlType::UpdateSwitcher const String& value,
#define UPDATE_SLIDER ControlType::UpdateSlider ControlColor color,
#define UPDATE_NUMBER ControlType::UpdateNumber bool visible,
#define UPDATE_TEXT_INPUT ControlType::UpdateText uint16_t parentControl);
#define CLEAR_GRAPH ControlType::ClearGraph
Control(const Control& Control);
// Colors
#define COLOR_TURQUOISE ControlColor::Turquoise void SendCallback(int type);
#define COLOR_EMERALD ControlColor::Emerald bool HasCallback() { return (nullptr != callback); }
#define COLOR_PETERRIVER ControlColor::Peterriver void MarshalControl(ArduinoJson::JsonObject& item, bool refresh, uint32_t DataOffset);
#define COLOR_WETASPHALT ControlColor::Wetasphalt void MarshalErrorMessage(ArduinoJson::JsonObject& item);
#define COLOR_SUNFLOWER ControlColor::Sunflower void DeleteControl();
#define COLOR_CARROT ControlColor::Carrot void onWsEvent(String& cmd, String& data);
#define COLOR_ALIZARIN ControlColor::Alizarin inline bool ToBeDeleted() { return _ToBeDeleted; }
#define COLOR_DARK ControlColor::Dark inline bool NeedsSync(uint32_t lastControlChangeID) {return (false == _ToBeDeleted) && (lastControlChangeID < ControlChangeID);}
#define COLOR_NONE ControlColor::None void SetControlChangedId(uint32_t value) {ControlChangeID = value;}
private:
bool _ToBeDeleted = false;
uint32_t ControlChangeID;
};
#define UI_TITLE ControlType::Title
#define UI_LABEL ControlType::Label
#define UI_BUTTON ControlType::Button
#define UI_SWITCHER ControlType::Switcher
#define UI_PAD ControlType::Pad
#define UI_CPAD ControlType::Cpad
#define UI_SLIDER ControlType::Slider
#define UI_NUMBER ControlType::Number
#define UI_TEXT_INPUT ControlType::Text
#define UI_GRAPH ControlType::Graph
#define UI_ADD_GRAPH_POINT ControlType::GraphPoint
#define UPDATE_LABEL ControlType::UpdateLabel
#define UPDATE_SWITCHER ControlType::UpdateSwitcher
#define UPDATE_SLIDER ControlType::UpdateSlider
#define UPDATE_NUMBER ControlType::UpdateNumber
#define UPDATE_TEXT_INPUT ControlType::UpdateText
#define CLEAR_GRAPH ControlType::ClearGraph
// Colors
#define COLOR_TURQUOISE ControlColor::Turquoise
#define COLOR_EMERALD ControlColor::Emerald
#define COLOR_PETERRIVER ControlColor::Peterriver
#define COLOR_WETASPHALT ControlColor::Wetasphalt
#define COLOR_SUNFLOWER ControlColor::Sunflower
#define COLOR_CARROT ControlColor::Carrot
#define COLOR_ALIZARIN ControlColor::Alizarin
#define COLOR_DARK ControlColor::Dark
#define COLOR_NONE ControlColor::None