# MicroPython firmware for the 10-button custom streamdeck Pico. # Copy this file to the Pico as /main.py. from machine import Pin import time # Button index 1..10 maps to the physical order provided by the wiring list. BUTTON_PINS = [28, 27, 26, 22, 21, 20, 18, 19, 17, 16] DEBOUNCE_MS = 35 POLL_MS = 5 buttons = [Pin(pin, Pin.IN, Pin.PULL_UP) for pin in BUTTON_PINS] last_raw = [button.value() for button in buttons] stable_state = last_raw[:] last_change = [time.ticks_ms() for _ in buttons] print("streamdeck-pico ready") print("pins=" + ",".join(str(pin) for pin in BUTTON_PINS)) while True: now = time.ticks_ms() for index, button in enumerate(buttons): raw = button.value() if raw != last_raw[index]: last_raw[index] = raw last_change[index] = now if raw != stable_state[index] and time.ticks_diff(now, last_change[index]) >= DEBOUNCE_MS: stable_state[index] = raw pressed = raw == 0 event = "down" if pressed else "up" button_number = index + 1 gp_pin = BUTTON_PINS[index] print('{{"button":{},"pin":{},"event":"{}","pressed":{}}}'.format( button_number, gp_pin, event, "true" if pressed else "false", )) time.sleep_ms(POLL_MS)