mirror of
https://github.com/bdring/Grbl_Esp32.git
synced 2025-08-29 09:10:03 +02:00
Fixed WebUI settings problems - floats and sets.
This commit is contained in:
@@ -89,8 +89,11 @@ namespace Configuration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void JsonGenerator::item(const char* name, float& value, float minValue, float maxValue) {
|
void JsonGenerator::item(const char* name, float& value, float minValue, float maxValue) {
|
||||||
int n = int(value * 1000);
|
enter(name);
|
||||||
item(name, n, int(minValue * 1000), int(maxValue * 1000));
|
// WebUI does not explicitly recognize the R type, but nevertheless handles it correctly.
|
||||||
|
_encoder.begin_webui(name, _currentPath, "R", String(value, 3).c_str());
|
||||||
|
_encoder.end_object();
|
||||||
|
leave();
|
||||||
}
|
}
|
||||||
|
|
||||||
void JsonGenerator::item(const char* name, std::vector<speedEntry>& value) {}
|
void JsonGenerator::item(const char* name, std::vector<speedEntry>& value) {}
|
||||||
|
@@ -24,8 +24,10 @@
|
|||||||
#include <atomic>
|
#include <atomic>
|
||||||
|
|
||||||
namespace Configuration {
|
namespace Configuration {
|
||||||
RuntimeSetting::RuntimeSetting(const char* key, const char* value, WebUI::ESPResponseStream* out) :
|
RuntimeSetting::RuntimeSetting(const char* key, const char* value, WebUI::ESPResponseStream* out) : newValue_(value), out_(out) {
|
||||||
setting_(key), start_(key), newValue_(value), out_(out) {
|
// Remove leading '/' if it is present
|
||||||
|
setting_ = (*key == '/') ? key + 1 : key;
|
||||||
|
start_ = setting_;
|
||||||
// Read fence for config. Shouldn't be necessary, but better safe than sorry.
|
// Read fence for config. Shouldn't be necessary, but better safe than sorry.
|
||||||
std::atomic_thread_fence(std::memory_order::memory_order_seq_cst);
|
std::atomic_thread_fence(std::memory_order::memory_order_seq_cst);
|
||||||
}
|
}
|
||||||
|
@@ -144,25 +144,27 @@ namespace WebUI {
|
|||||||
|
|
||||||
// Creates an Esp32_WebUI configuration item specification from
|
// Creates an Esp32_WebUI configuration item specification from
|
||||||
// a value passed in as a C-style string.
|
// a value passed in as a C-style string.
|
||||||
void JSONencoder::begin_webui(const char* p, const char* help, const char* type, const char* val) {
|
void JSONencoder::begin_webui(const char* brief, const char* full, const char* type, const char* val) {
|
||||||
begin_object();
|
begin_object();
|
||||||
member("F", "network");
|
member("F", "network");
|
||||||
member("P", p);
|
// We must pass the full path as the P parameter because that is
|
||||||
member("H", help);
|
// what WebUI sends back to us when setting a new value.
|
||||||
|
member("P", full);
|
||||||
|
member("H", full);
|
||||||
member("T", type);
|
member("T", type);
|
||||||
member("V", val);
|
member("V", val);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Creates an Esp32_WebUI configuration item specification from
|
// Creates an Esp32_WebUI configuration item specification from
|
||||||
// an integer value.
|
// an integer value.
|
||||||
void JSONencoder::begin_webui(const char* p, const char* help, const char* type, int val) {
|
void JSONencoder::begin_webui(const char* brief, const char* full, const char* type, int val) {
|
||||||
begin_webui(p, help, type, String(val).c_str());
|
begin_webui(brief, full, type, String(val).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Creates an Esp32_WebUI configuration item specification from
|
// Creates an Esp32_WebUI configuration item specification from
|
||||||
// a C-style string value, with additional min and max arguments.
|
// a C-style string value, with additional min and max arguments.
|
||||||
void JSONencoder::begin_webui(const char* p, const char* help, const char* type, const char* val, int min, int max) {
|
void JSONencoder::begin_webui(const char* brief, const char* full, const char* type, const char* val, int min, int max) {
|
||||||
begin_webui(p, help, type, val);
|
begin_webui(brief, full, type, val);
|
||||||
member("S", max);
|
member("S", max);
|
||||||
member("M", min);
|
member("M", min);
|
||||||
}
|
}
|
||||||
|
@@ -83,8 +83,8 @@ namespace WebUI {
|
|||||||
// S => 0 .. 255
|
// S => 0 .. 255
|
||||||
// A => 7 .. 15 (0.0.0.0 .. 255.255.255.255)
|
// A => 7 .. 15 (0.0.0.0 .. 255.255.255.255)
|
||||||
// I => 0 .. 2^31-1
|
// I => 0 .. 2^31-1
|
||||||
void begin_webui(const char* p, const char* help, const char* type, const char* val);
|
void begin_webui(const char* brief, const char* full, const char* type, const char* val);
|
||||||
void begin_webui(const char* p, const char* help, const char* type, const int val);
|
void begin_webui(const char* brief, const char* full, const char* type, const int val);
|
||||||
void begin_webui(const char* p, const char* help, const char* type, const char* val, int min, int max);
|
void begin_webui(const char* brief, const char* full, const char* type, const char* val, int min, int max);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user