mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-28 13:46:36 +00:00
Allow ANSI codes to be disabled #261
This commit is contained in:
parent
cacdb34df8
commit
de83fa8a9d
@ -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<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()) {
|
||||
|
@ -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";
|
||||
|
@ -139,6 +139,9 @@ bool debugGetConfig(const JsonObject& settings)
|
||||
{
|
||||
bool changed = false;
|
||||
|
||||
if(debugAnsiCodes != settings[FPSTR(FP_DEBUG_ANSI)].as<bool>()) changed = true;
|
||||
settings[FPSTR(FP_DEBUG_ANSI)] = debugAnsiCodes;
|
||||
|
||||
if(debugSerialBaud != settings[FPSTR(FP_CONFIG_BAUD)].as<uint16_t>()) 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;
|
||||
|
@ -324,6 +324,7 @@ void saveConfig()
|
||||
guiSetConfig(settings.as<JsonObject>());
|
||||
|
||||
} else if(save == String(PSTR("debug"))) {
|
||||
settings[FPSTR(FP_DEBUG_ANSI)] = webServer.hasArg(PSTR("ansi"));
|
||||
debugSetConfig(settings.as<JsonObject>());
|
||||
|
||||
} else if(save == String(PSTR("http"))) {
|
||||
@ -1739,12 +1740,18 @@ static void webHandleDebugConfig()
|
||||
httpMessage += F("</select></div></div>");
|
||||
|
||||
// Telemetry Period
|
||||
httpMessage += F("<div class='row gap'><div class='col-25'><label for='tele'>Telemetry Period</label></div>");
|
||||
httpMessage += F("<div class='row'><div class='col-25'><label for='tele'>Telemetry Period</label></div>");
|
||||
httpMessage += F("<div class='col-75'><input type='number' id='tele' name='tele' min='0' max='65535' "
|
||||
"value='");
|
||||
httpMessage += settings[FPSTR(FP_DEBUG_TELEPERIOD)].as<String>();
|
||||
httpMessage += F("'></div></div>");
|
||||
|
||||
// Invert
|
||||
httpMessage += F("<div class='row gap'><div class='col-25'><label for='ansi'></label></div>");
|
||||
httpMessage += F("<div class='col-75'><input type='checkbox' id='ansi' name='ansi'");
|
||||
if(settings[FPSTR(FP_DEBUG_ANSI)].as<bool>()) httpMessage += F(" checked");
|
||||
httpMessage += F(">Use ANSI Colors</div></div>");
|
||||
|
||||
#if HASP_USE_SYSLOG > 0
|
||||
// Syslog host
|
||||
httpMessage += F("<div class='row'><div class='col-25'><label for='host'>Syslog Server</label></div>");
|
||||
|
Loading…
x
Reference in New Issue
Block a user