feat(display): add runtime display.flip for panel orientation
`set display.flip 0|1` (also off/on) turns the panel 180 degrees from its compiled DISPLAY_ROTATION, persisted in MQTTPrefs alongside display.timeout and applied live without a reboot. Adding 2 to the compiled rotation rather than setting an absolute value keeps portrait portrait and landscape landscape, so the DisplayViewport geometry never changes with it and the setting cannot produce a nonsensical mix. DisplayDriver gains a defaulted no-op setFlipped(), so no other display driver is affected. The compiled rotation was verified identical across `pio run` and `build.sh` on two machines (movi a11, 2 at the setRotation call site), yet the panel read upside down for one tester and upright for another - which is what a board mounted either way up looks like. No single compiled constant satisfies both, so orientation becomes a setting rather than another rebuild. Runtime-only, like display_timeout_secs: LegacyV1MQTTPrefs and the frozen binary payload sizes are untouched, and the JSON group is an append that older firmware skips.
This commit is contained in:
1 parent
11d7551ccd
commit
ca17c2980c
12 files changed
+120
-9
No files matched your search
@@ -31,6 +31,23 @@ static inline bool millisReached(unsigned long now, unsigned long deadline) {
|
||||
return (int32_t)((uint32_t)now - (uint32_t)deadline) >= 0;
|
||||
}
|
||||
|
||||
// Applies `display.flip` when it changes, forcing a complete repaint because
|
||||
// the panel's existing contents are now the wrong way up.
|
||||
void UITask::applyDisplayFlip() {
|
||||
#ifdef WITH_MQTT_BRIDGE
|
||||
if (_observer_prefs == NULL || _observer_prefs->display_flip == _flip_seen) return;
|
||||
_flip_seen = _observer_prefs->display_flip;
|
||||
_display->setFlipped(_flip_seen != 0);
|
||||
#ifdef DISPLAY_REDRAW_ON_CHANGE
|
||||
_frame_valid = false;
|
||||
#endif
|
||||
#ifdef DISPLAY_ACTIVITY_DASHBOARD
|
||||
_rows_valid = false;
|
||||
#endif
|
||||
_next_refresh = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
// `display.timeout` when the observer prefs are available, otherwise the
|
||||
// compiled-in default. Read on every use so a `set display.timeout` takes
|
||||
// effect immediately.
|
||||
@@ -68,6 +85,7 @@ void UITask::begin(NodePrefs* node_prefs, const char* build_date, const char* fi
|
||||
ObserverDashboard::applyDarkPalette(); // retunes UIColor for this target only
|
||||
#endif
|
||||
_display->turnOn();
|
||||
applyDisplayFlip();
|
||||
#ifdef DISPLAY_TOUCH_TOGGLE
|
||||
_touch.begin();
|
||||
#endif
|
||||
@@ -386,6 +404,7 @@ void UITask::loop() {
|
||||
// `_auto_off` is only armed on activity, so a timeout changed at runtime has
|
||||
// to restart the countdown here - otherwise 0 -> 60 blanks instantly off a
|
||||
// boot-time deadline, and 60 -> 3600 still blanks at the old 60 s mark.
|
||||
applyDisplayFlip();
|
||||
unsigned long timeout = displayTimeoutMillis();
|
||||
if (timeout != _timeout_seen) {
|
||||
_timeout_seen = timeout;
|
||||
|
||||
Reference in new issue
Block a user