26 lines
709 B
Python
26 lines
709 B
Python
from time import sleep
|
|
from telemetrix_rpi_pico import telemetrix_rpi_pico
|
|
from siwatlib.debounce import debounce
|
|
from siwatlib.sound import piano_key
|
|
|
|
import winsound
|
|
|
|
index_shift = 2
|
|
debouncers = []
|
|
|
|
def handle_button_press(data):
|
|
try:
|
|
print(str(data[1])+' Pressed')
|
|
recieved_state = not data[2]
|
|
if debouncers[data[1]-index_shift].set_state(state=recieved_state):
|
|
piano_key((data[1]-1)*2-1)
|
|
except KeyError:
|
|
pass
|
|
|
|
mcu = telemetrix_rpi_pico.TelemetrixRpiPico(com_port='COM10')
|
|
|
|
for i in range(2,10):
|
|
debouncers.append(debounce(state=False,debounce_time=0.2))
|
|
mcu.set_pin_mode_digital_input(i,callback=handle_button_press)
|
|
while True:
|
|
sleep(100) |