From a887cc8789c9053d1619080edd2aae84f573097c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Sun, 26 Feb 2017 16:13:05 +0100 Subject: [PATCH] Moved EEPROM initialization to main sketch --- code/espurna/espurna.ino | 8 +++++++- code/espurna/relay.ino | 4 +--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/code/espurna/espurna.ino b/code/espurna/espurna.ino index e9174bba..e2a40bcd 100644 --- a/code/espurna/espurna.ino +++ b/code/espurna/espurna.ino @@ -20,6 +20,7 @@ along with this program. If not, see . */ #include "config/all.h" +#include // ----------------------------------------------------------------------------- // METHODS @@ -32,6 +33,7 @@ String getIdentifier() { } void hardwareSetup() { + EEPROM.begin(4096); Serial.begin(SERIAL_BAUDRATE); #if not EMBEDDED_WEB SPIFFS.begin(); @@ -53,6 +55,9 @@ void hardwareLoop() { DEBUG_MSG("[MAIN] Time: %s\n", (char *) NTP.getTimeDateString().c_str()); DEBUG_MSG("[MAIN] Uptime: %ld seconds\n", uptime_seconds); DEBUG_MSG("[MAIN] Free heap: %d bytes\n", ESP.getFreeHeap()); + #if ENABLE_VCC_REPORT + DEBUG_MSG("[MAIN] Power: %d mV\n", ESP.getVcc()); + #endif #if (MQTT_REPORTS | MQTT_STATUS_REPORT) mqttSend(MQTT_STATUS_TOPIC, "1"); @@ -67,9 +72,10 @@ void hardwareLoop() { mqttSend(MQTT_FREEHEAP_TOPIC, String(ESP.getFreeHeap()).c_str()); #endif #if (MQTT_REPORTS | MQTT_VCC_REPORT) - DEBUG_MSG("[BEAT] Power: %d mV\n", ESP.getVcc()); + #if ENABLE_VCC_REPORT mqttSend(MQTT_VCC_TOPIC, String(ESP.getVcc()).c_str()); #endif + #endif } diff --git a/code/espurna/relay.ino b/code/espurna/relay.ino index 230a14c6..cfa9379b 100644 --- a/code/espurna/relay.ino +++ b/code/espurna/relay.ino @@ -555,14 +555,12 @@ void relaySetup() { #endif - EEPROM.begin(4096); - byte relayMode = getSetting("relayMode", RELAY_MODE).toInt(); - #if RELAY_PROVIDER == RELAY_PROVIDER_MY9291 _my9291 = new my9291(MY9291_DI_PIN, MY9291_DCKI_PIN, MY9291_COMMAND); retrieveLightColor(); #endif + byte relayMode = getSetting("relayMode", RELAY_MODE).toInt(); for (unsigned int i=0; i < _relays.size(); i++) { pinMode(_relays[i].pin, OUTPUT); if (relayMode == RELAY_MODE_OFF) relayStatus(i, false);