diff --git a/README.md b/README.md
index b5d79f23..34726bc4 100644
--- a/README.md
+++ b/README.md
@@ -4,9 +4,9 @@ ESPurna ("spark" in Catalan) is a custom firmware for ESP8285/ESP8266 based smar
It uses the Arduino Core for ESP8266 framework and a number of 3rd party libraries.
[![version](https://img.shields.io/badge/version-1.12.7a-brightgreen.svg)](CHANGELOG.md)
-[![branch](https://img.shields.io/badge/branch-dev-orange.svg)](https://github.org/xoseperez/espurna/tree/dev/)
-[![travis](https://travis-ci.org/xoseperez/espurna.svg?branch=dev)](https://travis-ci.org/xoseperez/espurna)
-[![codacy](https://img.shields.io/codacy/grade/c9496e25cf07434cba786b462cb15f49/dev.svg)](https://www.codacy.com/app/xoseperez/espurna/dashboard)
+[![branch](https://img.shields.io/badge/branch-eeprom_rotate-orange.svg)](https://github.org/xoseperez/espurna/tree/eeprom_rotate/)
+[![travis](https://travis-ci.org/xoseperez/espurna.svg?branch=eeprom_rotate)](https://travis-ci.org/xoseperez/espurna)
+[![codacy](https://img.shields.io/codacy/grade/c9496e25cf07434cba786b462cb15f49/eeprom_rotate.svg)](https://www.codacy.com/app/xoseperez/espurna/dashboard)
[![license](https://img.shields.io/github/license/xoseperez/espurna.svg)](LICENSE)
[![donate](https://img.shields.io/badge/donate-PayPal-blue.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=xose%2eperez%40gmail%2ecom&lc=US&no_note=0¤cy_code=EUR&bn=PP%2dDonationsBF%3abtn_donate_LG%2egif%3aNonHostedGuest)
diff --git a/code/espurna/config/general.h b/code/espurna/config/general.h
index 2ca143ab..8a8723fc 100644
--- a/code/espurna/config/general.h
+++ b/code/espurna/config/general.h
@@ -147,7 +147,8 @@
#define EEPROM_CUSTOM_RESET 5 // Address for the reset reason (1 byte)
#define EEPROM_CRASH_COUNTER 6 // Address for the crash counter (1 byte)
#define EEPROM_MESSAGE_ID 7 // Address for the MQTT message id (4 bytes)
-#define EEPROM_DATA_END 11 // End of custom EEPROM data block
+#define EEPROM_ROTATE_DATA 11 // Reserved for the EEPROM_ROTATE library (3 bytes)
+#define EEPROM_DATA_END 14 // End of custom EEPROM data block
//------------------------------------------------------------------------------
// HEARTBEAT
@@ -1152,13 +1153,13 @@
#if IR_BUTTON_SET == 3
/*
+------+------+------+
- | 1 | 2 | 3 |
+ | 1 | 2 | 3 |
+------+------+------+
- | 4 | 5 | 6 |
+ | 4 | 5 | 6 |
+------+------+------+
- | 7 | 8 | 9 |
+ | 7 | 8 | 9 |
+------+------+------+
- | | 0 | |
+ | | 0 | |
+------+------+------+
*/
#define IR_BUTTON_COUNT 10
@@ -1168,7 +1169,7 @@
{ 0xE0E020DF, IR_BUTTON_MODE_TOGGLE, 0 }, // Toggle Relay #0
{ 0xE0E0A05F, IR_BUTTON_MODE_TOGGLE, 1 }, // Toggle Relay #1
{ 0xE0E0609F, IR_BUTTON_MODE_TOGGLE, 2 }, // Toggle Relay #2
-
+
{ 0xE0E010EF, IR_BUTTON_MODE_TOGGLE, 3 }, // Toggle Relay #3
{ 0xE0E0906F, IR_BUTTON_MODE_TOGGLE, 4 }, // Toggle Relay #4
{ 0xE0E050AF, IR_BUTTON_MODE_TOGGLE, 5 }, // Toggle Relay #5
diff --git a/code/espurna/config/prototypes.h b/code/espurna/config/prototypes.h
index 2a581218..317d46f5 100644
--- a/code/espurna/config/prototypes.h
+++ b/code/espurna/config/prototypes.h
@@ -7,6 +7,12 @@ extern "C" {
#include "user_interface.h"
}
+// -----------------------------------------------------------------------------
+// EEPROM_ROTATE
+// -----------------------------------------------------------------------------
+#include
+EEPROM_Rotate EEPROMr;
+
// -----------------------------------------------------------------------------
// WebServer
// -----------------------------------------------------------------------------
diff --git a/code/espurna/debug.ino b/code/espurna/debug.ino
index e7659693..8045e5d8 100644
--- a/code/espurna/debug.ino
+++ b/code/espurna/debug.ino
@@ -10,7 +10,7 @@ Copyright (C) 2016-2018 by Xose Pérez
#include
#include
-#include
+#include
extern "C" {
#include "user_interface.h"
@@ -204,31 +204,31 @@ extern "C" void custom_crash_callback(struct rst_info * rst_info, uint32_t stack
// write crash time to EEPROM
uint32_t crash_time = millis();
- EEPROM.put(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_CRASH_TIME, crash_time);
+ EEPROMr.put(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_CRASH_TIME, crash_time);
// write reset info to EEPROM
- EEPROM.write(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_RESTART_REASON, rst_info->reason);
- EEPROM.write(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_EXCEPTION_CAUSE, rst_info->exccause);
+ EEPROMr.write(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_RESTART_REASON, rst_info->reason);
+ EEPROMr.write(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_EXCEPTION_CAUSE, rst_info->exccause);
// write epc1, epc2, epc3, excvaddr and depc to EEPROM
- EEPROM.put(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_EPC1, rst_info->epc1);
- EEPROM.put(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_EPC2, rst_info->epc2);
- EEPROM.put(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_EPC3, rst_info->epc3);
- EEPROM.put(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_EXCVADDR, rst_info->excvaddr);
- EEPROM.put(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_DEPC, rst_info->depc);
+ EEPROMr.put(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_EPC1, rst_info->epc1);
+ EEPROMr.put(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_EPC2, rst_info->epc2);
+ EEPROMr.put(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_EPC3, rst_info->epc3);
+ EEPROMr.put(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_EXCVADDR, rst_info->excvaddr);
+ EEPROMr.put(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_DEPC, rst_info->depc);
// write stack start and end address to EEPROM
- EEPROM.put(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_STACK_START, stack_start);
- EEPROM.put(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_STACK_END, stack_end);
+ EEPROMr.put(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_STACK_START, stack_start);
+ EEPROMr.put(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_STACK_END, stack_end);
// write stack trace to EEPROM
int16_t current_address = SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_STACK_TRACE;
for (uint32_t i = stack_start; i < stack_end; i++) {
byte* byteValue = (byte*) i;
- EEPROM.write(current_address++, *byteValue);
+ EEPROMr.write(current_address++, *byteValue);
}
- EEPROM.commit();
+ EEPROMr.commit();
}
@@ -237,8 +237,8 @@ extern "C" void custom_crash_callback(struct rst_info * rst_info, uint32_t stack
*/
void debugClearCrashInfo() {
uint32_t crash_time = 0xFFFFFFFF;
- EEPROM.put(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_CRASH_TIME, crash_time);
- EEPROM.commit();
+ EEPROMr.put(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_CRASH_TIME, crash_time);
+ EEPROMr.commit();
}
/**
@@ -247,28 +247,28 @@ void debugClearCrashInfo() {
void debugDumpCrashInfo() {
uint32_t crash_time;
- EEPROM.get(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_CRASH_TIME, crash_time);
+ EEPROMr.get(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_CRASH_TIME, crash_time);
if ((crash_time == 0) || (crash_time == 0xFFFFFFFF)) {
DEBUG_MSG_P(PSTR("[DEBUG] No crash info\n"));
return;
}
DEBUG_MSG_P(PSTR("[DEBUG] Latest crash was at %lu ms after boot\n"), crash_time);
- DEBUG_MSG_P(PSTR("[DEBUG] Reason of restart: %u\n"), EEPROM.read(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_RESTART_REASON));
- DEBUG_MSG_P(PSTR("[DEBUG] Exception cause: %u\n"), EEPROM.read(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_EXCEPTION_CAUSE));
+ DEBUG_MSG_P(PSTR("[DEBUG] Reason of restart: %u\n"), EEPROMr.read(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_RESTART_REASON));
+ DEBUG_MSG_P(PSTR("[DEBUG] Exception cause: %u\n"), EEPROMr.read(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_EXCEPTION_CAUSE));
uint32_t epc1, epc2, epc3, excvaddr, depc;
- EEPROM.get(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_EPC1, epc1);
- EEPROM.get(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_EPC2, epc2);
- EEPROM.get(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_EPC3, epc3);
- EEPROM.get(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_EXCVADDR, excvaddr);
- EEPROM.get(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_DEPC, depc);
+ EEPROMr.get(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_EPC1, epc1);
+ EEPROMr.get(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_EPC2, epc2);
+ EEPROMr.get(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_EPC3, epc3);
+ EEPROMr.get(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_EXCVADDR, excvaddr);
+ EEPROMr.get(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_DEPC, depc);
DEBUG_MSG_P(PSTR("[DEBUG] epc1=0x%08x epc2=0x%08x epc3=0x%08x\n"), epc1, epc2, epc3);
DEBUG_MSG_P(PSTR("[DEBUG] excvaddr=0x%08x depc=0x%08x\n"), excvaddr, depc);
uint32_t stack_start, stack_end;
- EEPROM.get(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_STACK_START, stack_start);
- EEPROM.get(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_STACK_END, stack_end);
+ EEPROMr.get(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_STACK_START, stack_start);
+ EEPROMr.get(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_STACK_END, stack_end);
DEBUG_MSG_P(PSTR("[DEBUG] >>>stack>>>\n[DEBUG] "));
int16_t current_address = SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_STACK_TRACE;
int16_t stack_len = stack_end - stack_start;
@@ -276,7 +276,7 @@ void debugDumpCrashInfo() {
for (int16_t i = 0; i < stack_len; i += 0x10) {
DEBUG_MSG_P(PSTR("%08x: "), stack_start + i);
for (byte j = 0; j < 4; j++) {
- EEPROM.get(current_address, stack_trace);
+ EEPROMr.get(current_address, stack_trace);
DEBUG_MSG_P(PSTR("%08x "), stack_trace);
current_address += 4;
}
diff --git a/code/espurna/mqtt.ino b/code/espurna/mqtt.ino
index b74be3f8..603523b3 100644
--- a/code/espurna/mqtt.ino
+++ b/code/espurna/mqtt.ino
@@ -8,7 +8,7 @@ Copyright (C) 2016-2018 by Xose Pérez
#if MQTT_SUPPORT
-#include
+#include
#include
#include
#include
@@ -258,7 +258,7 @@ unsigned long _mqttNextMessageId() {
if (id == 0) {
// read id from EEPROM and shift it
- id = EEPROM.read(EEPROM_MESSAGE_ID);
+ id = EEPROMr.read(EEPROM_MESSAGE_ID);
if (id == 0xFF) {
// There was nothing in EEPROM,
@@ -267,9 +267,9 @@ unsigned long _mqttNextMessageId() {
} else {
- id = (id << 8) + EEPROM.read(EEPROM_MESSAGE_ID + 1);
- id = (id << 8) + EEPROM.read(EEPROM_MESSAGE_ID + 2);
- id = (id << 8) + EEPROM.read(EEPROM_MESSAGE_ID + 3);
+ id = (id << 8) + EEPROMr.read(EEPROM_MESSAGE_ID + 1);
+ id = (id << 8) + EEPROMr.read(EEPROM_MESSAGE_ID + 2);
+ id = (id << 8) + EEPROMr.read(EEPROM_MESSAGE_ID + 3);
// Calculate next block and start from there
id = MQTT_MESSAGE_ID_SHIFT * (1 + (id / MQTT_MESSAGE_ID_SHIFT));
@@ -280,11 +280,11 @@ unsigned long _mqttNextMessageId() {
// Save to EEPROM every MQTT_MESSAGE_ID_SHIFT
if (id % MQTT_MESSAGE_ID_SHIFT == 0) {
- EEPROM.write(EEPROM_MESSAGE_ID + 0, (id >> 24) & 0xFF);
- EEPROM.write(EEPROM_MESSAGE_ID + 1, (id >> 16) & 0xFF);
- EEPROM.write(EEPROM_MESSAGE_ID + 2, (id >> 8) & 0xFF);
- EEPROM.write(EEPROM_MESSAGE_ID + 3, (id >> 0) & 0xFF);
- EEPROM.commit();
+ EEPROMr.write(EEPROM_MESSAGE_ID + 0, (id >> 24) & 0xFF);
+ EEPROMr.write(EEPROM_MESSAGE_ID + 1, (id >> 16) & 0xFF);
+ EEPROMr.write(EEPROM_MESSAGE_ID + 2, (id >> 8) & 0xFF);
+ EEPROMr.write(EEPROM_MESSAGE_ID + 3, (id >> 0) & 0xFF);
+ EEPROMr.commit();
}
id++;
diff --git a/code/espurna/relay.ino b/code/espurna/relay.ino
index 2e7fd5d1..ca3062af 100644
--- a/code/espurna/relay.ino
+++ b/code/espurna/relay.ino
@@ -6,7 +6,7 @@ Copyright (C) 2016-2018 by Xose Pérez
*/
-#include
+#include
#include
#include
#include
@@ -357,9 +357,9 @@ void relaySave() {
if (relayStatus(i)) mask += bit;
bit += bit;
}
- EEPROM.write(EEPROM_RELAY_STATUS, mask);
+ EEPROMr.write(EEPROM_RELAY_STATUS, mask);
DEBUG_MSG_P(PSTR("[RELAY] Saving mask: %d\n"), mask);
- EEPROM.commit();
+ EEPROMr.commit();
}
void relayToggle(unsigned char id, bool report, bool group_report) {
@@ -437,7 +437,7 @@ void _relayBoot() {
bool trigger_save = false;
// Get last statuses from EEPROM
- unsigned char mask = EEPROM.read(EEPROM_RELAY_STATUS);
+ unsigned char mask = EEPROMr.read(EEPROM_RELAY_STATUS);
DEBUG_MSG_P(PSTR("[RELAY] Retrieving mask: %d\n"), mask);
// Walk the relays
@@ -474,8 +474,8 @@ void _relayBoot() {
// Save if there is any relay in the RELAY_BOOT_TOGGLE mode
if (trigger_save) {
- EEPROM.write(EEPROM_RELAY_STATUS, mask);
- EEPROM.commit();
+ EEPROMr.write(EEPROM_RELAY_STATUS, mask);
+ EEPROMr.commit();
}
_relayRecursive = false;
diff --git a/code/espurna/settings.ino b/code/espurna/settings.ino
index ce98370a..29576a50 100644
--- a/code/espurna/settings.ino
+++ b/code/espurna/settings.ino
@@ -6,7 +6,7 @@ Copyright (C) 2016-2018 by Xose Pérez
*/
-#include
+#include
#include
#include "libs/EmbedisWrap.h"
#include
@@ -30,7 +30,7 @@ bool _settings_save = false;
unsigned long settingsSize() {
unsigned pos = SPI_FLASH_SEC_SIZE - 1;
- while (size_t len = EEPROM.read(pos)) {
+ while (size_t len = EEPROMr.read(pos)) {
pos = pos - len - 2;
}
return SPI_FLASH_SEC_SIZE - pos;
@@ -41,9 +41,9 @@ unsigned long settingsSize() {
unsigned int _settingsKeyCount() {
unsigned count = 0;
unsigned pos = SPI_FLASH_SEC_SIZE - 1;
- while (size_t len = EEPROM.read(pos)) {
+ while (size_t len = EEPROMr.read(pos)) {
pos = pos - len - 2;
- len = EEPROM.read(pos);
+ len = EEPROMr.read(pos);
pos = pos - len - 2;
count ++;
}
@@ -56,17 +56,17 @@ String _settingsKeyName(unsigned int index) {
unsigned count = 0;
unsigned pos = SPI_FLASH_SEC_SIZE - 1;
- while (size_t len = EEPROM.read(pos)) {
+ while (size_t len = EEPROMr.read(pos)) {
pos = pos - len - 2;
if (count == index) {
s.reserve(len);
for (unsigned char i = 0 ; i < len; i++) {
- s += (char) EEPROM.read(pos + i + 1);
+ s += (char) EEPROMr.read(pos + i + 1);
}
break;
}
count++;
- len = EEPROM.read(pos);
+ len = EEPROMr.read(pos);
pos = pos - len - 2;
}
@@ -162,21 +162,13 @@ void _settingsKeysCommand() {
void _settingsFactoryResetCommand() {
for (unsigned int i = 0; i < SPI_FLASH_SEC_SIZE; i++) {
- EEPROM.write(i, 0xFF);
+ EEPROMr.write(i, 0xFF);
}
- EEPROM.commit();
+ EEPROMr.commit();
}
-void _settingsDumpCommand(bool ascii) {
- for (unsigned int i = 0; i < SPI_FLASH_SEC_SIZE; i++) {
- if (i % 16 == 0) DEBUG_MSG_P(PSTR("\n[%04X] "), i);
- byte c = EEPROM.read(i);
- if (ascii && 32 <= c && c <= 126) {
- DEBUG_MSG_P(PSTR(" %c "), c);
- } else {
- DEBUG_MSG_P(PSTR("%02X "), c);
- }
- }
+void _settingsDumpCommand() {
+ EEPROMr.dump(_serial);
}
void _settingsInitCommands() {
@@ -195,9 +187,7 @@ void _settingsInitCommands() {
});
settingsRegisterCommand(F("EEPROM.DUMP"), [](Embedis* e) {
- bool ascii = false;
- if (e->argc == 2) ascii = String(e->argv[1]).toInt() == 1;
- _settingsDumpCommand(ascii);
+ _settingsDumpCommand();
DEBUG_MSG_P(PSTR("\n+OK\n"));
});
@@ -275,7 +265,7 @@ void _settingsInitCommands() {
});
settingsRegisterCommand(F("RESET.SAFE"), [](Embedis* e) {
- EEPROM.write(EEPROM_CRASH_COUNTER, SYSTEM_CHECK_MAX);
+ EEPROMr.write(EEPROM_CRASH_COUNTER, SYSTEM_CHECK_MAX);
DEBUG_MSG_P(PSTR("+OK\n"));
deferredReset(100, CUSTOM_RESET_TERMINAL);
});
@@ -366,7 +356,7 @@ bool settingsRestoreJson(JsonObject& data) {
if (strcmp(app, APP_NAME) != 0) return false;
for (unsigned int i = EEPROM_DATA_END; i < SPI_FLASH_SEC_SIZE; i++) {
- EEPROM.write(i, 0xFF);
+ EEPROMr.write(i, 0xFF);
}
for (auto element : data) {
@@ -405,7 +395,7 @@ void settingsRegisterCommand(const String& name, void (*call)(Embedis*)) {
void settingsSetup() {
- EEPROM.begin(SPI_FLASH_SEC_SIZE);
+ EEPROMr.begin(SPI_FLASH_SEC_SIZE);
_serial.callback([](uint8_t ch) {
#if TELNET_SUPPORT
@@ -418,8 +408,8 @@ void settingsSetup() {
Embedis::dictionary( F("EEPROM"),
SPI_FLASH_SEC_SIZE,
- [](size_t pos) -> char { return EEPROM.read(pos); },
- [](size_t pos, char value) { EEPROM.write(pos, value); },
+ [](size_t pos) -> char { return EEPROMr.read(pos); },
+ [](size_t pos, char value) { EEPROMr.write(pos, value); },
#if SETTINGS_AUTOSAVE
[]() { _settings_save = true; }
#else
@@ -443,7 +433,7 @@ void settingsSetup() {
void settingsLoop() {
if (_settings_save) {
- EEPROM.commit();
+ EEPROMr.commit();
_settings_save = false;
}
diff --git a/code/espurna/system.ino b/code/espurna/system.ino
index fb1d1ed0..4c019254 100644
--- a/code/espurna/system.ino
+++ b/code/espurna/system.ino
@@ -6,7 +6,7 @@ Copyright (C) 2018 by Xose Pérez
*/
-#include
+#include
// -----------------------------------------------------------------------------
@@ -30,7 +30,7 @@ unsigned short int _load_average = 100;
bool _systemStable = true;
void systemCheck(bool stable) {
- unsigned char value = EEPROM.read(EEPROM_CRASH_COUNTER);
+ unsigned char value = EEPROMr.read(EEPROM_CRASH_COUNTER);
if (stable) {
value = 0;
DEBUG_MSG_P(PSTR("[MAIN] System OK\n"));
@@ -41,8 +41,8 @@ void systemCheck(bool stable) {
DEBUG_MSG_P(PSTR("[MAIN] System UNSTABLE\n"));
}
}
- EEPROM.write(EEPROM_CRASH_COUNTER, value);
- EEPROM.commit();
+ EEPROMr.write(EEPROM_CRASH_COUNTER, value);
+ EEPROMr.commit();
}
bool systemCheck() {
@@ -148,7 +148,17 @@ void _systemSetupSpecificHardware() {
void systemSetup() {
- EEPROM.begin(EEPROM_SIZE);
+ uint8_t sectors = 0;
+ if (EEPROMr.last() > 1000) { // 4Mb boards
+ sectors = 4;
+ } else if (EEPROMr.last() > 250) { // 1Mb boards
+ sectors = 2;
+ } else {
+ sectors = 1;
+ }
+ EEPROMr.offset(EEPROM_ROTATE_DATA);
+ EEPROMr.rotate(sectors);
+ EEPROMr.begin(EEPROM_SIZE);
#if SPIFFS_SUPPORT
SPIFFS.begin();
diff --git a/code/espurna/utils.ino b/code/espurna/utils.ino
index 7eaee736..5bc955b2 100644
--- a/code/espurna/utils.ino
+++ b/code/espurna/utils.ino
@@ -508,7 +508,7 @@ bool sslFingerPrintChar(const char * fingerprint, char * destination) {
unsigned char resetReason() {
static unsigned char status = 255;
if (status == 255) {
- status = EEPROM.read(EEPROM_CUSTOM_RESET);
+ status = EEPROMr.read(EEPROM_CUSTOM_RESET);
if (status > 0) resetReason(0);
if (status > CUSTOM_RESET_MAX) status = 0;
}
@@ -516,8 +516,8 @@ unsigned char resetReason() {
}
void resetReason(unsigned char reason) {
- EEPROM.write(EEPROM_CUSTOM_RESET, reason);
- EEPROM.commit();
+ EEPROMr.write(EEPROM_CUSTOM_RESET, reason);
+ EEPROMr.commit();
}
void reset(unsigned char reason) {
diff --git a/code/platformio.ini b/code/platformio.ini
index 384223a2..eb0dec97 100644
--- a/code/platformio.ini
+++ b/code/platformio.ini
@@ -35,7 +35,7 @@ debug_flags = -DDEBUG_ESP_CORE -DDEBUG_ESP_SSL -DDEBUG_ESP_WIFI -DDEBUG_ESP_HTTP
# -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY v2 Lower Memory
# -DPIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH v2 Higher Bandwidth
# ------------------------------------------------------------------------------
-build_flags = -g -DMQTT_MAX_PACKET_SIZE=400 ${env.ESPURNA_FLAGS} -DPIO_FRAMEWORK_ARDUINO_LWIP_HIGHER_BANDWIDTH
+build_flags = -g -DMQTT_MAX_PACKET_SIZE=400 -DNO_GLOBAL_EEPROM ${env.ESPURNA_FLAGS} -DPIO_FRAMEWORK_ARDUINO_LWIP_HIGHER_BANDWIDTH
build_flags_512k = ${common.build_flags} -Wl,-Tesp8266.flash.512k0.ld
build_flags_1m = ${common.build_flags} -Wl,-Tesp8266.flash.1m0.ld
@@ -57,6 +57,7 @@ lib_deps =
https://github.com/marvinroger/async-mqtt-client#v0.8.1
Brzo I2C
https://bitbucket.org/xoseperez/debounceevent.git#2.0.1
+ https://github.com/xoseperez/eeprom_rotate
Embedis
https://github.com/plerup/espsoftwareserial#3.4.1
https://github.com/me-no-dev/ESPAsyncTCP#55cd520