I use the FastLED library on the Arduino and i use snippets found on the net (source not known anymore)
I hope i got everything together her for you. I had to piece it together out of a larger chunck i made.
Global variables
Methode configuration. Need to do this only once
And call this methode each time in main()
VBscript code voor RGB to HSV to RGB conversie
http://stackoverflow.com/questions/3...b-color-to-hsv
Or
http://www.xtremevbtalk.com/tech-dis...b-hsv-rgb.html
Or
http://stackoverflow.com/questions/4...b-color-values
I hope i got everything together her for you. I had to piece it together out of a larger chunck i made.
Global variables
Code:
// PULSE Variables uint8_t hueA; uint8_t satA; float valueMin; uint8_t hueB; uint8_t satB; float valueMax; uint8_t hue; uint8_t sat; float val; uint8_t hueDelta; static float delta; static float PulseSpeed; CHSV objHSVStart; CHSV objHSVEnd; CRGB colorRGBStart; CRGB colorRGBEnd;
Code:
void SetupEffect() { colorRGBStart.r = R; colorRGBStart.g = G; colorRGBStart.b = B; colorRGBEnd.r = R; colorRGBEnd.g = G; colorRGBEnd.b = B; objHSVStrat = rgb2hsv_approximate(colorRGBStart); objHSVEnd = rgb2hsv_approximate(colorRGBEnd); hueA = objHSVStart.h; satA = objHSVStart.s; valueMin = objHSVStart.v hueB = objHSVEnd.h; satB = objHSVEnd.s; valueMax = objHSVEnd.v; if((valueMin + 20) > valueMax) { valueMax = valueMin + 20; if(valueMax > 255) valueMax = 255; } hue = hueA; sat = satA; val = valueMin; hueDelta = hueA - hueB; delta = (valueMax - valueMin) / 2.35040238; // Do Not Edit }
Code:
void DoEffect(){ float dV = ((exp(sin(PulseSpeed * millis()/2000.0*PI)) -0.36787944) * delta); val = valueMin + dV; hue = map(val, valueMin, valueMax, hueA, hueB); // Map hue based on current val sat = map(val, valueMin, valueMax, satA, satB); // Map sat based on current val leds0[0] = CHSV(hue, sat, val); // This controles the LEDstring but you have to convert HSV back to RGB here end send that value to the device }
http://stackoverflow.com/questions/3...b-color-to-hsv
Or
http://www.xtremevbtalk.com/tech-dis...b-hsv-rgb.html
Or
http://stackoverflow.com/questions/4...b-color-values
Comment