mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-07-26 14:58:12 +00:00
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:
@@ -1,5 +1,6 @@
|
||||
#include <Arduino.h>
|
||||
#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));
|
||||
|
||||
Reference in New Issue
Block a user