|
|
|
@ -41,8 +41,61 @@ Debug debug;
|
|
|
|
|
Config config(debug);
|
|
|
|
|
ClockClient fastclock(debug, config);
|
|
|
|
|
SevenSegmentClock sevenSegmentClock(debug, config);
|
|
|
|
|
ClockClient fastclockClient(debug, config);
|
|
|
|
|
ESP8266WebServer *server;
|
|
|
|
|
ClockClient fastclockClient(debug, config);
|
|
|
|
|
|
|
|
|
|
static struct ColorSelection {
|
|
|
|
|
uint8_t id;
|
|
|
|
|
SevenSegmentClock::Color colorHandle;
|
|
|
|
|
String colorName;
|
|
|
|
|
} colorSelection[] = {
|
|
|
|
|
{ 1, SevenSegmentClock::Black, "black" },
|
|
|
|
|
{ 2, SevenSegmentClock::Blue, "blue" },
|
|
|
|
|
{ 3, SevenSegmentClock::Red, "red" },
|
|
|
|
|
{ 4, SevenSegmentClock::Green, "green" },
|
|
|
|
|
{ 5, SevenSegmentClock::White, "white" },
|
|
|
|
|
{ 6, SevenSegmentClock::Yellow, "yellow" }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
|
|
|
|
|
static const String getColorName(uint8_t color) {
|
|
|
|
|
for (unsigned int i=0; i<sizeof(colorSelection); ++i) {
|
|
|
|
|
if (color == colorSelection[i].id) {
|
|
|
|
|
return colorSelection[i].colorName;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return "**INVALID**";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const uint8_t getColorId(SevenSegmentClock::Color color) {
|
|
|
|
|
for (unsigned int i=0; i<sizeof(colorSelection); ++i) {
|
|
|
|
|
if (color == colorSelection[i].colorHandle) {
|
|
|
|
|
return colorSelection[i].id;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const SevenSegmentClock::Color getColorHandle(uint8_t id) {
|
|
|
|
|
for (unsigned int i=0; i<sizeof(colorSelection); ++i) {
|
|
|
|
|
if (id == colorSelection[i].id) {
|
|
|
|
|
return colorSelection[i].colorHandle;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return SevenSegmentClock::Green; // default
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
static const SevenSegmentClock::Color getColorHandleByName(String name) {
|
|
|
|
|
for (unsigned int i=0; i<sizeof(colorSelection); ++i) {
|
|
|
|
|
if (name.equals(colorSelection[i].colorName)) {
|
|
|
|
|
return colorSelection[i].colorHandle;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return SevenSegmentClock::Green; // default
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//flag for saving data
|
|
|
|
|
bool shouldSaveConfig = false;
|
|
|
|
@ -81,6 +134,25 @@ void setupWifiConnection() {
|
|
|
|
|
//save the custom parameters to FS
|
|
|
|
|
if (shouldSaveConfig) {
|
|
|
|
|
debug.outln("saving config ... NYI", DEBUG_MED_INFO);
|
|
|
|
|
// DynamicJsonDocument config(2048);
|
|
|
|
|
//JsonObject json = jsonBuffer.createObject();
|
|
|
|
|
/*
|
|
|
|
|
config["clock_name"] = clockName;
|
|
|
|
|
config["clock_channel"] = clockChannelString;
|
|
|
|
|
config["clock_color"] = clockColor;
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
File configFile = SPIFFS.open("/config.json", "w");
|
|
|
|
|
if (!configFile) {
|
|
|
|
|
Serial.println("failed to open config file for writing");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
serializeJsonPretty(config, Serial);
|
|
|
|
|
serializeJson(config, configFile);
|
|
|
|
|
configFile.close();
|
|
|
|
|
//end save
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
debug.out("local ip: ", DEBUG_MAX_INFO); debug.outln(WiFi.localIP(), DEBUG_MAX_INFO);
|
|
|
|
@ -94,11 +166,8 @@ const char _SCRIPT[] PROGMEM = "<script>function c(l){document.getEle
|
|
|
|
|
const char _HEAD_END[] PROGMEM = "</head><body><div style='text-align:left;display:inline-block;min-width:260px;'>";
|
|
|
|
|
const char _PORTAL_OPTIONS[] PROGMEM = "<form action=\"/wifi\" method=\"get\"><button>Configure WiFi</button></form><br/><form action=\"/0wifi\" method=\"get\"><button>Configure WiFi (No Scan)</button></form><br/><form action=\"/i\" method=\"get\"><button>Info</button></form><br/><form action=\"/r\" method=\"post\"><button>Reset</button></form>";
|
|
|
|
|
const char _ITEM[] PROGMEM = "<div><a href='#p' onclick='c(this)'>{v}</a> <span class='q {i}'>{r}%</span></div>";
|
|
|
|
|
const char _FORM_START[] PROGMEM = "<form method='get' action='configSave'>";
|
|
|
|
|
const char _FORM_CLOCKNAME[] PROGMEM = "<label for='n'>Fastclock name</label><input id='n' name='n' length=32 placeholder='clock name' value='{n}'><br/>";
|
|
|
|
|
const char _FORM_CLOCKSFOUND_START[] PROGMEM = "Fastclocks seen:<br/><ul>";
|
|
|
|
|
const char _FORM_CLOCKSFOUND_ITEM[] PROGMEM = "<li>{fc}</li>";
|
|
|
|
|
const char _FORM_CLOCKSFOUND_END[] PROGMEM = "</ul><br/>";
|
|
|
|
|
const char _FORM_START[] PROGMEM = "<form method='get' action='configsave'>";
|
|
|
|
|
const char _FORM_CLOCKNAME[] PROGMEM = "<label for='n'>Fastclock name</label><input id='n' name='n' length=32 placeholder='clock name'><br/>";
|
|
|
|
|
const char _FORM_CLOCKMODE_HEADLINE[] PROGMEM = "<br/>Clock mode:<br/>";
|
|
|
|
|
const char _FORM_CLOCKMODE_DEMO[] PROGMEM = "<input class='r' id='md' name='m' type='radio' value='demo' {check}><label for='md'>Demo</label><br/>";
|
|
|
|
|
const char _FORM_CLOCKMODE_REAL[] PROGMEM = "<input class='r' id='mr' name='m' type='radio' value='real' {check}><label for='md'>Real Clock</label><br/>";
|
|
|
|
@ -106,18 +175,15 @@ const char _FORM_CLOCKMODE_FAST[] PROGMEM = "<input class='r' id='mf' name='m' t
|
|
|
|
|
const char _FORM_UTC_OFFSET[] PROGMEM = "<label for='utc'>UTC offset (minutes)</label><input id='utc' name='utc' length=4 placeholder='120'><br/>";
|
|
|
|
|
const char _FORM_PARAM[] PROGMEM = "<br/><input id='{i}' name='{n}' maxlength={l} placeholder='{p}' value='{v}' {c}>";
|
|
|
|
|
const char _FORM_COLOR_HEADLINE[] PROGMEM = "<br/>Display color:<br/>";
|
|
|
|
|
const char _FORM_COLOR_template[] PROGMEM = "<input class='r' id='{cid}' name='c' type='radio' value='{cname}' {check}><label for='{cid}'>{cname}</label><br/>";
|
|
|
|
|
const char _FORM_COLOR_BLUE[] PROGMEM = "<input class='r' id='cb' name='c' type='radio' value='Blue' {check}><label for='cb'>Blue</label><br/>";
|
|
|
|
|
const char _FORM_COLOR_RED[] PROGMEM = "<input class='r' id='cr' name='c' type='radio' value='Red' {check}><label for='cr'>Red</label><br/>";
|
|
|
|
|
const char _FORM_COLOR_GREEN[] PROGMEM = "<input class='r' id='cg' name='c' type='radio' value='Green' {check}><label for='cg'>Green</label><br/>";
|
|
|
|
|
const char _FORM_COLOR_WHITE[] PROGMEM = "<input class='r' id='cw' name='c' type='radio' value='White' {check}><label for='cw'>White</label><br/>";
|
|
|
|
|
const char _FORM_COLOR_YELLOW[] PROGMEM = "<input class='r' id='cy' name='c' type='radio' value='Yellow' {check}><label for='cy'>Yellow</label><br/>";
|
|
|
|
|
const char _FORM_BRIGHTNESS[] PROGMEM = "<label for='b'>Brightness:</label><input id='b' name='b' type='range' min='10' max='255' value='{bright}'><br/>";
|
|
|
|
|
const char _FORM_FASTCLOCK_INFO[] PROGMEM = "<div>Number of fastclocks found: {nfc}</div><br/>";
|
|
|
|
|
const char _FORM_END[] PROGMEM = "<br/><button type='submit'>apply</button></form><br/>";
|
|
|
|
|
const char _SAVE_PERM_BUTTON[] PROGMEM = "<br/><form action=\"/configSavePermanent\" method=\"get\"><button>Save permanently</button></form><br/>";
|
|
|
|
|
const char _CONFIG_BUTTON[] PROGMEM = "<br/><form action=\"/config\" method=\"get\"><button>Configure</button></form><br/>";
|
|
|
|
|
const char _VSPACE[] PROGMEM = "<br/><br/>";
|
|
|
|
|
const char _FORM_COLOR_BLUE[] PROGMEM = "<input class='r' id='cb' name='c' type='radio' value='blue' {check}><label for='cb'>Blue</label><br/>";
|
|
|
|
|
const char _FORM_COLOR_RED[] PROGMEM = "<input class='r' id='cr' name='c' type='radio' value='red' {check}><label for='cr'>Red</label><br/>";
|
|
|
|
|
const char _FORM_COLOR_GREEN[] PROGMEM = "<input class='r' id='cg' name='c' type='radio' value='green' {check}><label for='cg'>Green</label><br/>";
|
|
|
|
|
const char _FORM_COLOR_WHITE[] PROGMEM = "<input class='r' id='cw' name='c' type='radio' value='white' {check}><label for='cw'>White</label><br/>";
|
|
|
|
|
const char _FORM_COLOR_YELLOW[] PROGMEM = "<input class='r' id='cy' name='c' type='radio' value='yellow' {check}><label for='cy'>Yellow</label><br/>";
|
|
|
|
|
const char _FORM_BRIGHTNESS[] PROGMEM = "<br/><label for='b'>Brightness:</label><input id='b' name='b' type='range' min='10' max='255' value='{bright}'><br/>";
|
|
|
|
|
const char _FORM_FASTCLOCK_INFO[] PROGMEM = "<br/><br/><div>Number of fastclocks found: {nfc}</div>";
|
|
|
|
|
const char _FORM_END[] PROGMEM = "<br/><button type='submit'>save</button></form>";
|
|
|
|
|
const char _CONFIG_LINK[] PROGMEM = "<br/><div class=\"c\"><a href=\"/config\">Configure</a></div>";
|
|
|
|
|
const char _SAVED[] PROGMEM = "<div>Credentials Saved<br />Trying to connect ESP to network.<br />If it fails reconnect to AP to try again</div>";
|
|
|
|
|
const char _END[] PROGMEM = "</div></body></html>";
|
|
|
|
|
|
|
|
|
@ -125,7 +191,6 @@ void appConfig() {
|
|
|
|
|
String page = FPSTR(_HEAD);
|
|
|
|
|
String input;
|
|
|
|
|
String value;
|
|
|
|
|
int ivalue;
|
|
|
|
|
|
|
|
|
|
page.replace("{v}", "7Seg Config");
|
|
|
|
|
page += FPSTR(_SCRIPT);
|
|
|
|
@ -148,43 +213,32 @@ void appConfig() {
|
|
|
|
|
input = FPSTR(_FORM_CLOCKMODE_FAST);
|
|
|
|
|
input.replace("{check}", (config.getString("appMode").equals("Fastclock")) ? "checked" : "");
|
|
|
|
|
page += input;
|
|
|
|
|
page += FPSTR(_VSPACE);
|
|
|
|
|
page += FPSTR(_FORM_UTC_OFFSET);
|
|
|
|
|
page += FPSTR(_VSPACE);
|
|
|
|
|
input = FPSTR(_FORM_CLOCKNAME);
|
|
|
|
|
value = config.getString("listenToClock");
|
|
|
|
|
input.replace("{n}", value);
|
|
|
|
|
page += input;
|
|
|
|
|
page += FPSTR(_FORM_CLOCKSFOUND_START);
|
|
|
|
|
String *knownClocks = fastclock.getKnownClocks();
|
|
|
|
|
for (int i=0; i<fastclock.getNumberOfKnownClocks(); ++i) {
|
|
|
|
|
input = FPSTR(_FORM_CLOCKSFOUND_ITEM);
|
|
|
|
|
input.replace("{fc}", knownClocks[i]);
|
|
|
|
|
page += input;
|
|
|
|
|
}
|
|
|
|
|
page += FPSTR(_FORM_CLOCKSFOUND_END);
|
|
|
|
|
|
|
|
|
|
page += FPSTR(_VSPACE);
|
|
|
|
|
page += FPSTR(_FORM_CLOCKNAME);
|
|
|
|
|
page += FPSTR(_FORM_COLOR_HEADLINE);
|
|
|
|
|
for (int i=0; i<sevenSegmentClock.getNumberSupportedColors(); ++i) {
|
|
|
|
|
input = FPSTR(_FORM_COLOR_template);
|
|
|
|
|
input.replace("{cid}", sevenSegmentClock.getColorName(i));
|
|
|
|
|
input.replace("{cname}", sevenSegmentClock.getColorName(i));
|
|
|
|
|
input.replace("{check}", (config.getString("clockColor").equals(sevenSegmentClock.getColorName(i))) ? "checked" : "");
|
|
|
|
|
page += input;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
page += FPSTR(_VSPACE);
|
|
|
|
|
input = FPSTR(_FORM_COLOR_BLUE);
|
|
|
|
|
input.replace("{check}", (config.getString("clockColor").equals("Blue")) ? "checked" : "");
|
|
|
|
|
page += input;
|
|
|
|
|
input = FPSTR(_FORM_COLOR_RED);
|
|
|
|
|
input.replace("{check}", (config.getString("clockColor").equals("Red")) ? "checked" : "");
|
|
|
|
|
page += input;
|
|
|
|
|
input = FPSTR(_FORM_COLOR_GREEN);
|
|
|
|
|
input.replace("{check}", (config.getString("clockColor").equals("Green")) ? "checked" : "");
|
|
|
|
|
page += input;
|
|
|
|
|
input = FPSTR(_FORM_COLOR_YELLOW);
|
|
|
|
|
input.replace("{check}", (config.getString("clockColor").equals("Yellow")) ? "checked" : "");
|
|
|
|
|
page += input;
|
|
|
|
|
input = FPSTR(_FORM_COLOR_WHITE);
|
|
|
|
|
input.replace("{check}", (config.getString("clockColor").equals("White")) ? "checked" : "");
|
|
|
|
|
page += input;
|
|
|
|
|
input = FPSTR(_FORM_BRIGHTNESS);
|
|
|
|
|
value = String(sevenSegmentClock.getBrightness());
|
|
|
|
|
input.replace("{bright}", value);
|
|
|
|
|
page += input;
|
|
|
|
|
|
|
|
|
|
page += FPSTR(_VSPACE);
|
|
|
|
|
input = FPSTR(_FORM_FASTCLOCK_INFO);
|
|
|
|
|
ivalue = fastclock.getNumberOfKnownClocks();
|
|
|
|
|
value = String(ivalue);
|
|
|
|
|
//value = String("unknown");
|
|
|
|
|
//value = String(ClockClient::getNumberOfKnownClocks());
|
|
|
|
|
value = String("unknown");
|
|
|
|
|
input.replace("{nfc}", value);
|
|
|
|
|
page += input;
|
|
|
|
|
|
|
|
|
@ -217,18 +271,15 @@ void appConfigSave() {
|
|
|
|
|
debug.outln(server->arg(i), DEBUG_MAX_INFO);
|
|
|
|
|
}
|
|
|
|
|
if (server->hasArg("b")) {
|
|
|
|
|
int brightness = server->arg("b").toInt();
|
|
|
|
|
sevenSegmentClock.setBrightness(brightness);
|
|
|
|
|
config.setInt("brightness", brightness);
|
|
|
|
|
sevenSegmentClock.setBrightness(server->arg("b").toInt());
|
|
|
|
|
page += F("<div>Set brightness to ");
|
|
|
|
|
page += server->arg("b");
|
|
|
|
|
page += F(".</div>");
|
|
|
|
|
}
|
|
|
|
|
if (server->hasArg("c")) {
|
|
|
|
|
String colorName = server->arg("c");
|
|
|
|
|
SevenSegmentClock::Color colorHandle = sevenSegmentClock.getColorHandleByName(server->arg("c"));
|
|
|
|
|
SevenSegmentClock::Color colorHandle = getColorHandleByName(server->arg("c"));
|
|
|
|
|
sevenSegmentClock.setColor(colorHandle);
|
|
|
|
|
config.setString("clockColor", colorName);
|
|
|
|
|
page += F("<div>Set color to ");
|
|
|
|
|
page += server->arg("c");
|
|
|
|
|
page += F(".</div>");
|
|
|
|
@ -262,28 +313,7 @@ void appConfigSave() {
|
|
|
|
|
page += F(" minutes.</div>");
|
|
|
|
|
}
|
|
|
|
|
page += String(F("<div>Configuration updated.</div>"));
|
|
|
|
|
page += FPSTR(_CONFIG_BUTTON);
|
|
|
|
|
page += FPSTR(_SAVE_PERM_BUTTON);
|
|
|
|
|
page += FPSTR(_END);
|
|
|
|
|
server->sendHeader("Content-Length", String(page.length()));
|
|
|
|
|
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("<h1>"));
|
|
|
|
|
page += appName;
|
|
|
|
|
page += String(F("</h1>"));
|
|
|
|
|
|
|
|
|
|
debug.outln("Writing configs to save them permanently", DEBUG_MAX_INFO);
|
|
|
|
|
config.writeAllConfigs();
|
|
|
|
|
page += String(F("<div>Configuration permanently saved.</div>"));
|
|
|
|
|
page += FPSTR(_CONFIG_BUTTON);
|
|
|
|
|
page += FPSTR(_CONFIG_LINK);
|
|
|
|
|
page += FPSTR(_END);
|
|
|
|
|
server->sendHeader("Content-Length", String(page.length()));
|
|
|
|
|
server->send(200, "text/html", page);
|
|
|
|
@ -303,15 +333,77 @@ void setup() {
|
|
|
|
|
if (SPIFFS.begin()) {
|
|
|
|
|
debug.outln(F("mounted file system"), DEBUG_MAX_INFO);
|
|
|
|
|
config.begin("main.cfg", mainConfig, sizeof(mainConfig)/sizeof(mainConfig[0]));
|
|
|
|
|
#if 0
|
|
|
|
|
if (SPIFFS.exists("/config.json")) {
|
|
|
|
|
//file exists, reading and loading
|
|
|
|
|
Serial.println("reading config file");
|
|
|
|
|
File configFile = SPIFFS.open("/config.json", "r");
|
|
|
|
|
if (configFile) {
|
|
|
|
|
Serial.println("opened config file");
|
|
|
|
|
size_t size = configFile.size();
|
|
|
|
|
// Allocate a buffer to store contents of the file.
|
|
|
|
|
std::unique_ptr<char[]> buf(new char[size]);
|
|
|
|
|
|
|
|
|
|
configFile.readBytes(buf.get(), size);
|
|
|
|
|
DynamicJsonDocument config(2048);
|
|
|
|
|
//JsonObject json = jsonBuffer.createObject();
|
|
|
|
|
DeserializationError error = deserializeJson(config, configFile);
|
|
|
|
|
serializeJson(config, Serial);
|
|
|
|
|
if (!error) {
|
|
|
|
|
Serial.println("\nparsed json");
|
|
|
|
|
|
|
|
|
|
//**strcpy(mqtt_server, json["mqtt_server"]);
|
|
|
|
|
//**strcpy(mqtt_port, json["mqtt_port"]);
|
|
|
|
|
//strcpy(blynk_token, json["blynk_token"]);
|
|
|
|
|
|
|
|
|
|
if (config["clock_name"]) {
|
|
|
|
|
strncpy(clockName, config["clock_name"], MAX_CLOCK_NAME_LEN);
|
|
|
|
|
} else {
|
|
|
|
|
Serial.println("no clock name in config");
|
|
|
|
|
}
|
|
|
|
|
if (config["clock_channel"]) {
|
|
|
|
|
strncpy(clockChannelString, config["clock_channel"], MAX_CLOCK_CHANNEL_STRING_LEN);
|
|
|
|
|
} else {
|
|
|
|
|
Serial.println("no clock channel in config");
|
|
|
|
|
}
|
|
|
|
|
if (config["clock_color"]) {
|
|
|
|
|
//strncpy(clockColor, config["clock_color"], MAX_CLOCK_COLOR_LEN);
|
|
|
|
|
clockColor = getColorHandle(config["clock_color"]);
|
|
|
|
|
} else {
|
|
|
|
|
Serial.println("no clock color in config");
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
Serial.println("failed to load json config, using defaults");
|
|
|
|
|
strncpy(clockName, DEFAULT_CLOCK_NAME, MAX_CLOCK_NAME_LEN);
|
|
|
|
|
strncpy(clockChannelString, DEFAULT_CLOCK_CHANNEL_STRING, MAX_CLOCK_CHANNEL_STRING_LEN);
|
|
|
|
|
//strncpy(clockColor, DEFAULT_CLOCK_COLOR, MAX_CLOCK_COLOR_LEN);
|
|
|
|
|
clockColor = getColorHandleByName(DEFAULT_CLOCK_COLOR);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
Serial.println("no config file found");
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
} else {
|
|
|
|
|
debug.outln(F("failed to mount FS"), DEBUG_ERROR);
|
|
|
|
|
config.begin("main.cfg", mainConfig, sizeof(mainConfig)/sizeof(mainConfig[0]));
|
|
|
|
|
}
|
|
|
|
|
//end read
|
|
|
|
|
// setupWifiConnection();
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
radio.setClockChannel(clockChannel);
|
|
|
|
|
radio.setClockName(clockName);
|
|
|
|
|
radio.begin();
|
|
|
|
|
fastclock.begin();
|
|
|
|
|
pinMode(POWER_OFF_PIN, INPUT);
|
|
|
|
|
*/
|
|
|
|
|
setupWifiConnection();
|
|
|
|
|
debug.outln(F("Starting NTP Client"), DEBUG_MAX_INFO);
|
|
|
|
|
timeClient.begin();
|
|
|
|
|
|
|
|
|
|
debug.outln(F("Have following configuration:"), DEBUG_MAX_INFO);
|
|
|
|
|
//Serial.print(" Clock name: "); Serial.println(config.getString("clock_name"));
|
|
|
|
|
debug.out(F(" App Mode: "), DEBUG_MAX_INFO); debug.outln(config.getString("appMode"), DEBUG_MAX_INFO);
|
|
|
|
|
debug.out(F(" Clock color: "), DEBUG_MAX_INFO); debug.outln(config.getString("clockColor"), DEBUG_MAX_INFO);
|
|
|
|
|
debug.out(F(" Brightness: "), DEBUG_MAX_INFO); debug.outln(config.getString("brightness"), DEBUG_MAX_INFO);
|
|
|
|
@ -325,15 +417,11 @@ 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("/configSavePermanent", HTTP_GET, appConfigSavePermanent);
|
|
|
|
|
|
|
|
|
|
server->on("/configsave", HTTP_GET, appConfigSave);
|
|
|
|
|
server->begin();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -344,6 +432,8 @@ void loop() {
|
|
|
|
|
timeClient.update();
|
|
|
|
|
fastclock.loop();
|
|
|
|
|
|
|
|
|
|
//Serial.println(timeClient.getFormattedTime());
|
|
|
|
|
|
|
|
|
|
if (config.getString("appMode").equals(MODE_DEMO)) {
|
|
|
|
|
if (millis() > nextUpdate_ms) {
|
|
|
|
|
nextUpdate_ms = millis() + 1000;
|
|
|
|
|