commit 9e4e14e8acc1f855525430c990c439e3a6d228d2 Author: Søren Rasmussen Date: Mon Aug 1 15:38:31 2022 +0200 Initial commit diff --git a/main.py b/main.py new file mode 100644 index 0000000..ab48bac --- /dev/null +++ b/main.py @@ -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)