Restore display orientation after Windows resume - #1069
Conversation
|
Quick update before merge: during continued hardware testing I found a rare long-hibernation resume case that I want to investigate before this PR is merged. After a ~26 hour hibernation, the display orientation and static content recovered correctly, and most live stats continued updating. However, CPU percentage and CPU frequency did not resume drawing and remained blank for more than an hour, while CPU temperature, GPU, RAM, network and disk stats continued working. The resume log itself looked normal and contained no COM/serial errors. I don't yet know whether this is caused by the changes in this PR or whether the new resume sequence is exposing an existing scheduler/LibreHardwareMonitor issue. I'd prefer to investigate and validate this case before merging. Please hold off on merging for now. I'll update the PR once I have identified the cause and tested the fix. |
Summary
On Windows, some displays can lose their configured orientation after sleep or hibernation and resume in the default orientation.
This was reproduced on a Turing Smart Screen 3.5" Rev. A using reversed portrait orientation.
The Windows resume handler currently calls
display.turn_on(), but orientation is only configured separately during initial display initialization. Rev. A also sendsSetOrientation()directly to the serial port instead of serializing it with the normal display command queue.This PR:
Reproduction
Before this change:
On affected resumes, the display controller can return in its default orientation while the monitoring process continues running. On Rev. A, restoring orientation immediately during resume can also race with queued display updates.
Why
After hibernation, the LCD controller may return to its default orientation while the application itself continues running.
Sending the orientation command immediately during resume can also race with queued redraw/sensor updates on Rev. A.
Serializing the orientation command and allowing the USB endpoint/queue to settle before redraw makes the resume sequence deterministic.
Hardware validation
Tested by Mugen Art Lab on:
DISPLAY_REVERSE: true)The final recovery sequence was exercised through repeated real-world hibernate/resume cycles, including multi-hour hibernation periods. Orientation, background/static content and live sensor updates recovered correctly after resume.
The final test run completed 6 consecutive long hibernate/resume cycles without an orientation failure or incomplete redraw.
Notes
The change is intentionally limited to resume/orientation recovery and does not modify theme configuration or sensor logic.