0

NeoTrellis 4X4 as HID hotkeys via Trinket M0 (HID library fa
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

NeoTrellis 4X4 as HID hotkeys via Trinket M0 (HID library fa

by TheEnder42 on Tue Feb 12, 2019 1:40 am

I'm attempting to use a NeoTrellis 4X4 as a hotkey pad for some computer games. My code is a heavily modified version of the neotrellis_simpletest.py example from the Adafruit_CircuitPython_NeoTrellis-master library. The trellis interface works fine over a JST cable: the colors are how I want them and the colors change responding to being pressed how they should.

The problem is the HID library.

My import statements are:
Code: Select all | TOGGLE FULL SIZE
import time
from board import SCL, SDA
import busio
from adafruit_neotrellis.neotrellis import NeoTrellis
#from adafruit_hid.keyboard import Keyboard
#from adafruit_hid.keycode import Keycode

and further down I have:

Code: Select all | TOGGLE FULL SIZE
# Make keyboard
time.sleep(1)
#kbd = Keyboard()

When I un-comment any of these 3 lines the trellis buttons stop responding to presses, the colors don't change and the whole thing seems to freeze in place. Un-commenting the #kbd = Keyboard() will clearly cause an error because the keyboard() isn't imported, but the import statements will both cause the "crash" individually.

Has anyone else encountered this before?

Other information (in case it's relevant):
-Using Mu editor
-Trinket M0 has a tiny memory so I had to delete unused files from the libraries.
----Of the adafruit_hid library I cut out consumer_control.mpy, consumer_control_code.mpy, gamepad.mpy, and mouse.mpy. I never import these files but are they still necessary to the library as a whole?

TheEnder42
 
Posts: 4
Joined: Tue Feb 12, 2019 1:17 am

Re: NeoTrellis 4X4 as HID hotkeys via Trinket M0 (HID librar

by adafruit_support_mike on Sun Feb 17, 2019 5:21 am

[moved to the CircuitPython forum]

adafruit_support_mike
 
Posts: 57106
Joined: Thu Feb 11, 2010 2:51 pm

Re: NeoTrellis 4X4 as HID hotkeys via Trinket M0 (HID librar

by tannewt2 on Tue Feb 19, 2019 3:06 am

Hi TheEnder42,
Deleting the extra files from the library should be fine. You'll get an import error if a file is needed.

What version of CircuitPython are you running on the Trinket. It's always good to update to the latest (currently 3.1.2).

The HID library is pretty large so you may need to delete some of the contents of the libraries as well to make them fit into the Trinket's RAM.

~Scott

tannewt2
 
Posts: 1097
Joined: Thu Oct 06, 2016 8:48 pm

Re: NeoTrellis 4X4 as HID hotkeys via Trinket M0 (HID librar

by TheEnder42 on Sun Apr 07, 2019 6:21 pm

Hi Scott,

It seems I was running version 3.1.1, I have updated it to 3.1.2 but the same problems persist.

I've cut out any file from the libraries I don't use, and have about 2kb left when I check the properties. Could the amount of RAM be different from this number and I'm actually asking too much of it? I don't get any missing file errors though, or any errors at all actually, it just simply freezes and won't respond to the buttons anymore.

I have a circuitplayground express M0 that I loaded with the same code and it works just fine on there (although I used the adafruit distribution bundle of lots of libraries, but the files used are the same as the ones on my Trinket, I checked)

Does it sound like any of these could potentially be the problem?

Thanks in advance!
-TheEnder42

TheEnder42
 
Posts: 4
Joined: Tue Feb 12, 2019 1:17 am

Re: NeoTrellis 4X4 as HID hotkeys via Trinket M0 (HID librar

by tannewt2 on Mon Apr 08, 2019 3:04 am

The flash space is different from the RAM impact. You'll likely need to keep trimming libraries to get it to fit into the Trinket M0.

The CPX freezes in the HID library with means it doesn't take RAM to use it. Unfortunately we can't do the same with the Trinket M0 because internal flash is used for the filesystem as well.

tannewt2
 
Posts: 1097
Joined: Thu Oct 06, 2016 8:48 pm

Re: NeoTrellis 4X4 as HID hotkeys via Trinket M0 (HID librar

by TheEnder42 on Wed Apr 10, 2019 6:38 pm

That makes sense, though to keep cutting down libraries, what non explicitly imported files are still used in the Trinket M0 --> NeoTrellis 4X4 connection?

In the adafruit_seesaw lib I have:
analoginput.mpy (questionable?)
crickit.mpy (pretty sure I can remove this one)
digitalio.mpy (needed, I'm guessing)
keypad.mpy ---------------- (needed or delete?)
neopixel.mpy (needed for sure)
pwmout.mpy ---------------- (needed or delete?)
samd09.mpy ---------------- (needed or delete?)
seesaw.mpy (needed for sure)

And I know the NeoTrellis uses I2C connection so in the adafruit_bus_device lib I'm assuming spi_device.mpy can be removed as well? [Edit: I2C over the JST connector wires]

The other libraries I'm using have already been reduced; adafruit_neotrellis only has 1 file anyway, and adafruit_hid only has left what I have a direct import statement for (keyboard.mpy/keycode.mpy/keyboard_layout_us.mpy)

TheEnder42
 
Posts: 4
Joined: Tue Feb 12, 2019 1:17 am

Please be positive and constructive with your questions and comments.