Add Invert Colors display option

This commit is contained in:
fvanroie 2021-01-23 22:22:25 +01:00
parent 3f52fab0d1
commit a0409d0c7f
3 changed files with 23 additions and 13 deletions

View File

@ -3,12 +3,12 @@
#if HASP_USE_CONFIG > 0
#ifndef HASP_CONFIG_H
#define HASP_CONFIG_H
#ifndef HASP_CONFIG_H
#define HASP_CONFIG_H
#include "hasp_conf.h"
#include "ArduinoJson.h"
#include "hasp_debug.h" // for TAG_CONF
#include "hasp_conf.h"
#include "ArduinoJson.h"
#include "hasp_debug.h" // for TAG_CONF
/* ===== Default Event Processors ===== */
void configSetup(void);
@ -49,18 +49,19 @@ const char F_CONFIG_GROUP[] PROGMEM = "group";
const char F_CONFIG_BAUD[] PROGMEM = "baud";
const char F_CONFIG_LOG[] PROGMEM = "log";
const char F_CONFIG_PROTOCOL[] PROGMEM = "proto";
const char F_GUI_ROTATION[] PROGMEM = "rotation";
const char F_GUI_TICKPERIOD[] PROGMEM = "tickperiod";
const char F_GUI_ROTATION[] PROGMEM = "rotate";
const char F_GUI_INVERT[] PROGMEM = "invert";
const char F_GUI_TICKPERIOD[] PROGMEM = "tick";
const char F_GUI_IDLEPERIOD1[] PROGMEM = "idle1";
const char F_GUI_IDLEPERIOD2[] PROGMEM = "idle2";
const char F_GUI_CALIBRATION[] PROGMEM = "calibration";
const char F_GUI_BACKLIGHTPIN[] PROGMEM = "bcklpin";
const char F_GUI_POINTER[] PROGMEM = "pointer";
const char F_DEBUG_TELEPERIOD[] PROGMEM = "teleperiod";
const char F_GUI_BACKLIGHTPIN[] PROGMEM = "bckl";
const char F_GUI_POINTER[] PROGMEM = "cursor";
const char F_DEBUG_TELEPERIOD[] PROGMEM = "tele";
const char F_GPIO_CONFIG[] PROGMEM = "config";
const char HASP_CONFIG_FILE[] PROGMEM = "/config.json";
#endif
#endif
#endif // HASP_USE_CONFIG

View File

@ -506,6 +506,9 @@ bool guiGetConfig(const JsonObject & settings)
if(guiShowPointer != settings[FPSTR(F_GUI_POINTER)].as<bool>()) changed = true;
settings[FPSTR(F_GUI_POINTER)] = guiShowPointer;
if(guiInvertDisplay != settings[FPSTR(F_GUI_INVERT)].as<bool>()) changed = true;
settings[FPSTR(F_GUI_INVERT)] = guiInvertDisplay;
/* Check CalData array has changed */
JsonArray array = settings[FPSTR(F_GUI_CALIBRATION)].as<JsonArray>();
uint8_t i = 0;
@ -559,6 +562,7 @@ bool guiSetConfig(const JsonObject & settings)
changed |= configSet(guiSleepTime1, settings[FPSTR(F_GUI_IDLEPERIOD1)], F("guiSleepTime1"));
changed |= configSet(guiSleepTime2, settings[FPSTR(F_GUI_IDLEPERIOD2)], F("guiSleepTime2"));
changed |= configSet(guiRotation, settings[FPSTR(F_GUI_ROTATION)], F("guiRotation"));
changed |= configSet(guiInvertDisplay, settings[FPSTR(F_GUI_INVERT)], F("guiInvertDisplay"));
if(!settings[FPSTR(F_GUI_POINTER)].isNull()) {
if(guiShowPointer != settings[FPSTR(F_GUI_POINTER)].as<bool>()) {

View File

@ -237,7 +237,8 @@ void saveConfig()
#endif
} else if(save == String(PSTR("gui"))) {
settings[FPSTR(F_GUI_POINTER)] = webServer.hasArg(PSTR("pointer"));
settings[FPSTR(F_GUI_POINTER)] = webServer.hasArg(PSTR("cur"));
settings[FPSTR(F_GUI_INVERT)] = webServer.hasArg(PSTR("inv"));
guiSetConfig(settings.as<JsonObject>());
} else if(save == String(PSTR("debug"))) {
@ -1093,7 +1094,11 @@ void webHandleGuiConfig()
httpMessage += getOption(5, F("270 degrees - mirrored"), rotation == 5);
httpMessage += F("</select></p>");
httpMessage += F("<p><input id='pointer' name='pointer' type='checkbox' ");
httpMessage += F("<p><input id='inv' name='inv' type='checkbox' ");
if(settings[FPSTR(F_GUI_INVERT)].as<bool>()) httpMessage += F(" checked");
httpMessage += F("><b>Invert Colors</b>");
httpMessage += F("<p><input id='cur' name='cur' type='checkbox' ");
if(settings[FPSTR(F_GUI_POINTER)].as<bool>()) httpMessage += F(" checked");
httpMessage += F("><b>Show Pointer</b>");