hyderhusainarastu/hardware-mod-toolkit/device-companion-dashboard

Claude Code and agent skill by hyderhusainarastu/hardware-mod-toolkit

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Build a host-side dashboard that renders to a small 1 or 2 bpp device panel: image and text rendering, dirty-rectangle partial refresh, YAML widget config, presets, one-shot notifications. Use when driving a small device display from a host or when panel updates are slow or garbled.

Install

npx vskill@latest install hyderhusainarastu/hardware-mod-toolkit/device-companion-dashboard

SKILL.md

The same SKILL.md was published earlier as hyderhusainarastu/hardware-mod-toolkit/device-companion-dashboard.

Device companion dashboard

Turning a device panel into a useful companion display is mostly two engineering problems: getting readable output out of a 1-bit (or few-level) panel, and not re-sending the whole framebuffer every cycle. The worked example (<REPO>, a 240x80 1bpp panel over a per-byte I2C link) measured a full refresh at ~220 ms (2412 I2C transactions, ~91 µs each) and a realistic dirty band at roughly a tenth of that — the difference between a usable dashboard and a flickering, laggy toy. The rules below (page-snapped dirty rects, a bounding-box fallback chosen by an explicit cost model, a periodic forced full refresh, a host-side shadow of what's actually on the glass) plus the YAML-config/widget/preset shape are directly reusable on a different <DEVICE>.

1. The render pipeline

Fixed order: fit → grayscale → quantize → pack.

  • Fit: scale the source image to fit (<PANEL_WIDTH>, <PANEL_HEIGHT>) preserving aspect ratio

(Lanczos or similar), then letterbox onto a background-filled canvas of exactly the target size. Grayscale in, grayscale out — keep this step orthogonal to quantization.

  • Quantize to 2**bpp levels. Support at least two interchangeable methods and pick per widget:
  • plain nearest-level threshold, no dithering — the right default for text. Dithering

blurs edges to fake intermediate tones; a glyph doesn't have intermediate tones, it has strokes, and blurring them is strictly worse at small sizes.

  • ordered (Bayer 4x4) dither — the right default for photographic or moving content. Its

threshold pattern is identical every frame, so on a moving scene only the underlying image changes, not the dither noise itself (the worked example rejected Floyd–Steinberg for a screen-mirror/game-video widget for exactly this reason: independent per-frame error diffusion makes the noise pattern visibly "boil" frame to frame).

  • Floyd–Steinberg error diffusion — fine for a single still image widget, avoid it for

anything that redraws the same content repeatedly at speed.

  • Level convention: represent pixels internally as a flat array of levels in [0, 2**bpp - 1]

with level 0 always darkest, regardless of final bpp. Quantizers then never need to know which bpp they're feeding — only the packer (step 2) needs to know the wire convention.

2. Pixel packing — pin these down explicitly, per <DEVICE>

Get these four facts from your controller's own datasheet or firmware source, never by guessing:

bpppixels/byteleftmost pixelrow stride"dark" on the wire
18most-significant bitceil(width / 8) bytestypically bit 1 = pixel on
24most-significant pairceil(width*2 / 8) bytestypically level 0 (of 0..3)

Pad every row to a whole byte independently — never let one row's leftover bits bleed into the next row's first pixel. A stride or bit-order mismatch does not crash; it shows up as diagonal tearing, mirrored content, or a shifted/garbled image, which is much slower to diagnose than a crash. Write a unit test that packs a single known pattern (e.g. a checkerboard, or "all pixels on") and asserts the exact byte sequence, before ever sending real content to hardware.

3. Dirty-rectangle partial refresh

Keep a host-side shadow — the levels array the host believes is currently on the glass — and diff every new frame against it before deciding what to send.

  1. Snap to page granularity. Most controllers address partial refreshes in fixed-height row

bands (the worked example: 8-row pages), not pixel-exact rectangles. Expand any dirty region's y/h outward to whole page bands; leave x/w column-exact.

  1. Two candidate plans, pick the cheaper one by an explicit cost model, not a fixed size

threshold:

  • one DirtyRect per changed page band, each tight to that band's own changed columns; or
  • a single page-snapped bounding rect covering every changed pixel.

Cost a plan as sum(window_overhead + stride(rect.w, bpp) * rect.h) over its rects — window_overhead is the fixed per-rect cost of reprogramming the controller's address window (measure it: it's a real, nonzero number of transactions on most I2C/SPI panel controllers). Send whichever total is lower. This naturally degrades to "just send the bounding box" once enough of the frame has changed, without a hand-tuned magic-number threshold.

  1. Force a full refresh periodically (e.g. every 60th cycle) regardless of what the diff says.

This bounds the damage of any missed update, dropped ACK, or shadow/reality drift you didn't anticipate — it should be a cheap insurance policy, not something you rely on for correctness.

  1. Only trust the shadow once the corresponding write is known to have landed. If your

transport can silently drop or truncate a write, update the shadow after confirmation (an ACK, or a successful synchronous call), not optimistically before sending — an untruthful shadow makes the diff wrong in a way that's invisible until content stops updating.

  1. **Invalidate the shadow (force the next frame full) whenever you can't be sure what's on the

glass**: after a transport reconnect, and after switching to a different layout/preset (§5) — diffing a new layout's first frame against the old layout's shadow can coincidentally match bytes and wrongly skip regions that need to be drawn.

