Hello together, sorry for my bad explanation of my problem a few days before. I will try it one more time a little bit easier.
-
What is my project?
I have installed 2 or more Led Stripes in my car one from the footwell of the driver side up to under the door. The same on the co driver side with another Led Stripe. -
What is my goal in a simple way?
In a simple way I have a specific color or gradient in the footwell and if I open the door I want to blend to another color(colorarray) in the footwell and if I close the door the leds should blend back to the old color (colorarray). -
Specials
Blending should be slowly and fluently and if the blending isn’t ready and I close or open the door it should be blend seamless–> it has to store the values.
I have 4 doors and all can be open simutanously and blending should work also very fine. All should work parallel, thats why I increase the blending level only by one each cycle. -
What I have done
I have written an function and a sketch where I have these functionality, but the code is big and I used a lot of variables to control the blending (blend up, blend down, first cycle…). → when I have 4 doors I have to multiply this and this isn’t very clear and a lot of code. I want more structure… -
Thoughts on this
My actual thoughts are to make a class with an object for every door where every door has it’s methods and variables. There I can store the information and create easily new objects, but I don’t know how this exactly works.
All in all, maybe someone of you has an easier way to solve this problem I would be very happy or you can help me with the architecture how to handle the classes…
Thanks for your help!!
Any suggestions?
@Kev_Zhu @Mark_Kriegsman
////////////////////////////////////CODE////////////////////////////////
Some code extracts:
blend up function:
// blend up
uint8_t Licht_hochdimmen(uint8_t k, uint8_t i_Stripe_num, uint8_t i_start_led, uint8_t i_num_led, CHSV led_array)
{
// first blend cycle and last blend complete
if(k==0 && b_Licht_dimm_fertig)
{
// copy startvalue
memcpy8(leds_startvalue_chsv+i_start_led,leds_chsv+i_start_led,(i_num_led*3)); // Dest, Source, Bytes
memcpy8(leds_nextblend+i_start_led,leds_chsv+i_start_led,(i_num_led*3)); // Dest, Source, Bytes
}
if(k==0 &&!b_Licht_dimm_fertig) // blend down wasnt complete --> modified start value
{
memcpy8(leds_nextblend+i_start_led,leds_chsv+i_start_led,(i_num_led*3)); // Dest, Source, Bytes
}
b_Licht_dimm_fertig=false; // Information schreiben, dass aktuell gedimt wird, damit nicht das array kopiert wird // blend active --> not copy the array
// blending of colors
for(uint8_t i=0;i<i_num_led;i++)
{
leds_chsv[i+i_start_led]=blend(leds_nextblend[i+i_start_led],led_array[i],k, SHORTEST_HUES);
}
if(k >= 254)
{
k=0;
b_Licht_dimm_fertig=true;
b_Licht_up=false;
}
else
{
k=k+2;
}
// return counter value
return k;
}
Call of the function in loop:
// interrupt from button down
if(b_Licht_active && b_Licht_up)
{
{
// create the blend color array
CHSV Test[3];
fill_rainbow(Test,3,0,10);
///
// counter value of blending level
//light dimm_up(count value,stripe_num,start_led,num_leds,ledarray);
Licht_Step=Licht_hochdimmen(Licht_Step,0,2,3,Test);
//Licht_time=0;
}
}


