fix(ui): OLED joystick rotation — enforce reset after prefs rd()

The previous fix set joystick_rotation=0 before reading from file, but
the subsequent rd() call overwrote it with whatever was stored (e.g. 2
from a prior e-ink firmware). Move the hardware-enforce block to after
rd() so stale values in flash are always corrected on OLED builds
(FEAT_JOYSTICK_ROTATION_SETTING=0). Remove the now-redundant pre-read
block.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Jakub
2026-05-27 23:47:30 +02:00
parent 82fa152a94
commit c92264c21e
2 changed files with 102 additions and 40 deletions

View File

@@ -209,14 +209,6 @@ void DataStore::loadPrefsInt(const char *filename, NodePrefs& _prefs, double& no
#ifdef DISPLAY_ROTATION
_prefs.display_rotation = DISPLAY_ROTATION;
#endif
#ifdef JOYSTICK_ROTATION
_prefs.joystick_rotation = JOYSTICK_ROTATION;
#elif !FEAT_JOYSTICK_ROTATION_SETTING
// OLED: no rotation setting in UI — always reset to 0 so stale e-ink prefs
// (which could have a non-zero value) don't silently reverse the joystick.
_prefs.joystick_rotation = 0;
#endif
File file = openRead(_fs, filename);
if (!file) return;
@@ -303,6 +295,13 @@ 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
_prefs.joystick_rotation = 0;
#endif
rd(&_prefs.eink_full_refresh_every, sizeof(_prefs.eink_full_refresh_every));
rd(&_prefs.page_order_set, sizeof(_prefs.page_order_set));
// Migration: pre-magic firmware wrote page_order without a flag. If we see a plausible