Skip to main content

Module nudge

Module nudge 

Source
Expand description

Live display nudge: tell a connected device “your dashboard changed, re-poll now” when its bound dashboard’s data updates (review gap #4).

TRMNL devices poll the node for their display image. Without a push signal, an edit (a new widget, fresh widget data, a builder change from the desktop) would only appear on the next poll — up to refresh_rate seconds late. This loop closes that gap: it subscribes to the dashboard store’s broadcast (the SAME stream the desktop Home grid reads over SSE) and, when a widget on a device-bound dashboard changes, sends the RHP display control message (RhpServerMsg::Display) over that device’s live WS so it re-polls promptly.

Cost discipline mirrors the dashboard refresh loop: the nudge is only sent to connected devices ([session::live::is_connected]), and it is debounced per device so a burst of widget updates collapses into one re-poll. The device still re-polls on its own refresh_rate cadence when offline, so a missed nudge is never a correctness problem — only a latency one.

Functions§

spawn
Spawn the hardware display-nudge loop. Call once at startup with the DashboardFeed (for change events + the device→dashboard bindings) and the device store (to resolve a device’s panel surface). No-op-cheap when no devices are bound.