#Gemma m0 memory error
1 messages ยท Page 1 of 1 (latest)
I guess I'm running into ram issues?
This is the code I'm trying to run:
import adafruit_dotstar as dotstar
import board
dot = dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1, brightness=0.1)
pulse = Pulse(dot, speed=0.1, color=(0, 255, 0), period=3)
pulse.animate()
It seems the error is being thrown in this line:
https://github.com/adafruit/Adafruit_CircuitPython_LED_Animation/blob/main/adafruit_led_animation/animation/pulse.py#L78
Could this be due to the import being inline within the function and not at the top?
The animation library is designed to be used with LED strips. That's a lot of overhead to pulse 1 LED. There are other ways to do it without involving large libraries.
Here's an example I wrote for the Gemma M0 that does a candle flicker. https://github.com/DJDevon3/My_Circuit_Python_Projects/tree/main/Boards/atmel-samd/Adafruit Gemma M0/Candle Flicker
Thanks. That looks like just an analog out. I'm trying to work with the onboard RGB led to create a heartbeat like pulse effect.
ah ok. pretty sure there's a guide for that in the circuit python essentials learn guide. it's one of the best overall guides to keep bookmarked. https://learn.adafruit.com/circuitpython-essentials/circuitpython-neopixel
the onboard LED is just board.LED though that might not be the RGB LED.
I wasn't able to find a pulse/fade through those docs. Been looking at stuff all day, going in circles now ๐
Might be able to rev-eng the pulse code in the library though
ah the RGB led uses 2 pins. board.APA102_MOSI and board.APA102_SCK. one is data the other is clock.
yep, i got the rgb led to rotate colors
but, writing nice fade/pulse code isn't trivial for me
Have you looked at this example yet? https://learn.adafruit.com/circuitpython-powered-gemma-nightlight/nightlight-pro
Nope, haven't seen this one
the amount of time between operations can be slowed down by using time.sleep(0.01) in seconds.
time.sleep(5) would pause for 5 seconds and would be very noticeable but a pause of 0.5 might slow it down to a smoother slow speed.
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
My code is here, I've gotten the capacitive touch etc working.
you'd want the pause inside the while true loop since that's what is looping.
something like py if mode == MODE_RGB_WHEEL: time.sleep(0.5) dot[0] = wheel(i)
Sure but what I guess i'm missing is what the fade algorithm should be like
pulsing like this: https://www.youtube.com/watch?v=VCnmjwenPeM
Hi ,
This video is to show you how to make a simple heat beating effect LED heart.
โพ Circuit diagram - https://drive.google.com/file/d/1htFdoxIDvBjw2zZqzsxn_aJPW6iYL6j5/view?usp=drivesdk
โพ Resistors - https://amzn.to/3Afk6yh
โพ Transistors - https://amzn.to/3XKyyIO
โพ IC - https://amzn.to/3AMLgN5
โพ PCB - https://amzn.to/3EbR1Vp
โพ LED - h...
ok that's a for in range loop that goes from 0 brightness to 255 where 255 is maximum brightness, then resets to 0 and loops infinitely.
It's not really though.
It's more like start at 255, fade down to 100, jump back to 255?
what I want to control is how fast it pulses down
Which I can do with time.sleep?
the brightness is set with the argument brightness=next_brightness_val
does brightness internally change the rgb values?
what's the difference between using brightness=1 vs [255,0,0]
do you want to keep the touch control for speed or brightness? i might have to whip out a gemma m0 and try this.
A1 mode
A2 brightness
so to only change the red you'll only want to change the first value for R in [R,G,B]
right
and leave the others at 0
for my pulse effect i can ignore brightness correct?
for that script it seems that brightness is equated to the color value where 0 is off (no brightness) and 255 is full brightness (per color).
correct. assume brightness constant at 0.1
brightness isn't a constant, it's a variable that does change from 0-255
[255,0,0] is full red
if i set
dot = [255,0,0]
then change brigthness to 0.1
what is the value of dot?
it's not [255,0,0] anymore right?
it's [25, 0, 0]?
oh you're correct, i didn't realize dot.brightness was an argument. i've never used the onboard RGB LED.
interesting. i'm sure there's documentation on it.
alternatively just use brightness since it's a single color pulse
you are correct there is a separate parameter just for brightness.
i suppose you could just set the color to 255,0,0 and then put brightness in a for i in range(0.0, 1.0): dot.brightness = i
if it's a while true loop it should loop infinitely.
what are the values of i in your example?
isn't it just 0,1
j = 0
dot[0] = [0, 255, 0]
for j in range(0, 100):
jk = j / 100
dot.brightness = jk
this is causing some crazy flickering ha
it's turning off and on on each set.
heartbeat_min = 30
while True:
if mode == MODE_RGB_WHEEL:
dot[0] = wheel(i)
# dot.show()
elif mode == MODE_HEARTBEAT:
j = 255 - i
if j < heartbeat_min:
dot[0] = [0, heartbeat_min, 0]
else:
dot[0] = [0, j, 0]
this kinda works, but would be better with the pulse library ๐
i loaded up my gemma m0 to help test but it's not recognizing the dotstar library for some reason.
what version of circuit python are you using?
9
You should only need dotstar & pixelbuf
my gemma came with cp v5, updated it to v9
Here's the latest code:
https://pastebin.com/rBfFDwBk
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
do you have a boot_out.txt file? what version date is it?
i'm having some weird issues here.
Adafruit CircuitPython 9.0.5 on 2024-05-22; Adafruit Gemma M0 with samd21e18
Board ID:gemma_m0
UID:A1B2E6594E34315020312E43112A15FF
yeah the latest is from May and I don't think it's working right. I couldn't get it to work with the dotstar library at all.
You tried the latest library right?
this is the simpletest example for the dotstar ```py
SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
SPDX-License-Identifier: MIT
import time
import random
import board
import adafruit_dotstar as dotstar
On-board DotStar for boards including Gemma, Trinket, and ItsyBitsy
dots = dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1, brightness=0.2)
Using a DotStar Digital LED Strip with 30 LEDs connected to hardware SPI
dots = dotstar.DotStar(board.SCK, board.MOSI, 30, brightness=0.2)
Using a DotStar Digital LED Strip with 30 LEDs connected to digital pins
dots = dotstar.DotStar(board.D6, board.D5, 30, brightness=0.2)
HELPERS
a random color 0 -> 192
def random_color():
return random.randrange(0, 7) * 32
MAIN LOOP
n_dots = len(dots)
while True:
# Fill each dot with a random color
for dot in range(n_dots):
dots[dot] = (random_color(), random_color(), random_color())
time.sleep(0.25)
yes the mpy and the py bundle neither work for me
intresting
should work with v9 uf2 & v9 mpy
Thanks for trying and helping out. I'm somewhat satisfied with the result ๐
I might look into the Pulse animation library and see why it's hogging so much memory to light up one pixel
i've brought it up to the devs, someone will look into it. i can't even replicate your setup with the identical board. :/
yes it should. what it should do and what it's doing are 2 different things. ๐ฆ
hw is never reproducible
the samd21 is one of the lowest end cpu's. the only thing lower is an arduino uno or there about. there's very little ram so it doesn't take much to hit a memory limit error.
i do love the gemma m0's for how small and compact they are though. i have many of them and this is the first time i've ever encountered this type of issue.
how would you go about adding BLE to an m0, trying to keep it's form factor small as well
alternatively I was looking at an esp32c3 which has ble
it's almost like the UF2 is from a beta state where mpy files weren't accepted and only py libraries were. it's asking for the .py specifically and even when i put it in /lib it still says module not found. it's so weird.
ah i think that's a compiliation error
i had the error too and it was because i aws mising the pip package
right but why is yours working with the same exact build date and mine isn't. ๐ฆ
I had to install the pip package and it worked
pip? on a microcontroller?
No, i was seeing the uC log .py error
i don't use circup i drag and drop
so i insatlled it via ide
and it worked
not entirely sure how i got through it tbh
that's ok, someone will have to look into it. it's a weird issue i've never seen before. usually the build dates are from like last night or today... so seeing it from May might be a clue that the UF2 hasn't been building properly via github actions since May. just a guess.
hmm maybe i could try a nightly build but that's not really the point i guess. someone else will run into the same issue so it's best i report it.
Makes sense, thanks again!
https://learn.adafruit.com/circuitpython-led-animations/basic-animations
This page claims the animations should work on an m0 ๐ค
sorry i couldn't be more help. yeah May was the last stable release it's all beta versions since then.
You were helpful enough to get me thinking to write a custom pulse function, and that gets the job done
You could run & modify my code on an dotstar I guess, doesn't have to be m0
glad you know enough coding to take it and run with it. good stuff.