Hello together,
I’m working on my first lambda effect, but can’t get it work. My c-programming times are already a few years ago - so maybe there is just a stupid mistake…
For this effect I have 10 LEDs. I would like to program a running light. However, the “fade-in” time should be around 500ms. When the brightness of the first LED is at 25, the second should start to get brighter, when this is at 25, the third starts and so on. So that when the first one is approximately at full brightness, the 10th one just starts to get brighter. The first LED is the Last in the Array, so I’ve to count backwards.
This is what I have so far:
- platform: partition
name: "LED Partition Stairs"
id: LedPartitionStairs
segments:
- id: FlurGrossRGB
from: 11
to: 24
effects:
- addressable_lambda:
name: Staireffect
update_interval: 2ms # 2ms * 255(max brightness) = 510ms
lambda: |-
static int amount = 0;
static int x = 0;
static int led[10] = {0}; //for calculating the brighness per LED channel
if (initial_run) {
amount = it.size() - 1;
it.all() = Color(0,0,0);
}
for (x = it.size() -1; x >= 0; --x){ //count down from highest led to lowest
if(x == it.size() - 1){ //If it is the first (or highest number) just count up
++led[x];
if (led[x] >= 255){ //Limit to 255
led[x] = 255;
}
}
else{
if(led[x+1] > 25){ //If the previous LED is above 25 start counting up
++led[x];
if(led[x] >= 255){ //limit to 255
led[x] = 255;
}
}
}
}
for (x = 0; x <= it.size() - 1; ++x) {
it[x] = Color(led[x],led[x],led[x]); //set the calculated value for each led
}
What I see is, that only the first LED light up, at full brightness, but then nothing happens anymore. I tried to set update_intervall at 16ms to see some progress, but nothing changed.
What am I missing here? I appreciate every help!!!