fix(prefs): persist joystick rotation on e-ink builds

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 <noreply@anthropic.com>
This commit is contained in:
Jakub
2026-06-17 21:35:30 +02:00
co-authored by Claude Opus 4.8
parent 7a1f19dd6f
commit fee4182ffa
+7 -5
View File
@@ -1,5 +1,6 @@
#include <Arduino.h> #include <Arduino.h>
#include "DataStore.h" #include "DataStore.h"
#include "Features.h" // FEAT_JOYSTICK_ROTATION_SETTING (else `#if !FEAT_…` is always true)
#if defined(EXTRAFS) || defined(QSPIFLASH) #if defined(EXTRAFS) || defined(QSPIFLASH)
#define MAX_BLOBRECS 100 #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.display_rotation, sizeof(_prefs.display_rotation));
rd(_prefs.page_order, sizeof(_prefs.page_order)); rd(_prefs.page_order, sizeof(_prefs.page_order));
rd(&_prefs.joystick_rotation, sizeof(_prefs.joystick_rotation)); rd(&_prefs.joystick_rotation, sizeof(_prefs.joystick_rotation));
// Override any stale stored value — must come AFTER rd() so files that already #if !FEAT_JOYSTICK_ROTATION_SETTING
// have the field (e.g. migrated from e-ink with rotation=2) are also corrected. // No UI to change it on this build, so force the default — this also corrects
#ifdef JOYSTICK_ROTATION // a stale value migrated from another build (e.g. e-ink rotation=2). On builds
_prefs.joystick_rotation = JOYSTICK_ROTATION; // that DO expose the setting the stored value is kept; the old code clobbered
#elif !FEAT_JOYSTICK_ROTATION_SETTING // 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; _prefs.joystick_rotation = 0;
#endif #endif
rd(&_prefs.eink_full_refresh_every, sizeof(_prefs.eink_full_refresh_every)); rd(&_prefs.eink_full_refresh_every, sizeof(_prefs.eink_full_refresh_every));