Browse Source

Fix settings report after factory reset

rfm69
Xose Pérez 6 years ago
parent
commit
f4513d2fe3
1 changed files with 4 additions and 1 deletions
  1. +4
    -1
      code/espurna/settings.ino

+ 4
- 1
code/espurna/settings.ino View File

@ -31,9 +31,10 @@ bool _settings_save = false;
unsigned long settingsSize() { unsigned long settingsSize() {
unsigned pos = SPI_FLASH_SEC_SIZE - 1; unsigned pos = SPI_FLASH_SEC_SIZE - 1;
while (size_t len = EEPROMr.read(pos)) { while (size_t len = EEPROMr.read(pos)) {
if (0xFF == len) break;
pos = pos - len - 2; pos = pos - len - 2;
} }
return SPI_FLASH_SEC_SIZE - pos;
return SPI_FLASH_SEC_SIZE - pos + EEPROM_DATA_END;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
@ -42,6 +43,7 @@ unsigned int settingsKeyCount() {
unsigned count = 0; unsigned count = 0;
unsigned pos = SPI_FLASH_SEC_SIZE - 1; unsigned pos = SPI_FLASH_SEC_SIZE - 1;
while (size_t len = EEPROMr.read(pos)) { while (size_t len = EEPROMr.read(pos)) {
if (0xFF == len) break;
pos = pos - len - 2; pos = pos - len - 2;
len = EEPROMr.read(pos); len = EEPROMr.read(pos);
pos = pos - len - 2; pos = pos - len - 2;
@ -57,6 +59,7 @@ String settingsKeyName(unsigned int index) {
unsigned count = 0; unsigned count = 0;
unsigned pos = SPI_FLASH_SEC_SIZE - 1; unsigned pos = SPI_FLASH_SEC_SIZE - 1;
while (size_t len = EEPROMr.read(pos)) { while (size_t len = EEPROMr.read(pos)) {
if (0xFF == len) break;
pos = pos - len - 2; pos = pos - len - 2;
if (count == index) { if (count == index) {
s.reserve(len); s.reserve(len);


Loading…
Cancel
Save