feat: add runtime display rotation setting for e-ink builds

Adds Settings > Display > Rotation (0°/90°/180°/270°) that persists to
NodePrefs and is applied on startup. Falls back to compile-time
DISPLAY_ROTATION when the field is missing from an older prefs file.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Jakub
2026-05-22 09:58:33 +02:00
co-authored by Claude Sonnet 4.6
parent cffe960f3f
commit 6a3b8e3135
8 changed files with 51 additions and 1 deletions
@@ -15,6 +15,9 @@ class SettingsScreen : public UIScreen {
CLOCK_SECONDS,
CLOCK_FORMAT,
FONT,
#if defined(EINK_DISPLAY_MODEL)
ROTATION,
#endif
// Sound section
SECTION_SOUND,
BUZZER,
@@ -321,6 +324,14 @@ class SettingsScreen : public UIScreen {
display.print("Font");
display.setCursor(VAL_X, y);
display.print((p && p->use_lemon_font) ? "Lemon" : "Default");
#if defined(EINK_DISPLAY_MODEL)
} else if (item == ROTATION) {
display.print("Rotation");
display.setCursor(VAL_X, y);
{ static const char* ROT_LABELS[] = { "0deg", "90deg", "180deg", "270deg" };
uint8_t r = p ? (p->display_rotation & 3) : 0;
display.print(ROT_LABELS[r]); }
#endif
} else if (item == DM_FILTER) {
display.print("DM");
display.setCursor(VAL_X, y);
@@ -517,6 +528,14 @@ public:
_dirty = true;
return true;
}
#if defined(EINK_DISPLAY_MODEL)
if (_selected == ROTATION && p && (left || right || enter)) {
p->display_rotation = (p->display_rotation + (left ? 3 : 1)) & 3;
_task->applyRotation();
_dirty = true;
return true;
}
#endif
if (_selected == DM_FILTER && p && (left || right || enter)) {
p->dm_show_all = p->dm_show_all ? 0 : 1;
_dirty = true;
@@ -817,6 +817,7 @@ void UITask::begin(DisplayDriver* display, SensorManager* sensors, NodePrefs* no
applyBrightness();
applyFont();
applyRotation();
}
void UITask::gotoSettingsScreen() {
@@ -1565,6 +1566,13 @@ void UITask::applyFont() {
}
}
void UITask::applyRotation() {
if (_display != NULL && _node_prefs != NULL) {
_display->setDisplayRotation(_node_prefs->display_rotation);
_next_refresh = 0;
}
}
void UITask::setBrightnessLevel(uint8_t level) {
if (_node_prefs == NULL) return;
if (level > 4) level = 4;
+1
View File
@@ -159,6 +159,7 @@ public:
void applyTxPower();
void applyGPSInterval();
void applyFont();
void applyRotation();
uint32_t autoOffMillis() const {
if (!_node_prefs || _node_prefs->auto_off_secs == 0) return 0;
return (uint32_t)_node_prefs->auto_off_secs * 1000UL;