Rob_Hilken
(Rob Hilken)
February 29, 2016, 12:50am
1
I’ve started looking at some of the built in things that FastLED can do, and I wonder if it’s possible to replace this code:
void fire(int grnLow) {
for (int grnPx = grnHigh; grnPx > grnLow; grnPx–) {
leds[onLedNumber] = CRGB(redPx, grnPx, bluePx);
FastLED.show();
delay(fDelay);
}
for (int grnPx = grnLow; grnPx < grnHigh; grnPx++) {
leds[onLedNumber] = CRGB(redPx, grnPx, bluePx);
FastLED.show();
delay(fDelay);
}
}
with something that uses EVERY_N_MILLISECONDS and fadeLightBy to achieve the same without using any delay() so that I can get non-blocking code?
Basically it is pulsing the green value up and down by a calculated amount.
marmil
(Marc Miller)
March 1, 2016, 5:06pm
2
How long is the delay? Is it variable or set? I’m just trying to think how it might be reworked.
marmil
(Marc Miller)
March 1, 2016, 5:08pm
3
Also where is this routine being called in the main loop? Can you post the code to pastebin or gist?
@marmil This is the original code - https://github.com/timpear/NeoCandle/blob/master/NeoCandle/NeoCandle.ino
This is my latest code that works and has the delay removed - http://pastebin.com/fdgK1b3s
I am trying to simplify it as I am now scaling it up to track multiple ‘candles’ that start and end at different times. At the moment I am trying to introduce a timeout function rather than using static variables, but i have a feeling that the EVERY_N_MILLISECONDS could also work