mirror of
https://github.com/s00500/ESPUI.git
synced 2025-06-14 02:30:41 +00:00
Adding basic structure for new widgets
This commit is contained in:
@ -441,6 +441,17 @@ uint16_t ESPUIClass::number(const char *label, void (*callback)(Control *, int),
|
||||
return numberId;
|
||||
}
|
||||
|
||||
uint16_t ESPUIClass::gauge(const char *label, ControlColor color, int number, int min, int max) {
|
||||
uint16_t numberId = addControl(ControlType::Gauge, label, String(number), color, Control::noParent);
|
||||
addControl(ControlType::Min, label, String(min), ControlColor::None, numberId);
|
||||
addControl(ControlType::Max, label, String(max), ControlColor::None, numberId);
|
||||
return numberId;
|
||||
}
|
||||
|
||||
uint16_t ESPUIClass::accelerometer(const char *label, void (*callback)(Control *, int), ControlColor color) {
|
||||
return addControl(ControlType::Accel, label, "", color, Control::noParent, callback);
|
||||
}
|
||||
|
||||
uint16_t ESPUIClass::text(const char *label, void (*callback)(Control *, int), ControlColor color, String value) {
|
||||
return addControl(ControlType::Text, label, value, color, Control::noParent, callback);
|
||||
}
|
||||
@ -506,13 +517,14 @@ void ESPUIClass::updateControl(Control *control, int clientId) {
|
||||
void ESPUIClass::updateControl(uint16_t id, int clientId) {
|
||||
Control *control = getControl(id);
|
||||
|
||||
if (control) {
|
||||
updateControl(control, clientId);
|
||||
} else {
|
||||
if (!control) {
|
||||
if (this->verbosity) {
|
||||
Serial.println(String("Error: There is no control with ID ") + String(id));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
updateControl(control, clientId);
|
||||
}
|
||||
|
||||
void ESPUIClass::updateControlValue(Control *control, String value, int clientId) {
|
||||
@ -527,13 +539,14 @@ void ESPUIClass::updateControlValue(Control *control, String value, int clientId
|
||||
void ESPUIClass::updateControlValue(uint16_t id, String value, int clientId) {
|
||||
Control *control = getControl(id);
|
||||
|
||||
if (control) {
|
||||
updateControlValue(control, value, clientId);
|
||||
} else {
|
||||
if (!control) {
|
||||
if (this->verbosity) {
|
||||
Serial.println(String("Error: There is no control with ID ") + String(id));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
updateControlValue(control, value, clientId);
|
||||
}
|
||||
|
||||
void ESPUIClass::print(uint16_t id, String value) { updateControlValue(id, value); }
|
||||
@ -550,6 +563,10 @@ void ESPUIClass::updateText(uint16_t id, String text, int clientId) { updateCont
|
||||
|
||||
void ESPUIClass::updateSelect(uint16_t id, String text, int clientId) { updateControlValue(id, text, clientId); }
|
||||
|
||||
void ESPUIClass::updateGauge(uint16_t id, int number, int clientId) { updateControlValue(id, String(number), clientId); }
|
||||
|
||||
void ESPUIClass::clearGraph(uint16_t id, int clientId) {}
|
||||
void ESPUIClass::addGraphPoint(uint16_t id, int nValue, int clientId) {}
|
||||
/*
|
||||
Convert & Transfer Arduino elements to JSON elements
|
||||
Initially this function used to send the control element data individually.
|
||||
|
11
src/ESPUI.h
11
src/ESPUI.h
@ -54,6 +54,8 @@ enum ControlType : uint8_t {
|
||||
Min,
|
||||
Max,
|
||||
Step,
|
||||
Gauge,
|
||||
Accel,
|
||||
|
||||
UpdateOffset = 100,
|
||||
UpdatePad = 101,
|
||||
@ -71,6 +73,8 @@ enum ControlType : uint8_t {
|
||||
UpdateMin,
|
||||
UpdateMax,
|
||||
UpdateStep,
|
||||
UpdateGauge,
|
||||
UpdateAccel,
|
||||
|
||||
InitialGui = 200
|
||||
};
|
||||
@ -188,6 +192,11 @@ public:
|
||||
// Output only
|
||||
uint16_t label(const char *label, ControlColor color, String value = ""); // Create Label
|
||||
uint16_t graph(const char *label, ControlColor color); // Create Graph display
|
||||
uint16_t gauge(const char *label, ControlColor color, int value, int min = 0,
|
||||
int max = 100); // Create Gauge display
|
||||
|
||||
// Input only
|
||||
uint16_t accelerometer(const char *label, void (*callback)(Control *, int), ControlColor color);
|
||||
|
||||
// Update Elements
|
||||
|
||||
@ -207,6 +216,8 @@ public:
|
||||
void updateNumber(uint16_t id, int nValue, int clientId = -1);
|
||||
void updateText(uint16_t id, String nValue, int clientId = -1);
|
||||
void updateSelect(uint16_t id, String nValue, int clientId = -1);
|
||||
void updateGauge(uint16_t id, int number, int clientId);
|
||||
|
||||
void clearGraph(uint16_t id, int clientId = -1);
|
||||
void addGraphPoint(uint16_t id, int nValue, int clientId = -1);
|
||||
|
||||
|
Reference in New Issue
Block a user