diff --git a/src/hasp_config.cpp b/src/hasp_config.cpp index 15cb5860..13f4fd78 100644 --- a/src/hasp_config.cpp +++ b/src/hasp_config.cpp @@ -37,6 +37,18 @@ void confDebugSet(const __FlashStringHelper* fstr_name) 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(); + 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()) { diff --git a/src/hasp_config.h b/src/hasp_config.h index 3ab61d58..9d8c0c50 100644 --- a/src/hasp_config.h +++ b/src/hasp_config.h @@ -24,6 +24,7 @@ void configOutput(const JsonObject& settings, uint8_t tag = TAG_CONF); bool configClearEeprom(void); /* ===== Getter and Setter Functions ===== */ +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(uint8_t& value, const JsonVariant& setting, const __FlashStringHelper* fstr_name); bool configSet(uint16_t& value, const JsonVariant& setting, const __FlashStringHelper* fstr_name); @@ -60,6 +61,7 @@ const char FP_GUI_CALIBRATION[] PROGMEM = "calibration"; const char FP_GUI_BACKLIGHTPIN[] PROGMEM = "bckl"; const char FP_GUI_POINTER[] PROGMEM = "cursor"; const char FP_DEBUG_TELEPERIOD[] PROGMEM = "tele"; +const char FP_DEBUG_ANSI[] PROGMEM = "ansi"; const char FP_GPIO_CONFIG[] PROGMEM = "config"; const char FP_HASP_CONFIG_FILE[] PROGMEM = "/config.json"; diff --git a/src/log/hasp_debug.cpp b/src/log/hasp_debug.cpp index 8d87dc6c..67c5988a 100644 --- a/src/log/hasp_debug.cpp +++ b/src/log/hasp_debug.cpp @@ -139,6 +139,9 @@ bool debugGetConfig(const JsonObject& settings) { bool changed = false; + if(debugAnsiCodes != settings[FPSTR(FP_DEBUG_ANSI)].as()) changed = true; + settings[FPSTR(FP_DEBUG_ANSI)] = debugAnsiCodes; + if(debugSerialBaud != settings[FPSTR(FP_CONFIG_BAUD)].as()) changed = true; settings[FPSTR(FP_CONFIG_BAUD)] = debugSerialBaud; @@ -176,13 +179,16 @@ bool debugSetConfig(const JsonObject& settings) configOutput(settings, TAG_DEBG); bool changed = false; - /* Serial Settings*/ + /* Ansi Code Settings */ + changed |= configSet(debugAnsiCodes, settings[FPSTR(FP_DEBUG_ANSI)], F("debugAnsi")); + + /* Serial Settings */ changed |= configSet(debugSerialBaud, settings[FPSTR(FP_CONFIG_BAUD)], F("debugSerialBaud")); - /* Teleperiod Settings*/ + /* Teleperiod Settings */ changed |= configSet(dispatch_setings.teleperiod, settings[FPSTR(FP_DEBUG_TELEPERIOD)], F("debugTelePeriod")); -/* Syslog Settings*/ +/* Syslog Settings */ #if HASP_USE_SYSLOG > 0 if(!settings[FPSTR(FP_CONFIG_HOST)].isNull()) { changed |= strcmp(debugSyslogHost, settings[FPSTR(FP_CONFIG_HOST)]) != 0; diff --git a/src/sys/svc/hasp_http.cpp b/src/sys/svc/hasp_http.cpp index 2a0aa2aa..3177db0d 100644 --- a/src/sys/svc/hasp_http.cpp +++ b/src/sys/svc/hasp_http.cpp @@ -324,6 +324,7 @@ void saveConfig() guiSetConfig(settings.as()); } else if(save == String(PSTR("debug"))) { + settings[FPSTR(FP_DEBUG_ANSI)] = webServer.hasArg(PSTR("ansi")); debugSetConfig(settings.as()); } else if(save == String(PSTR("http"))) { @@ -1739,12 +1740,18 @@ static void webHandleDebugConfig() httpMessage += F(""); // Telemetry Period - httpMessage += F("
"); + httpMessage += F("
"); httpMessage += F("
"); + // Invert + httpMessage += F("
"); + httpMessage += F("
()) httpMessage += F(" checked"); + httpMessage += F(">Use ANSI Colors
"); + #if HASP_USE_SYSLOG > 0 // Syslog host httpMessage += F("
");