Files
Anthias/tests
Viktor Petersson a3aa63fa1a feat(viewer): blank/unblank commands to turn the display off (#3065)
* feat(viewer): add blank/unblank commands to turn the display off

Adds a way to blank the screen on demand, parallel to the existing
next/previous/stop/play viewer commands on the anthias.viewer Redis
channel:

* Wayland boards (x86/pi5/arm64): wlr-randr powers the connector off
  (true DPMS power-off) and back on. _wlr_output_names() gained an
  include_disabled flag so unblank can re-enable a connector that's
  currently Enabled: no.
* eglfs/linuxfb boards (pi2/pi3/pi4): the Qt app owns the DRM master
  and can't be powered off externally, so the asset loop paints a new
  all-black BLACK_SCREEN image instead (same proven loadImage path as
  the standby screen). Backlight stays on; the screen goes black.

blank_display() flips display_blanked + loop_is_stopped from the
subscriber thread and runs the out-of-process wlr-randr call there; the
webview repaint is deferred to the main loop thread (start_loop), which
owns current_browser_url — mirroring the existing rotation-bounce
threading discipline.

Validated live on x86 (wayland): `blank` -> DP-1 Enabled: no, `unblank`
-> Enabled: yes. eglfs black-paint reuses the standby loadImage path.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix(viewer): address review on display blanking (mypy, log spam, state)

- Import get_skip_event from anthias_viewer.utils in the test instead
  of via the viewer module, which doesn't explicitly re-export it
  (mypy attr-defined under --no-implicit-reexport).
- start_loop: guard the black repaint on current_browser_url so it
  doesn't re-call view_image() — and re-log "Current url ..." at INFO —
  on every 0.1s tick while blanked (Copilot).
- Route stop/play through module-level helpers that set the
  loop_is_stopped global start_loop actually reads; the prior
  setattr(__main__, ...) wrote a dead namespace under
  `python -m anthias_viewer` and never paused the loop. play now
  implies unblank when the display is blanked (Copilot).
- Add tests for stop flag + play-implies-unblank.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* chore(viewer): mark BLACK_SCREEN http URL safe for Sonar (S5332)

http is intentional — the viewer talks to the local anthias-server over
plain HTTP (TLS is the opt-in Caddy sidecar's job), identical to the
existing STANDBY_SCREEN / SPLASH_PAGE_URL. Annotate the line # NOSONAR,
the repo's documented convention for Sonar false positives under
Automatic Analysis (see sonar-project.properties; cf. test_csrf.py).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-11 11:50:54 +01:00
..