I'm looking for ways to adapt Elco Jacobs' ShiftPWM Non-Blocking for single color fades. The end goal is to have a fade spread across several leds (of a single colour) rather than fade in one by one.
Eventually, I'd like to be able to address the particular order of leds to fade in/out through an array but this is another matter.
I've looked through the CShiftPWM.cpp and found the code below. Is there a way I could adjust this code and embedded within a sketch to work for a single color - a wide fade over several leds? I'm getting a bit lost in the code here.
If not this, any suggestions on an alternative?
Bringing in the array for specific leds will be the next issue.
Hardware in use: four x ... 32 channel MOSFET boards, P-channel MOSFET board - Other Hardware Development - Arduino Forum which has worked great for other projects. See here: CAFKA.18: Negotiating +/- by Marcia Huyer - YouTube
For this project a total of 16 shift registers
void CShiftPWM::SetHSV(int led, unsigned int hue, unsigned int sat, unsigned int val, int offset){
unsigned char r=0,g=0,b=0;
unsigned int H_accent = hue/60;
unsigned int bottom = ((255 - sat) * val)>>8;
unsigned int top = val;
unsigned char rising = ((top-bottom) *(hue%60 ) ) / 60 + bottom;
unsigned char falling = ((top-bottom) *(60-hue%60) ) / 60 + bottom;
switch(H_accent) {
case 0:
r = top;
g = rising;
b = bottom;
break;
case 1:
r = falling;
g = top;
b = bottom;
break;
case 2:
r = bottom;
g = top;
b = rising;
break;
case 3:
r = bottom;
g = falling;
b = top;
break;
case 4:
r = rising;
g = bottom;
b = top;
break;
case 5:
r = top;
g = bottom;
b = falling;
break;
}
SetRGB(led,r,g,b,offset);
}
Thanks!!