Skip to content

Displaypad

Leas Porscha edited this page Aug 30, 2026 · 5 revisions

DisplayPad

displaypad_lib.DisplayPad — the main class for controlling the pad.

Constructor

DisplayPad(rotation=0, debounce_sec=0.01, dc_window=0.6, auto_connect=True)
Argument Type Default Description
rotation int 0 Clockwise display rotation in degrees (0, 90, 180, 270)
debounce_sec float 0.01 Minimum seconds between repeated press events
dc_window float 0.6 Double-click detection window in seconds
auto_connect bool True Open hardware on init. Pass False to connect later

Methods

Method Returns Description
is_connected() bool True if hardware is connected
try_connect() bool Connect and push current buffer. Returns False on failure, never raises
update(timeout=20) — One loop iteration: poll input, fire events, repaint dirty keys
set_brightness(percent) — Set backlight 0–100%. No-op if disconnected
push_image(image_or_path=None) — Upload current buffer (or given image) to all 12 keys
add_page(page_id, page) — Register a Page. Repaints immediately if it replaces the active page
switch_to_page(page_id) bool Switch active page and repaint
blank() — Backlight off, all tiles black
clear() — Remove all keys from active page, clear display to black
disable() — Blank display, stop background worker, close driver
screenshot(filename) — Save current buffer to file

Key Assignment

pad[0] = MyKey()      # assign key to slot 0 on the active page
pad[0]                # get the key at slot 0
del pad.keys[0]       # or set to None to clear a slot

Slots are 0–11, left-to-right, top row then bottom row.

Main Loop

try:
    while True:
        pad.update(20)      # 20 ms poll timeout
except KeyboardInterrupt:
    pass
finally:
    pad.disable()

update() calls on_tick() on every active key, fires input lifecycle hooks, and uploads changed tiles. When 3 or more keys change in one cycle, the full panel is uploaded instead of individual tiles.

Hotplug

See the Home page for a complete hotplug example.

Clone this wiki locally