From ad9fd062a8ba34c17c1f3349739bb43fc8fe6b81 Mon Sep 17 00:00:00 2001 From: MangaValk Date: Wed, 4 Nov 2026 02:45:24 +0100 Subject: [PATCH] Stop reading the old settings format The display has stored its settings as version 8 since 2.22.0. Co-Authored-By: Claude Opus 5.5 --- src/esp32/config.h | 2 +- src/esp32/system/settings_store.cpp | 18 ++---------------- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/src/esp32/config.h b/src/esp32/config.h index 95ab195..a1871ac 100644 --- a/src/esp32/config.h +++ b/src/esp32/config.h @@ -118,7 +118,7 @@ const uint32_t SETUP_AP_DELAY = 20000; // open the AP when WiFi fails thi const uint32_t WIFI_CONNECT_TIMEOUT = 30000; const uint32_t WIFI_RESTART_TIME = 10UL * 60 * 1000; -#define FIRMWARE_VERSION "2.22.0" +#define FIRMWARE_VERSION "2.22.1" // Home Assistant device id (do not change: Home Assistant's entities are linked to it) const uint8_t HA_DEVICE_ID[] = {0x34, 0x86, 0x5d, 0x3a, 0x08, 0x28}; diff --git a/src/esp32/system/settings_store.cpp b/src/esp32/system/settings_store.cpp index c27a80a..ec7d48b 100644 --- a/src/esp32/system/settings_store.cpp +++ b/src/esp32/system/settings_store.cpp @@ -7,14 +7,9 @@ static const char *NAMESPACE = "flipdot"; static const char *KEY = "settings"; // Increase when the Settings struct changes; records of other versions are ignored -// (defaults). 2.15.0 stored all older records again in version 7. To keep the settings over -// a change, add a frozen copy of the old layout and convert it (see git history). +// (defaults). To keep the settings over a change, read or convert the old layout for one +// release (see git history: 2.22.0 read version 7, a prefix of version 8). static const uint16_t VERSION = 8; -// Version 7 is version 8 without random_effects at the end, so no frozen copy is needed. It -// becomes version 8 with the next save. Remove this once the device has saved. -static const uint16_t OLD_VERSION = 7; -static const size_t OLD_SIZE = offsetof(Settings, random_effects); -static_assert(alignof(Settings) == alignof(uint16_t), "no padding before random_effects"); struct StoredSettings { @@ -33,15 +28,6 @@ void loadSettings(Settings &settings) size_t read = prefs.getBytes(KEY, &stored, sizeof(stored)); prefs.end(); - if (read == offsetof(StoredSettings, settings) + OLD_SIZE && stored.version == OLD_VERSION && - stored.size == OLD_SIZE) - { - stored.settings.random_effects = RANDOM_EFFECTS_ALL; - if (validateSettings(stored.settings) == nullptr) - settings = stored.settings; - return; - } - if (read == offsetof(StoredSettings, settings) + sizeof(Settings) && stored.version == VERSION && stored.size == sizeof(Settings) && validateSettings(stored.settings) == nullptr) settings = stored.settings;