Initial commit
This commit is contained in:
commit
9e4e14e8ac
1 changed files with 35 additions and 0 deletions
35
main.py
Normal file
35
main.py
Normal 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)
|
Loading…
Reference in a new issue