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:
agessaman committed 2026-08-28 14:37:03 -07:00
1 parent 11d7551ccd
commit ca17c2980c
12 files changed
+120 -9

No files matched your search

+14
View File
@@ -266,6 +266,18 @@ bool CommonCLI::handleObserverSetCmd(uint32_t sender_timestamp, const char* conf
}
}
}
} else if (memcmp(config, "display.flip ", 13) == 0) {
const char* val = &config[13];
if (strcmp(val, "0") == 0 || strcmp(val, "off") == 0) {
_mqtt_prefs.display_flip = 0;
} else if (strcmp(val, "1") == 0 || strcmp(val, "on") == 0) {
_mqtt_prefs.display_flip = 1;
} else {
strcpy(reply, "Error: display.flip must be 0/1 (or off/on)");
return true;
}
if (!persistObserverPrefs(reply)) return true;
strcpy(reply, _mqtt_prefs.display_flip ? "OK - display rotated 180" : "OK - display upright");
} else if (memcmp(config, "display.timeout ", 16) == 0) {
const char* val = &config[16];
bool all_digits = (*val != '\0');
@@ -887,6 +899,8 @@ bool CommonCLI::handleObserverGetCmd(uint32_t sender_timestamp, const char* conf
sprintf(reply, "> %d", (uint32_t)_mqtt_prefs.radio_watchdog_minutes);
} else if (memcmp(config, "display.timeout", 15) == 0) {
sprintf(reply, "> %d", (uint32_t)_mqtt_prefs.display_timeout_secs);
} else if (memcmp(config, "display.flip", 12) == 0) {
strcpy(reply, _mqtt_prefs.display_flip ? "> on" : "> off");
#ifdef WITH_MQTT_BRIDGE
} else if (memcmp(config, "mqtt.origin", 11) == 0) {
char effective_origin[32];