Initial commit

This commit is contained in:
Søren Rasmussen 2022-08-01 15:38:31 +02:00
commit 9e4e14e8ac

35
main.py Normal file
View file

@ -0,0 +1,35 @@
import machine
import pyb
KEY_KEYPAD_PLUS = 0x57
hid = pyb.USB_HID()
button = machine.Pin(12, machine.Pin.IN, machine.Pin.PULL_UP)
def press_key_once(key1):
buf = bytearray(8)
buf[2] = key1
hid.send(buf)
pyb.delay(10)
def release_key_once():
press_key_once(0)
buf = bytearray(8)
state = False
while True:
pressed = not bool(button.value())
if pressed == state:
continue
if pressed:
press_key_once(KEY_KEYPAD_PLUS)
else:
release_key_once()
state = pressed
pyb.delay(10)