diff --git a/src/DjConfig.cpp b/src/DjConfig.cpp index f662cf7..016473c 100644 --- a/src/DjConfig.cpp +++ b/src/DjConfig.cpp @@ -127,6 +127,28 @@ void Config::loadFile(const char *filename, const char * const sectionConfigItem } } +void Config::writeAllConfigs(void) { + boolean allChangesWritten = false; + logHeap(); + + while (!allChangesWritten) { + for (int i=0; i
"; const char _PORTAL_OPTIONS[] PROGMEM = "



"; const char _ITEM[] PROGMEM = "
{v} {r}%
"; -const char _FORM_START[] PROGMEM = "
"; +const char _FORM_START[] PROGMEM = ""; const char _FORM_CLOCKNAME[] PROGMEM = "
"; const char _FORM_CLOCKSFOUND_START[] PROGMEM = "Fastclocks seen:
    "; const char _FORM_CLOCKSFOUND_ITEM[] PROGMEM = "
  • {fc}
  • "; @@ -115,7 +115,7 @@ const char _FORM_COLOR_YELLOW[] PROGMEM = "
    "; +const char _SAVE_PERM_BUTTON[] PROGMEM = "

    "; const char _CONFIG_BUTTON[] PROGMEM = "

    "; const char _VSPACE[] PROGMEM = "

    "; const char _SAVED[] PROGMEM = "
    Credentials Saved
    Trying to connect ESP to network.
    If it fails reconnect to AP to try again
    "; @@ -269,6 +269,26 @@ void appConfigSave() { server->send(200, "text/html", page); } +void appConfigSavePermanent() { + String page = FPSTR(_HEAD); + + page.replace("{v}", "7Seg Config"); + page += FPSTR(_SCRIPT); + page += FPSTR(_STYLE); + page += FPSTR(_HEAD_END); + page += String(F("

    ")); + page += appName; + page += String(F("

    ")); + + debug.outln("Writing configs to save them permanently", DEBUG_MAX_INFO); + config.writeAllConfigs(); + page += String(F("
    Configuration permanently saved.
    ")); + page += FPSTR(_CONFIG_BUTTON); + page += FPSTR(_END); + server->sendHeader("Content-Length", String(page.length())); + server->send(200, "text/html", page); +} + void setup() { debug.out(F("Starting *** "), DEBUG_MAX_INFO); debug.outln(appName, DEBUG_MAX_INFO); debug.out(F("Reset reason: "), DEBUG_MIN_INFO); @@ -305,11 +325,15 @@ void setup() { debug.outln(F("Starting 7-segment clock display ..."), DEBUG_MAX_INFO); sevenSegmentClock.begin(); + sevenSegmentClock.setBrightness(config.getInt("brightness")); + sevenSegmentClock.setColor(sevenSegmentClock.getColorHandleByName(config.getString("clockColor"))); // setting up web server for clock configuration server = new ESP8266WebServer(80); server->on("/config", HTTP_GET, appConfig); - server->on("/configsave", HTTP_GET, appConfigSave); + server->on("/configSave", HTTP_GET, appConfigSave); + server->on("/configSavePermanent", HTTP_GET, appConfigSavePermanent); + server->begin(); }