hi,
i'm using FASTLED library to show an animation,
and i'm showing currently on my led shades of specific color (pink in this example)
what i want it that animation to "flow"
meaning right now the darkest color is in 0 and the brightest is in 300.
i want it to flow meaning it will move up this pattern over and over again,
(like darkest color will be 1, brightest will be 0(because it will repeat itself), then darkest color will be 2 brightest will be 1... etc etc)
hope it makes sense
i tried multiple ways to achieve this and i fail every time
this is my function where i show the gradient
loop() {
FastLED.show();
FastLED.delay(1000/FRAMES_PER_SECOND);
gradientFlow();
}
void gradientFlow() {
for( int i = 0; i < NUM_LEDS; i++) {
leds[i] = CRGB( round (170+(i*0.26666)), 0, round (20+(i*0.26666)));
}
}
i tried passing an interval to the function and then move the darkest / lightest color based on that but that didn't work (this is what i tried >)
loop() {
FastLED.show();
FastLED.delay(1000/FRAMES_PER_SECOND);
gradientFlow();
}
int gradientInterval = o;
void gradientFlow() {
for( int i = gradientInterval ; i < NUM_LEDS; i++) {
leds[i] = CRGB( round (170+((i-gradientInterval)*0.26666)), 0, round (20+((i-gradientInterval)*0.26666)));
}
if (gradientInterval < NUM_LEDS) {
gradientInterval = gradientInterval + 1;
}
}
which in my head would suppose to achieve what i wanted as every loop it will go there and start that "wave" from +1 led, and fix the colors appropriately
but it doesn't work i keep seeing the same pattern
i know it's hard to explain what i want hope it made some sense in here ?
any help in how to achieve this ? or what am i doing wrong ?
but now i came into another problem (that can be another question but maybe if you solved that one you can also solve the second problem ?
so in short, it works, it makes the pattern repeate and it's all amazing
the problem is... that the pattern started from darkest, to lightest, so when it repeates it just looks wierd becaouse it causes it to be from lightest bolb... imidiatly to darkest one which looks bad
so i fixed it by making the "wave" or the "gradient" like go half the strip to brightest color
and go half the strip to darkest color
so the start bolb and end bolb are the same color now so if this will repeate it can be amazing
here is the code i did to achieve that
for (int i = 0; i < NUM_LEDS; i++){
if (i < (NUM_LEDS/2)) {
leds[i] = CRGB( round (170 + (i * 0.533333)), 0, round (20 + (i * 0.533333)));
} else {
leds[i] = CRGB( round (330 - (i * 0.533333)), 0, round (180 - (i * 0.533333)));
}
}
but the issue now that if i add your fix it wouldn't work, becaouse it wouldn't know the num/2 anymore, and it all gets wierd...
Based on this updated code i showed in here
do you know of a way to achieve what i achieved before with your method
how to offset this one ?
for (int i = 0; i < NUM_LEDS; i++){
int index = (i + offset) % NUM_LEDS;
if (i < (NUM_LEDS/2)) {
leds[index] = CRGB( round (170 + (i * 0.533333)), 0, round (20 + (i * 0.533333)));
} else {
leds[index] = CRGB( round (330 - (i * 0.533333)), 0, round (180 - (i * 0.533333)));
}
}
Yes, and in the version that you said worked "leds 0-300 go slowly to brightest". That didn't prevent the offset from working. Are you not passing the offset anymore? Are you no changing the offset?
no I copy pasted same code
first time without that condition that from 0-150 it worked
and second time with that 0-150 and 150-300 it didn't work
I didn't do anything different just copy pasted