Add configSet for lv_color_t variables

This commit is contained in:
fvanroie 2022-04-12 02:24:24 +02:00
parent b073983275
commit a3f2890ea0

View File

@ -85,7 +85,19 @@ bool configSet(uint16_t& value, const JsonVariant& setting, const __FlashStringH
}
return false;
}
bool configSet(lv_color_t& value, const JsonVariant& setting, const __FlashStringHelper* fstr_name)
{
lv_color32_t c32;
if(!setting.isNull() && Parser::haspPayloadToColor(setting.as<const char*>(), c32)) {
lv_color_t val = lv_color_make(c32.ch.red, c32.ch.green, c32.ch.blue);
if(value.full != val.full) {
confDebugSet(fstr_name);
value = val;
return true;
}
}
return false;
}
void configSetupDebug(JsonDocument& settings)
{
debugSetup(settings[FPSTR(FP_DEBUG)]);
@ -199,7 +211,8 @@ DeserializationError configRead(JsonDocument& settings, bool setupdebug = false)
#if HASP_USE_CONFIG > 0 && defined(HASP_GPIO_TEMPLATE)
// Load custom GPIO template
char json[96];
snprintf(json, sizeof(json), PSTR("{\"%s\":%s}"), (char*)(FPSTR(FP_GPIO_CONFIG)), (char*)(FPSTR(HASP_GPIO_TEMPLATE)));
snprintf(json, sizeof(json), PSTR("{\"%s\":%s}"), (char*)(FPSTR(FP_GPIO_CONFIG)),
(char*)(FPSTR(HASP_GPIO_TEMPLATE)));
dispatch_config((char*)(FPSTR(FP_GPIO)), json, TAG_CONF);
#endif