-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adafruit sparkle animation broken on RP2040, but RainbowSparkle and SparklePulse work? #112
Comments
Tested on a Gemma M0 with the same result: doc_2023-03-01_04-34-00.mp4It only has enough memory to run the standard Sparkle animation, but not SparklePulse or RainbowSparkle to show the difference. (I tried an ItsyBitsy RP2040 too, same result and Sparkle doesn't work, but SparklePulse and RainbowSparkle do work.) |
almost 1,5 years later with CircuitPython 9.1.1 and the latest libraries this bug is still not fixed |
SparklePulse seems to just call Sparkle and Pulse and for some reason it works. If I could disable the pulsing, it would work. Or there is some bug I don't recognise in here. |
@GithubUser99999999 Just checking, are you the same person as https://forums.adafruit.com/viewtopic.php?p=1025640#p1025640 ? |
Hello Dan, yes I also linked the videos from here. I can also provide more if needed. |
After testing Sparkle, Pulse, and SparklePulse, I think the problem here is that the videos in the guide on that page are mislabeled. The Sparkle effect at the very top of the page is what you should expect sparkle to look like: very quick random transitions. The animation labeled as Sparkle is really SparklePulse. And the animation labeled as SparklePulse is something else, maybe just an adjusted SparklePulse. In other words, it's a bug in the Guide, not a code bug. |
Aaaaaah okay. I never would've figured that out ^^ Thanks for that. Do you perchance have an idea of how to use the RainbowSparkle library/code with just one single colour then? The sparkling of SparklePulse and RainbowSparkle is perfect, but not that of Sparkle, that's just flickering. I don't seem to be able to create any animation like the one in the gif from the guide at all. The guide gif also is simply not pulsing, it's just sparkling with one single colour. |
Just to be clear, which one do you mean? |
A non-pulsing single-colour sparkle animation like this. RainbowSparkle works fine, if only I knew how to change the code so that it outputs just one colour. |
I tried making a new video of the Sparkle effect and did not succeed in a faithful representation. I think the video in the guide may indeed be Sparkle, but because of video aliasing effects, it does not show up well and looks slower than in real life. The video at the top of that page is the best representation of Sparkle. I've added a warning to the guide about that video. I also tried some simple modifications to the example code to force a monochromatic sparkle_pulse = SparklePulse(pixels, speed=0.05, period=3, color=JADE, step=256) you will get a monochromatic red |
I am using this as a sparkly replacement now even though it's not as random.
Vid.20240815.161808128_x264.mp4I would need white for this for example with yellow PLA. Thanks for your help anyway! Maybe I will be good enough to understand how the rainbowsparkle code actually works in-depth in order to be able to modify it for single colour use. |
I am going to close this for now as it is not a bug in the library, but was more of a Learn Guide documentation problem. Feel free to continue posting. |
Please take a look at my proposed fix. There does seem to be an issue with the way sparkle behaves by itself when not used with pulse. Only file edited was adafruit_led_animation/animation/sparkle.py from this # before
def _set_color(self, color):
half_color = tuple(color[rgb] // 4 for rgb in range(len(color)))
dim_color = tuple(color[rgb] // 10 for rgb in range(len(color))) to this # after
def _set_color(self, color):
half_color = tuple(color[rgb] // 64 for rgb in range(len(color)))
dim_color = tuple(color[rgb] // 16 for rgb in range(len(color))) Sparkle_Before_and_After.mp4I don't know if changing the divisor values might have unintended consequences for other scripts using sparkle so please take my changes with a grain of salt. They might work well for this script but not be good for others. I'd like to propose those divisor values become configurable. Some people might want the half color & dim color in their animation and others might want single color sparkle with no background color. Either that or a create a single_sparkle.py so it will have its own helper? I hope this is what OP wanted and I haven't completely misunderstood the assignment? |
It's going in the right direction but not quite. Here are some videos: original Adafruit Sparkle animation (speed=0.05, color=WHITE, num_sparkles=1, brightness=1) your edited Sparkle animation (speed=0.05, color=WHITE, num_sparkles=1, brightness=1) here as an example the Adafruit RainbowSparkle animation with Step=255 to show only RED (speed=0.05, num_sparkles=10, brightness=1) |
Seems like what you want isn't a single sparkle but sparkle pulse. remove the import for sparkle and remove it from the animation sequence. change the animation sequence to use sparkle pulse. sparkle_pulse = SparklePulse(pixels, speed=0.08, period=1, color=RED)
animations = AnimationSequence(
sparkle_pulse,
auto_clear=True,
) customize the speed (in seconds) where 0.05 is very fast and 1.0 is slow. You can set the library back to the original library file where half_color is //4 and dim_color is //10. When you add sparkle on top of sparkle pulse that's when it will do the fast blips. sparkle pulse by itself is a slower fading using PWM. This issue seems to be more of an animation settings issue than a library issue. |
SparklePulse basically doesn't work because I cannot indicate how many pixels are supposed to be sparkling. With about 40 LEDs, it's almost invisible and almost nothing sparkles at all, no matter how fast or slow it is. If I add Sparkle to this, it's just flickering again, and obviously I am aware about the speed variable, but that just changes how fast it's flickering. Flickering = abrupt changes in brightness of all or most LEDs instead of what this animation is supposed to do. The only animation that actually works fine and sparkles is RainbowSparkle, but it cannot be forced to just use one colour apparently. |
sparkle = Sparkle(pixels, speed=0.05, color=AMBER, num_sparkles=10)
This code should look like this (code and video taken from the adafruit guide):
leds_LED_Anim_Sparkle.mp4
But it does actually look like this:
doc_2023-02-21_03-50-08.mp4
However, the rainbowsparkle.mpy animation does indeed work (with the same code):
doc_2023-02-21_03-49-48.mp4
Tested with CircuitPython 8 on a PICO RP2040
Is this animation currently broken?
The text was updated successfully, but these errors were encountered: