From fee4182ffaae0afb88ce2348704378fc915bea82 Mon Sep 17 00:00:00 2001 From: Jakub <106778416+MarekZegare4@users.noreply.github.com> Date: Wed, 17 Jun 2026 21:35:30 +0200 Subject: [PATCH] fix(prefs): persist joystick rotation on e-ink builds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The joystick rotation setting never survived a reboot: loadPrefsInt cleared it on every load. The post-read override guarded on FEAT_JOYSTICK_ROTATION_SETTING (and JOYSTICK_ROTATION), but DataStore.cpp included neither Features.h nor the macro's header, so both were undefined — `#if !FEAT_JOYSTICK_ROTATION_SETTING` was always true and the stored value was forced back to 0 every time. Include Features.h so the flag resolves per build, and only force the default when the setting isn't user-editable (OLED). On e-ink the stored value is now kept; stale values migrated from another build are still corrected. Co-Authored-By: Claude Opus 4.8 --- examples/companion_radio/DataStore.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/examples/companion_radio/DataStore.cpp b/examples/companion_radio/DataStore.cpp index aa752c52..b5c46f96 100644 --- a/examples/companion_radio/DataStore.cpp +++ b/examples/companion_radio/DataStore.cpp @@ -1,5 +1,6 @@ #include #include "DataStore.h" +#include "Features.h" // FEAT_JOYSTICK_ROTATION_SETTING (else `#if !FEAT_…` is always true) #if defined(EXTRAFS) || defined(QSPIFLASH) #define MAX_BLOBRECS 100 @@ -296,11 +297,12 @@ void DataStore::loadPrefsInt(const char *filename, NodePrefs& _prefs, double& no rd(&_prefs.display_rotation, sizeof(_prefs.display_rotation)); rd(_prefs.page_order, sizeof(_prefs.page_order)); rd(&_prefs.joystick_rotation, sizeof(_prefs.joystick_rotation)); - // Override any stale stored value — must come AFTER rd() so files that already - // have the field (e.g. migrated from e-ink with rotation=2) are also corrected. -#ifdef JOYSTICK_ROTATION - _prefs.joystick_rotation = JOYSTICK_ROTATION; -#elif !FEAT_JOYSTICK_ROTATION_SETTING +#if !FEAT_JOYSTICK_ROTATION_SETTING + // No UI to change it on this build, so force the default — this also corrects + // a stale value migrated from another build (e.g. e-ink rotation=2). On builds + // that DO expose the setting the stored value is kept; the old code clobbered + // it unconditionally (FEAT_* was undefined here because Features.h wasn't + // included → `#if !FEAT_…` was always true), so the setting never persisted. _prefs.joystick_rotation = 0; #endif rd(&_prefs.eink_full_refresh_every, sizeof(_prefs.eink_full_refresh_every));