Refactor Settings usage
This commit is contained in:
@@ -1240,7 +1240,7 @@ void CrossPointWebServer::handleGetSettings() const {
|
||||
if (s.valuePtr) {
|
||||
doc["value"] = static_cast<int>(SETTINGS.*(s.valuePtr));
|
||||
} else if (s.valueGetter) {
|
||||
doc["value"] = static_cast<int>(s.valueGetter());
|
||||
doc["value"] = static_cast<int>(s.callValueGetter());
|
||||
}
|
||||
JsonArray options = doc["options"].to<JsonArray>();
|
||||
for (const auto& opt : s.enumValues) {
|
||||
@@ -1261,7 +1261,7 @@ void CrossPointWebServer::handleGetSettings() const {
|
||||
case SettingType::STRING: {
|
||||
doc["type"] = "string";
|
||||
if (s.stringGetter) {
|
||||
doc["value"] = s.stringGetter();
|
||||
doc["value"] = s.callStringGetter();
|
||||
} else if (s.stringMaxLen > 0) {
|
||||
doc["value"] = reinterpret_cast<const char*>(&SETTINGS) + s.stringOffset;
|
||||
}
|
||||
@@ -1326,7 +1326,7 @@ void CrossPointWebServer::handlePostSettings() {
|
||||
if (s.valuePtr) {
|
||||
SETTINGS.*(s.valuePtr) = static_cast<uint8_t>(val);
|
||||
} else if (s.valueSetter) {
|
||||
s.valueSetter(static_cast<uint8_t>(val));
|
||||
s.callValueSetter(static_cast<uint8_t>(val));
|
||||
}
|
||||
applied++;
|
||||
}
|
||||
@@ -1345,7 +1345,7 @@ void CrossPointWebServer::handlePostSettings() {
|
||||
case SettingType::STRING: {
|
||||
const std::string val = doc[s.key].as<std::string>();
|
||||
if (s.stringSetter) {
|
||||
s.stringSetter(val);
|
||||
s.callStringSetter(val);
|
||||
} else if (s.stringMaxLen > 0) {
|
||||
char* ptr = reinterpret_cast<char*>(&SETTINGS) + s.stringOffset;
|
||||
strncpy(ptr, val.c_str(), s.stringMaxLen - 1);
|
||||
|
||||
Reference in New Issue
Block a user