Importing NeoTrellis uses 83% of RAM -- how to fix?

CircuitPython on hardware including Adafruit's boards, and CircuitPython libraries using Blinka on host computers.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
jppearson
 
Posts: 3
Joined: Fri Dec 18, 2020 10:11 am

Importing NeoTrellis uses 83% of RAM -- how to fix?

Post by jppearson »

Hello! I am really enjoying the "NeoTrellis Game" project [1], which uses the Feather M0 Express [2] and a 4x4 NeoTrellis RGB driver [3].
However, I'm running out of RAM in my CircuitPython program. I notice that importing the NeoTrellis library takes 83% of the available RAM:

Code: Select all

import gc
print(gc.mem_free())   # 15728 bytes free
from adafruit_neotrellis.neotrellis import NeoTrellis
print(gc.mem_free())   # 2672 bytes free
I'm wondering if there's some way around this? For example, by building CircuitPython with the NeoTrellis library added as a "frozen module", as described here [4]?
Thanks,
Justin

[1] "NeoTrellis Game" : https://learn.adafruit.com/neotrellis-box-game/overview
[2] "Adafruit Feather M0 Express - Designed for CircuitPython - ATSAMD21 Cortex M0" : https://www.adafruit.com/product/3403
[3] "Adafruit NeoTrellis RGB Driver PCB for 4x4 Keypad" : https://www.adafruit.com/product/3954
[4] "Building CircuitPython – Adding Frozen Modules" : https://learn.adafruit.com/building-cir ... en-modules

User avatar
dastels
 
Posts: 15608
Joined: Tue Oct 20, 2015 3:22 pm

Re: Importing NeoTrellis uses 83% of RAM -- how to fix?

Post by dastels »

I suspect the modules (neotrellis and seesaw) have grown since that guide was written in late 2018.

I see 3 options off the top of my head:
- Switch to a Feather M4 Express. This is the easiest and would be my choice.
- get a build of CircuitPython and the bundle from Oct '18
- as you suggest, make a custom build of CircuitPython freezing in the neotrellis and seesaw libraries.

Dave

User avatar
jppearson
 
Posts: 3
Joined: Fri Dec 18, 2020 10:11 am

Re: Importing NeoTrellis uses 83% of RAM -- how to fix?

Post by jppearson »

These are great options! Thank you Dave!
-Justin

User avatar
dastels
 
Posts: 15608
Joined: Tue Oct 20, 2015 3:22 pm

Re: Importing NeoTrellis uses 83% of RAM -- how to fix?

Post by dastels »

Let me know what you decide an how it goes.

Dave

User avatar
jppearson
 
Posts: 3
Joined: Fri Dec 18, 2020 10:11 am

Re: Importing NeoTrellis uses 83% of RAM -- how to fix?

Post by jppearson »

Update: I bought a Feather M4 Express and it solved my RAM shortage! Now

Code: Select all

gc.mem_free()
shows more than 100kB instead of just 15kB for the M0 Express. Thanks Dave!
-Justin

User avatar
dastels
 
Posts: 15608
Joined: Tue Oct 20, 2015 3:22 pm

Re: Importing NeoTrellis uses 83% of RAM -- how to fix?

Post by dastels »

Awesome! Have fun.

FYI, the ESP2-S2 can have tons more. The Funhouse reports about 2M free before loading code. It will vary on board since it' supports external RAM.

For example, my FeatherS2 reports:

Code: Select all

Adafruit CircuitPython 6.2.0 on 2021-04-05; FeatherS2 with ESP32S2
>>> import gc
>>> gc.mem_free()
8196176
Dave

Locked
Please be positive and constructive with your questions and comments.

Return to “Adafruit CircuitPython”