4. Config and widgets

yaml
display:
width: <PANEL_WIDTH> # informational default only -- see below
height: <PANEL_HEIGHT>
bpp: 1 # 1 or 2
refresh_seconds: 60
layout:
grid: { cols: 12, rows: 5 }
widgets:
- type: clock
at: [0, 0] # [col, row], 0-indexed
span: [12, 3] # [width_cols, height_rows]
options: { format: "%H:%M:%S" }
  • Never trust `display:` over the real device. If your handshake reports actual panel geometry

(it should), always render against that, not the config file's declared size — the same config then can't accidentally mis-target a device with a different real panel, and the same file works unmodified across two units.

  • Grid cells are fractions, not pixels. Convert at/span to a pixel rect as

x0 = round(canvas_w * col / cols) (and so on) — the same config then renders sensibly at any target resolution, not just the one display: happens to name.

  • Widget contract: render(ctx) -> image of exactly the tile's pixel size. A widget must

never raise for a normal "no data" or I/O-failure condition — draw a fallback ("--", "No events", …) instead. The compositor's own per-widget exception guard (small [error] tile, never blanking the whole dashboard) is a last resort, not a first line of defense: a widget that relies on it loses dirty-rect determinism on the cycle it fires.

  • Provider pattern for any widget doing real I/O (subprocess, OS APIs, network): define a small

provider interface with at least a NullProvider that does no I/O and returns a deterministic placeholder. This is what makes an offline preview tool and a fast, hardware-free test suite possible at all.

  • **A cheap "should I actually redo my work this cycle" check is worth adding per widget, even

though it's easy to skip.** The worked example didn't have one, and paid for it: a system-stats widget spawned a ~390 ms subprocess call unconditionally every render cycle; combined with a loop that slept a flat interval after each cycle's work (§7) rather than to an absolute clock tick, the real frame period drifted to ~1.4x the requested interval and a seconds-resolution clock widget visibly ticked in an uneven 2-1-2-1 pattern that looked like a bug but was pure aliasing between the drifted period and whole-second display resolution. Cache or throttle a widget's own expensive I/O independently of render cadence — "it renders instantly" and "it costs nothing to compute" are different claims.

  • Config path resolution, a reasonable three-tier order to copy: (1) the given path, as-is,

relative to cwd or absolute; (2) the same with an extension appended if missing, still cwd-relative; (3) that name's bare basename joined onto a bundled examples directory — any directory component the caller passed is dropped at this step, since it only ever means "look in the bundled set." An unresolvable path should be a clean error naming every candidate tried, not a traceback.

  • Overflow, uniformly: single-line text that overflows horizontally gets ellipsized (binary

search the longest prefix + "…" that still fits); multi-line content word-wraps and silently drops whatever doesn't fit vertically, rather than drawing past the tile's edge.

5. Presets

A second, parallel set of configs, distinct from one-off "run this exact layout" configs: an ordered manifest — {name, display_label, file} per entry — that the device can switch between live over the link. List order is wire order. Whatever index a device-reported "selection changed" event carries gets looked up positionally against this exact list; reordering the manifest silently reassigns what index means what to a device that's already out there, so treat that reorder as a breaking change, not a cosmetic one.

  • Validate at load time, not at wire-encode time. Cap the display label's byte length and the

preset count to whatever the wire format actually allows (the worked example: ≤20 UTF-8 bytes/name, ≤8 presets) and raise a clear error immediately for a manifest mistake — don't let it surface only as an opaque exception three layers down inside the encoder.

  • Three useful host modes, worth supporting as distinct flags: run forever on one fixed config

and never touch presets at all; start pinned to one named preset while still telling the device the full menu (and then ignore later device-driven selection changes — an explicit pin should not be silently overridden); or start on a default and freely follow whatever the device reports.

  • A preset switch — locally forced or device-driven — must force the next frame full, exactly

like a reconnect (§3.5): the shadow belongs to whatever was on screen before the switch.

6. Notifications that don't fight a running loop for the transport

If your link is single-consumer (one serial/USB connection, one process at a time — many are, and some panel controllers get actively confused if two hosts both try to drive them), a one-shot notification command cannot just open the transport itself whenever a long-lived dashboard loop might already be running. The worked example hit this directly: two host processes briefly both held the port open, the second one's handshake reset the device's session sequencing out from under the first, and an unrelated bug turned the resulting protocol-level warning fatal. The fix that generalizes:

  1. A long-lived loop writes a small lock file (pid + start time) for the duration of its run,

removed on clean exit. A stale lock (the writer died without cleaning up) reads as "not running" the moment its pid is no longer alive — so a crash never permanently strands the one-shot path.

  1. The one-shot command checks that lock *first*. If a loop is running, it writes its request to

a small JSON file the loop polls once per cycle — it does not attempt to open the transport at all in this, the common, case.

  1. Only if no loop is running does the one-shot command try a direct connection — and even then,

a "busy" failure (lock missing/stale but something else genuinely holds the transport) falls back to the same request file rather than retrying the open.

Two distinct drawing paths, deliberately different:

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 95 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
1
7-day trend score
3

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/hyderhusainarastu/hardware-mod-toolkit/device-companion-dashboard/badge)](https://verified-skill.com/skills/hyderhusainarastu/hardware-mod-toolkit/device-companion-dashboard)

Something wrong with this skill or its page? Tell us.