So i'm pretty new to all of this and am loving Fastled,

fastled-support
gplus
(Marnix Reckman) #1

So i’m pretty new to all of this and am loving Fastled, but can’t figure out the details on the wave functions. I’d like to use the quadwave to run only once (from start till the end of the strip) and then stop and leave the last pixel lit.
I’m trying to do this with the code below, which passes compiling, but crashes my Wemos D1 mini.

Any idea where this goes wrong?

void Fill() {
EVERY_N_MILLISECONDS(10) {

while (angle < NUM_LEDS); { //move led up the strip till max count is reached
uint8_t leadDot = map(quadwave8(angle),0, 255, 0, NUM_LEDS - 1);
angle = angle+1;
leds[leadDot] = CHSV(0, 255, 255);
fadeToBlackBy(leds, NUM_LEDS, NUM_LEDS*.8 );
// Serial.println(angle);
FastLED.show();
}

} 

}

(Jeremy Spencer) #2

How many leds are there?
leadDot may be going out of range, try adding a constrain function, also try taking the quadwave8(angle) function out of the map function and use a separate line and variable for it.

The map function still has some unexpected results which may or may not be causing the issue here.

(Daniel Garcia) #3

The problem is more likely this line:

while (angle < NUM_LEDS); { //move led up the strip till max count is reached

See that ; after the while? You’ve basically created an infinitely spinning loop - because there is, effectively, no body to the loop. The D1 gets very unhappy if loop doesn’t return every once in a while and so that’s why it’s likely crashing/watchdogging. Get rid of that ;

(Marnix Reckman) #4

@Jeremy_Spencer
I had typed an answer this afternoon, but somehow it never send.
in Short: at writing I had 144 leds, now testing it on 60.
I’ve been trying to find more “how to” information on the (quad)wave functions… but besides the http://fastled.io + github wiki and a few examples (without comments) I can’t really find documentation.
Would you happen to know another source on how to get a deeper understanding of the different ways to use it?

@Daniel_Garcia
Thanks, earlier on I had error messages when I did that and it went super fast… but should have moved the Every_N_Milliseconds inside it. Now it indeed works, but the angle increase isn’t equal to the movement on the leds (it seems like each led lit is around ~2 degrees of angle increase)
For this some additional documentation would be great.

In the end it’s the idea to create a function to make the leds fill up the whole ledstrip one by one while the trail keeps moving.
But for now at least this is working.

(Daniel Garcia) #5

Fastled.io/docs has more api level documentation. http://Fastled.io/docs

(Daniel Garcia) #6

Also remember that the “angles” are represented as 0-255 values (for the 8-bit functions) - https://github.com/FastLED/FastLED/wiki/FastLED-Wave-Functions

(Marnix Reckman) #7

@Daniel_Garcia
| have had a look at that, but it’s not really extensive…
"LIB8STATIC uint8_t quadwave8 ( uint8_t in )

quadwave8: quadratic waveform generator.

Spends just a little more time at the limits than ‘sine’ does.

Definition at line 705 of file lib8tion.h.
"

is all there is on quadwave… or I’m looking wrong :slight_smile:

a4998357ed27aa82db7d291148428495.jpeg

(Daniel Garcia) #8

The wiki page shows the different graphs across the functions - @Mark_Kriegsman wrote those and can speak more to how they get used (I mostly use noise and other generator functions/oscillators in my own work)

(Marnix Reckman) #9

oops… didn’t intend to add the video there… kinda still have to get used to the whole google plus structure… thought it had died a long time ago :smiley:
Not being able to edit posts is deadly in my case… Anyhoe… I wanted to show what I’m trying to archieve in the end:

is a crude video of what I wish to accomplish… just to give the idea

(Marnix Reckman) #10

ok… I now actually have what I wish to create.
A single pixel that goes to the end with a fading trail that fades out when the pixel stops.
When I use NUM_LEDS2 it stops when the pixel reached the end of the strip
However, while testing I let it bounce back and forth and use:
while (angle < NUM_LEDS
16) instead so it goes back and forth a bit.

While testing I notice that my Wemos D1 mini just plain crashes and does a Soft WDT reset :confused:

To me this indicates that something is awefully wrong about the script below, so I’m wondering if any of you can tell me as I don’t see it…

Are the Wemos things prone to crashing while functions just work?

void Fill() {
while (angle < NUM_LEDS16) {
EVERY_N_MILLISECONDS(10) {
uint8_t leadDot = map(quadwave8(angle),0, 255, 0, NUM_LEDS - 1);
angle = angle+1;
leds[leadDot] = CHSV(0, 255, 255);
//Serial.println(angle);
}
fadeToBlackBy(leds, NUM_LEDS, NUM_LEDS
.4 );
FastLED.show();
}
}

(Daniel Garcia) #11

WDT is the watchdog timer - it’s like a dead man’s switch that needs to be pressed every so often or the device assumes that something has locked up and reset. Your Fill function basically doesn’t return for nearly a second, if not a little bit over, which is likely what’s upsetting the watchdog. You might be able to reset it by calling yield(); after show() - but the way I try to encourage people to do things is that each call to loop() does one frame of output, which has the side effect of side stepping this problem.

(Marnix Reckman) #12

@Daniel_Garcia thanks for the suggestion! not sure (yet) how to split up the while to make it process one frame at a time… would you have a sketch example here somewhere which i can use as reference? that’d be great