1
0
mirror of https://github.com/bdring/Grbl_Esp32.git synced 2025-08-29 01:00:00 +02:00

Fixed WebUI settings problems - floats and sets.

This commit is contained in:
Mitch Bradley
2021-08-01 10:23:37 -10:00
parent 0963be0433
commit 44d0c3eca0
4 changed files with 21 additions and 14 deletions

View File

@@ -89,8 +89,11 @@ namespace Configuration {
}
void JsonGenerator::item(const char* name, float& value, float minValue, float maxValue) {
int n = int(value * 1000);
item(name, n, int(minValue * 1000), int(maxValue * 1000));
enter(name);
// 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) {}

View File

@@ -24,8 +24,10 @@
#include <atomic>
namespace Configuration {
RuntimeSetting::RuntimeSetting(const char* key, const char* value, WebUI::ESPResponseStream* out) :
setting_(key), start_(key), newValue_(value), out_(out) {
RuntimeSetting::RuntimeSetting(const char* key, const char* value, WebUI::ESPResponseStream* out) : 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.
std::atomic_thread_fence(std::memory_order::memory_order_seq_cst);
}

View File

@@ -144,25 +144,27 @@ namespace WebUI {
// Creates an Esp32_WebUI configuration item specification from
// 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();
member("F", "network");
member("P", p);
member("H", help);
// We must pass the full path as the P parameter because that is
// what WebUI sends back to us when setting a new value.
member("P", full);
member("H", full);
member("T", type);
member("V", val);
}
// Creates an Esp32_WebUI configuration item specification from
// an integer value.
void JSONencoder::begin_webui(const char* p, const char* help, const char* type, int val) {
begin_webui(p, help, type, String(val).c_str());
void JSONencoder::begin_webui(const char* brief, const char* full, const char* type, int val) {
begin_webui(brief, full, type, String(val).c_str());
}
// Creates an Esp32_WebUI configuration item specification from
// 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) {
begin_webui(p, help, type, val);
void JSONencoder::begin_webui(const char* brief, const char* full, const char* type, const char* val, int min, int max) {
begin_webui(brief, full, type, val);
member("S", max);
member("M", min);
}

View File

@@ -83,8 +83,8 @@ namespace WebUI {
// S => 0 .. 255
// A => 7 .. 15 (0.0.0.0 .. 255.255.255.255)
// 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* p, const char* help, 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);
void begin_webui(const char* brief, const char* full, const char* type, const int val);
void begin_webui(const char* brief, const char* full, const char* type, const char* val, int min, int max);
};
}