I tried the following code:
import os, sys, io
import M5
from M5 import *
from unit import KeyUnit
from usb.device.keyboard import Keyboard
from usb.device.hid import KeyCode
keyboard = None
key_0 = None
def key_0_wasClicked_event(state):
global keyboard, key_0
keyboard.set_keys(KeyCode.A, 0, 0, 0, 0, 0)
def setup():
global keyboard, key_0
M5.begin()
keyboard = Keyboard()
key_0 = KeyUnit((1, 2))
key_0.setCallback(type=key_0.CB_TYPE.WAS_CLICKED, cb=key_0_wasClicked_event)
def loop():
global keyboard, key_0
M5.update()
key_0.tick(None)
if __name__ == '__main__':
try:
setup()
while True:
loop()
except (Exception, KeyboardInterrupt) as e:
try:
from utility import print_error_msg
print_error_msg(e)
except ImportError:
print("please update to latest firmware")
And I got the following error:
Traceback (most recent call last):
File "main.py", line 5, in <module>
ImportError: no module named 'usb'
So the usb module is not present in the firmware.
Is that on purpose, or is this a bug?
Is there a way to add the library?