AtomS3U USB otg.
-
Hello,
I have the AtomS3U, and have a key module that I can attach to it.
I have been playing around with UIFlow2 to get a bit a feel of this thing, an managed to do things like change the led colour when the key is pressed, making the led cycle colors etc...
What I however would like to do is have the AtomS3U emulate a keyboard. It supports usb OTG, so that should be supported. I want to try something simple first: Press the button and output some character to the connected PC.
I have not found information on how to do this with UIFlow2. Would this need me diving in to micropython or arduino?
-
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?