Skip to content

fix: power the X4 Pro panel off before every restart - #67

Merged
prokrypt merged 1 commit into
developmentfrom
fix/x4-pro-restart-panel-off
Sep 30, 2026
Merged

prokrypt merged 1 commit into
developmentfrom
fix/x4-pro-restart-panel-off

Conversation

@prokrypt

Copy link
Copy Markdown
Owner

Before: the panel stays powered between refreshes, and esp_restart() (silent restart after Wi-Fi, OTA, SD firmware update) left the booster on until the reset.

After: on the X4 Pro, a shutdown handler runs the panel deep sleep (POF + DSLP) before every restart and logs "Panel powered off before restart".

How: esp_register_shutdown_handler is called after display.begin(). The handler takes the render lock with a bounded 3 s wait, or proceeds when the calling task already holds it, so it cannot deadlock or cut a refresh short. On timeout it skips the power-off and logs an error. RenderLock gains a timeout constructor and heldByCaller(). Same approach as CrossDink 5fb93c4 + 4341c90.

It is X4 Pro only (FREEINK_DEVICE_X4PRO):

  • On the X4 and Sticky, the SD card shares the display SPI bus, so the handler's bus lock could block behind an SD transfer.
  • An X3 silent restart trusts controller RAM for its first differential paint, and deep sleep would discard that RAM.
  • On the X4 Pro, begin() re-inits the controller and the first paint after boot is non-differential on both SSD1677 and UC8179 panels.

Sizes vs development 2dc4839 (static RAM unchanged on both):

  • C3 (default): flash +80 B (6,296,057 → 6,296,137), mostly the longer branch name in the build info; the handler compiles out. RAM 65,232 → 65,232
  • x4-pro-light-sleep: flash +296 B (5,600,829 → 5,601,125), RAM 118,452 → 118,452

Verify on hardware: on an X4 Pro, run an SD firmware update or an OTA. The log should show "Panel powered off before restart" right before the reset, and the next boot should paint normally.

🤖 Generated with Claude Code

https://claude.ai/code/session_01XgLRarbAmBVepTPKCK7mgd


Generated by Claude Code

The panel stays powered between refreshes, and esp_restart() (silent
restart, OTA, SD update) left the booster on until the reset. A shutdown
handler takes the render lock (bounded 3 s, or proceeds when the caller
already holds it) and runs the panel deep sleep (POF + DSLP) first.
X4 Pro only: SDMMC keeps SD traffic off the display SPI bus, so the bus
lock cannot block the handler; the X3 seamless restart also relies on
controller RAM that deep sleep would discard.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XgLRarbAmBVepTPKCK7mgd
@prokrypt
prokrypt merged commit 05c554b into development Sep 30, 2026
12 checks passed
@prokrypt
prokrypt deleted the fix/x4-pro-restart-panel-off branch September 30, 2026 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants