Skip to content

examples: add ClockKey DUI package and ClockController#382

Merged
Faerkeren merged 3 commits into
mainfrom
dui/examples
May 25, 2026
Merged

examples: add ClockKey DUI package and ClockController#382
Faerkeren merged 3 commits into
mainfrom
dui/examples

Conversation

@Faerkeren
Copy link
Copy Markdown
Contributor

Adds a new analog clock example to the streamdeck demo.

Changes

  • New DUI package examples/ClockKey.dui -- analog clock face with three transform-bound hands (hour_hand, minute_hand, second_hand), each mapped to a 0-360 degree rotation.
  • ClockController(KeyController) in examples/streamdeck.py:
    • Computes hand angles from local system time (6 deg/sec for the second hand, 6 deg/min for the minute hand, 0.5 deg/min for the hour hand).
    • Writes confirmed degree values through set_range(min_val=0, max_val=360) matching the manifest mapping.
    • Drives updates from a single 1Hz asyncio task started in on_attach and cancelled in on_detach (safe across reconnect cycles).
    • Only requests a refresh when an angle actually changes.
    • No backend service -- this is a pure display controller.
    • Logs press, release, click, hold events at INFO for live-device verification.
  • StreamDeckApp wiring:
    • New self._key_controllers: list[KeyController] so KeyController-derived controllers share the same uniform on_attach/on_detach lifecycle as cards.
    • _build_main_screen reserves key 0 for the clock, then lays favourites and scenes on the remaining keys (fixes a previous off-by-one in the favourite slot range).

Verification

  • ruff check clean.
  • mypy: no new errors (same 23 pre-existing errors as on main, all related to the CardController/KeyController 'Any base class' pattern shared by every controller in the file).
  • pytest tests/ --cov=deux --cov-fail-under=95: 1983 passed, coverage 95.61%.

Faerkeren added 3 commits May 25, 2026 12:26
Adds an analog clock key controller that drives the hour_hand and
minute_hand transform bindings from the system clock via a 1Hz tick
task. Angles are written through set_range over a 0--360 degree
domain matching the manifest. The controller is not yet attached to
any screen.
Updates ClockController to drive the new second_hand transform
binding at 6 deg/sec alongside the existing hour and minute hands,
sharing the same 0--360 degree set_range mapping.

Wires the clock onto key 0 of the Main screen, shifting favourites
and scenes onto the remaining keys. Adds a separate KeyController
lifecycle list on StreamDeckApp so the clock participates in the
uniform on_attach/on_detach flow across reconnects.
Adds passive INFO-level loggers for the four manifest input events on
the ClockKey so the wiring can be verified on a live device. The
handlers are observers only and do not mutate any binding.
Comment thread examples/streamdeck.py
if task is not None and not task.done():
task.cancel()
with contextlib.suppress(asyncio.CancelledError):
await task
@Faerkeren Faerkeren merged commit c9d5214 into main May 25, 2026
16 checks passed
@Faerkeren Faerkeren deleted the dui/examples branch May 25, 2026 15:58
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.

1 participant