import machine
import usb_hid
from time import sleep
COMMANDS = {
"UP": 0xE0 0x18,
"DOWN": 0xE0 0x1C,
"LEFT": 0xE0 0x1A,
"RIGHT": 0xE0 0x1B,
"HOME": 0xE0 0x30,
"BACK": 0xE0 0x1D,
"OK": 0xE0 0x0C,
"PLAY": 0xE0 0x24,
"PAUSE": 0xE0 0x23,
"STOP": 0xE0 0x25,
"APPS": 0xE0 0x08,
}
ir_receiver = machine.Pin(2, machine.Pin.IN)
def read_ir_signal():
pass
def send_usb_command(command):
if command in COMMANDS:
key_code = COMMANDS[command]
report = usb_hid.Keyboard.report(0, key_code)
usb_hid.device.send(report)
while True:
command = read_ir_signal()
if command:
send_usb_command(command)
sleep(0.1)