mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-29 06:06:40 +00:00
Revert F() and move char* to FlashStringHelper
This commit is contained in:
parent
af24bedf6d
commit
6ccd10dbe0
@ -437,13 +437,13 @@ void haspProgressMsg(const char* msg)
|
|||||||
} */
|
} */
|
||||||
}
|
}
|
||||||
|
|
||||||
// #ifdef ARDUINO
|
#ifdef ARDUINO
|
||||||
// // Sets the value string of the global progress bar
|
// Sets the value string of the global progress bar
|
||||||
// void haspProgressMsg(const __FlashStringHelper* msg)
|
void haspProgressMsg(const __FlashStringHelper* msg)
|
||||||
// {
|
{
|
||||||
// haspProgressMsg(String(msg).c_str());
|
haspProgressMsg(String(msg).c_str());
|
||||||
// }
|
}
|
||||||
// #endif
|
#endif
|
||||||
|
|
||||||
/*Add a custom apply callback*/
|
/*Add a custom apply callback*/
|
||||||
static void custom_font_apply_cb(lv_theme_t* th, lv_obj_t* obj, lv_theme_style_t name)
|
static void custom_font_apply_cb(lv_theme_t* th, lv_obj_t* obj, lv_theme_style_t name)
|
||||||
@ -829,20 +829,20 @@ bool haspSetConfig(const JsonObject& settings)
|
|||||||
JsonVariant color_str;
|
JsonVariant color_str;
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
|
|
||||||
changed |= configSet(haspStartPage, settings[FPSTR(FP_CONFIG_STARTPAGE)], F("haspStartPage"));
|
changed |= configSet(haspStartPage, settings[FPSTR(FP_CONFIG_STARTPAGE)], "haspStartPage");
|
||||||
changed |= configSet(haspStartDim, settings[FPSTR(FP_CONFIG_STARTDIM)], F("haspStartDim"));
|
changed |= configSet(haspStartDim, settings[FPSTR(FP_CONFIG_STARTDIM)], "haspStartDim");
|
||||||
|
|
||||||
{ // Theme related settings
|
{ // Theme related settings
|
||||||
// Set from Hue first
|
// Set from Hue first
|
||||||
bool theme_changed = false;
|
bool theme_changed = false;
|
||||||
theme_changed |= configSet(haspThemeId, settings[FPSTR(FP_CONFIG_THEME)], F("haspThemeId"));
|
theme_changed |= configSet(haspThemeId, settings[FPSTR(FP_CONFIG_THEME)], "haspThemeId");
|
||||||
theme_changed |= configSet(haspThemeHue, settings[FPSTR(FP_CONFIG_HUE)], F("haspThemeHue"));
|
theme_changed |= configSet(haspThemeHue, settings[FPSTR(FP_CONFIG_HUE)], "haspThemeHue");
|
||||||
color_primary = lv_color_hsv_to_rgb(haspThemeHue, 100, 100);
|
color_primary = lv_color_hsv_to_rgb(haspThemeHue, 100, 100);
|
||||||
color_secondary = lv_color_hsv_to_rgb(20, 60, 100);
|
color_secondary = lv_color_hsv_to_rgb(20, 60, 100);
|
||||||
|
|
||||||
// Check for color1 and color2
|
// Check for color1 and color2
|
||||||
theme_changed |= configSet(color_primary, settings[FPSTR(FP_CONFIG_COLOR1)], F("haspColor1"));
|
theme_changed |= configSet(color_primary, settings[FPSTR(FP_CONFIG_COLOR1)], "haspColor1");
|
||||||
theme_changed |= configSet(color_secondary, settings[FPSTR(FP_CONFIG_COLOR2)], F("haspColor2"));
|
theme_changed |= configSet(color_secondary, settings[FPSTR(FP_CONFIG_COLOR2)], "haspColor2");
|
||||||
|
|
||||||
changed |= theme_changed;
|
changed |= theme_changed;
|
||||||
// if(theme_changed) hasp_set_theme(haspThemeId); // LVGL is not inited at config load time
|
// if(theme_changed) hasp_set_theme(haspThemeId); // LVGL is not inited at config load time
|
||||||
|
@ -105,8 +105,8 @@ void hasp_set_theme(uint8_t themeid);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
void haspProgressMsg(const char* msg);
|
void haspProgressMsg(const char* msg);
|
||||||
// #ifdef ARDUINO
|
#ifdef ARDUINO
|
||||||
// void haspProgressMsg(const __FlashStringHelper* msg);
|
void haspProgressMsg(const __FlashStringHelper* msg);
|
||||||
// #endif
|
#endif
|
||||||
|
|
||||||
#endif /*HASP_H*/
|
#endif /*HASP_H*/
|
||||||
|
@ -29,13 +29,94 @@ extern uint32_t dispatchLastMillis;
|
|||||||
extern gui_conf_t gui_settings;
|
extern gui_conf_t gui_settings;
|
||||||
extern dispatch_conf_t dispatch_settings;
|
extern dispatch_conf_t dispatch_settings;
|
||||||
|
|
||||||
void confDebugSet(const char* fstr_name)
|
void confDebugSet(const __FlashStringHelper* fstr_name)
|
||||||
{
|
{
|
||||||
/*char buffer[128];
|
/*char buffer[128];
|
||||||
snprintf_P(buffer, sizeof(buffer), PSTR(" * %s set"), name);
|
snprintf_P(buffer, sizeof(buffer), PSTR(" * %s set"), name);
|
||||||
debugPrintln(buffer);*/
|
debugPrintln(buffer);*/
|
||||||
LOG_VERBOSE(TAG_CONF, F(D_BULLET "%S set"), fstr_name);
|
LOG_VERBOSE(TAG_CONF, F(D_BULLET "%S set"), fstr_name);
|
||||||
}
|
}
|
||||||
|
void confDebugSet(const char* fstr_name)
|
||||||
|
{
|
||||||
|
/*char buffer[128];
|
||||||
|
snprintf_P(buffer, sizeof(buffer), PSTR(" * %s set"), name);
|
||||||
|
debugPrintln(buffer);*/
|
||||||
|
LOG_VERBOSE(TAG_CONF, F(D_BULLET "%s set"), fstr_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool configSet(bool& value, const JsonVariant& setting, const __FlashStringHelper* fstr_name)
|
||||||
|
{
|
||||||
|
if(!setting.isNull()) {
|
||||||
|
bool val = setting.as<bool>();
|
||||||
|
if(value != val) {
|
||||||
|
confDebugSet(fstr_name);
|
||||||
|
value = val;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
bool configSet(int8_t& value, const JsonVariant& setting, const __FlashStringHelper* fstr_name)
|
||||||
|
{
|
||||||
|
if(!setting.isNull()) {
|
||||||
|
int8_t val = setting.as<int8_t>();
|
||||||
|
if(value != val) {
|
||||||
|
confDebugSet(fstr_name);
|
||||||
|
value = val;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
bool configSet(uint8_t& value, const JsonVariant& setting, const __FlashStringHelper* fstr_name)
|
||||||
|
{
|
||||||
|
if(!setting.isNull()) {
|
||||||
|
uint8_t val = setting.as<uint8_t>();
|
||||||
|
if(value != val) {
|
||||||
|
confDebugSet(fstr_name);
|
||||||
|
value = val;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
bool configSet(uint16_t& value, const JsonVariant& setting, const __FlashStringHelper* fstr_name)
|
||||||
|
{
|
||||||
|
if(!setting.isNull()) {
|
||||||
|
uint16_t val = setting.as<uint16_t>();
|
||||||
|
if(value != val) {
|
||||||
|
confDebugSet(fstr_name);
|
||||||
|
value = val;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
bool configSet(int32_t& value, const JsonVariant& setting, const __FlashStringHelper* fstr_name)
|
||||||
|
{
|
||||||
|
if(!setting.isNull()) {
|
||||||
|
int32_t val = setting.as<int32_t>();
|
||||||
|
if(value != val) {
|
||||||
|
confDebugSet(fstr_name);
|
||||||
|
value = val;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
bool configSet(bool& value, const JsonVariant& setting, const char* fstr_name)
|
bool configSet(bool& value, const JsonVariant& setting, const char* fstr_name)
|
||||||
{
|
{
|
||||||
@ -110,6 +191,7 @@ bool configSet(lv_color_t& value, const JsonVariant& setting, const char* fstr_n
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void configSetupDebug(JsonDocument& settings)
|
void configSetupDebug(JsonDocument& settings)
|
||||||
{
|
{
|
||||||
debugSetup(settings[FPSTR(FP_DEBUG)]);
|
debugSetup(settings[FPSTR(FP_DEBUG)]);
|
||||||
@ -118,7 +200,7 @@ void configSetupDebug(JsonDocument& settings)
|
|||||||
|
|
||||||
void configStorePasswords(JsonDocument& settings, String& wifiPass, String& mqttPass, String& httpPass)
|
void configStorePasswords(JsonDocument& settings, String& wifiPass, String& mqttPass, String& httpPass)
|
||||||
{
|
{
|
||||||
const char* pass = F("pass");
|
const char* pass = ("pass");
|
||||||
|
|
||||||
wifiPass = settings[FPSTR(FP_WIFI)][pass].as<String>();
|
wifiPass = settings[FPSTR(FP_WIFI)][pass].as<String>();
|
||||||
mqttPass = settings[FPSTR(FP_MQTT)][pass].as<String>();
|
mqttPass = settings[FPSTR(FP_MQTT)][pass].as<String>();
|
||||||
@ -127,7 +209,7 @@ void configStorePasswords(JsonDocument& settings, String& wifiPass, String& mqtt
|
|||||||
|
|
||||||
void configRestorePasswords(JsonDocument& settings, String& wifiPass, String& mqttPass, String& httpPass)
|
void configRestorePasswords(JsonDocument& settings, String& wifiPass, String& mqttPass, String& httpPass)
|
||||||
{
|
{
|
||||||
const char* pass = F("pass");
|
const char* pass = ("pass");
|
||||||
|
|
||||||
if(!settings[FPSTR(FP_WIFI)][pass].isNull()) settings[FPSTR(FP_WIFI)][pass] = wifiPass;
|
if(!settings[FPSTR(FP_WIFI)][pass].isNull()) settings[FPSTR(FP_WIFI)][pass] = wifiPass;
|
||||||
if(!settings[FPSTR(FP_MQTT)][pass].isNull()) settings[FPSTR(FP_MQTT)][pass] = mqttPass;
|
if(!settings[FPSTR(FP_MQTT)][pass].isNull()) settings[FPSTR(FP_MQTT)][pass] = mqttPass;
|
||||||
@ -287,7 +369,7 @@ void configWrite()
|
|||||||
|
|
||||||
bool writefile = false;
|
bool writefile = false;
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
const char* module;
|
const __FlashStringHelper* module;
|
||||||
|
|
||||||
#if HASP_USE_WIFI > 0
|
#if HASP_USE_WIFI > 0
|
||||||
module = FPSTR(FP_WIFI);
|
module = FPSTR(FP_WIFI);
|
||||||
|
@ -23,12 +23,12 @@ void configOutput(const JsonObject& settings, uint8_t tag);
|
|||||||
bool configClearEeprom(void);
|
bool configClearEeprom(void);
|
||||||
|
|
||||||
/* ===== Getter and Setter Functions ===== */
|
/* ===== Getter and Setter Functions ===== */
|
||||||
// bool configSet(bool& value, const JsonVariant& setting, const __FlashStringHelper* fstr_name);
|
bool configSet(bool& value, const JsonVariant& setting, const __FlashStringHelper* fstr_name);
|
||||||
// bool configSet(int8_t& value, const JsonVariant& setting, const __FlashStringHelper* fstr_name);
|
bool configSet(int8_t& value, const JsonVariant& setting, const __FlashStringHelper* fstr_name);
|
||||||
// bool configSet(uint8_t& value, const JsonVariant& setting, const __FlashStringHelper* fstr_name);
|
bool configSet(uint8_t& value, const JsonVariant& setting, const __FlashStringHelper* fstr_name);
|
||||||
// bool configSet(uint16_t& value, const JsonVariant& setting, const __FlashStringHelper* fstr_name);
|
bool configSet(uint16_t& value, const JsonVariant& setting, const __FlashStringHelper* fstr_name);
|
||||||
// bool configSet(int32_t& value, const JsonVariant& setting, const __FlashStringHelper* fstr_name);
|
bool configSet(int32_t& value, const JsonVariant& setting, const __FlashStringHelper* fstr_name);
|
||||||
// bool configSet(lv_color_t& value, const JsonVariant& setting, const __FlashStringHelper* fstr_name);
|
bool configSet(lv_color_t& value, const JsonVariant& setting, const __FlashStringHelper* fstr_name);
|
||||||
bool configSet(bool& value, const JsonVariant& setting, const char* fstr_name);
|
bool configSet(bool& value, const JsonVariant& setting, const char* fstr_name);
|
||||||
bool configSet(int8_t& value, const JsonVariant& setting, const char* fstr_name);
|
bool configSet(int8_t& value, const JsonVariant& setting, const char* fstr_name);
|
||||||
bool configSet(uint8_t& value, const JsonVariant& setting, const char* fstr_name);
|
bool configSet(uint8_t& value, const JsonVariant& setting, const char* fstr_name);
|
||||||
|
@ -25,14 +25,14 @@
|
|||||||
|
|
||||||
bool debugAnsiCodes = false;
|
bool debugAnsiCodes = false;
|
||||||
|
|
||||||
// inline void debugSendAnsiCode(const __FlashStringHelper* code, Print* _logOutput)
|
inline void debugSendAnsiCode(const __FlashStringHelper* code, Print* _logOutput)
|
||||||
// {
|
{
|
||||||
// #ifdef ARDUINO
|
#ifdef ARDUINO
|
||||||
// if(debugAnsiCodes) _logOutput->print(code);
|
if(debugAnsiCodes) _logOutput->print(code);
|
||||||
// #else
|
#else
|
||||||
// if(debugAnsiCodes) debug_print(_logOutput, code);
|
if(debugAnsiCodes) debug_print(_logOutput, code);
|
||||||
// #endif
|
#endif
|
||||||
// }
|
}
|
||||||
|
|
||||||
inline void debugSendAnsiCode(const char* code, Print* _logOutput)
|
inline void debugSendAnsiCode(const char* code, Print* _logOutput)
|
||||||
{
|
{
|
||||||
|
@ -169,6 +169,15 @@ static void add_form_button(String& str, const char* label, const char* action)
|
|||||||
str += "</a>";
|
str += "</a>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void add_form_button(String& str, const char* label, const __FlashStringHelper* action)
|
||||||
|
{
|
||||||
|
str += "<a href='";
|
||||||
|
str += action;
|
||||||
|
str += "'>";
|
||||||
|
str += label;
|
||||||
|
str += "</a>";
|
||||||
|
}
|
||||||
|
|
||||||
static String http_get_content_type(const String& path)
|
static String http_get_content_type(const String& path)
|
||||||
{
|
{
|
||||||
char buffer[sizeof(mime::mimeTable[0].mimeType)];
|
char buffer[sizeof(mime::mimeTable[0].mimeType)];
|
||||||
@ -208,6 +217,22 @@ bool http_is_authenticated()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check authentication and create Log entry
|
||||||
|
bool http_is_authenticated(const __FlashStringHelper* notused)
|
||||||
|
{
|
||||||
|
if(!http_is_authenticated()) return false;
|
||||||
|
|
||||||
|
#if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266)
|
||||||
|
LOG_VERBOSE(TAG_HTTP, D_HTTP_SENDING_PAGE, webServer.uri().c_str(),
|
||||||
|
webServer.client().remoteIP().toString().c_str());
|
||||||
|
#else
|
||||||
|
// LOG_INFO(TAG_HTTP,D_HTTP_SENDING_PAGE, page,
|
||||||
|
// String(webServer.client().remoteIP()).c_str());
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// Check authentication and create Log entry
|
// Check authentication and create Log entry
|
||||||
bool http_is_authenticated(const char* notused)
|
bool http_is_authenticated(const char* notused)
|
||||||
{
|
{
|
||||||
@ -640,7 +665,7 @@ static void webHandleApi()
|
|||||||
}
|
}
|
||||||
|
|
||||||
settings = doc.to<JsonObject>();
|
settings = doc.to<JsonObject>();
|
||||||
const char* module;
|
const __FlashStringHelper* module;
|
||||||
|
|
||||||
module = FPSTR(FP_HASP);
|
module = FPSTR(FP_HASP);
|
||||||
settings.createNestedObject(module);
|
settings.createNestedObject(module);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user