From 838c2c3b625bee3cfd52c5fcb646197fde66fc4b Mon Sep 17 00:00:00 2001 From: Bertrand Lemasle Date: Sun, 18 Mar 2018 12:00:39 +1300 Subject: [PATCH] Fixed maxEntryIndex being set to 6 as eeprom is not initialized on static init. --- GpsTracker/Positions.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/GpsTracker/Positions.cpp b/GpsTracker/Positions.cpp index 569b078..91d1015 100644 --- a/GpsTracker/Positions.cpp +++ b/GpsTracker/Positions.cpp @@ -26,7 +26,7 @@ namespace positions { #endif namespace details { - uint16_t maxEntryIndex = (E24_MAX_ADDRESS(hardware::i2c::eeprom.getSize()) - ENTRIES_ADDR) / ENTRY_RESERVED_SIZE; + uint16_t maxEntryIndex = 0; uint16_t getEntryAddress(uint16_t index) { if (index > maxEntryIndex) return -1; @@ -35,6 +35,7 @@ namespace positions { } void setup() { + details::maxEntryIndex = (E24_MAX_ADDRESS(hardware::i2c::eeprom.getSize()) - ENTRIES_ADDR) / ENTRY_RESERVED_SIZE; #ifdef BACKUPS_ENABLED uint8_t backupIdx = 0; _backups = new backup::PositionsBackup*[BACKUPS_ENABLED];