Skip to content
This repository was archived by the owner on Oct 6, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## Changelog

0.8.1 (29.06.2016)
* fix HSVSetOutput / RAWSetOutput
* increase default queue size to 100 items
10 changes: 5 additions & 5 deletions RGBWWLed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ void RGBWWLed::setOutput(ChannelOutput& output) {
colorutils.correctBrightness(output);
_current_output = output;
debugRGBW("R:%i | G:%i | B:%i | WW:%i | CW:%i", output.r, output.g, output.b, output.ww, output.cw);
_pwm_output->setOutput(RGBWW_dim_curve[output.r],
RGBWW_dim_curve[output.g],
RGBWW_dim_curve[output.b],
RGBWW_dim_curve[output.ww],
RGBWW_dim_curve[output.cw]);
_pwm_output->setOutput((output.r == -1)?-1:RGBWW_dim_curve[output.r],
(output.g == -1)?-1:RGBWW_dim_curve[output.g],
(output.b == -1)?-1:RGBWW_dim_curve[output.b],
(output.ww == -1)?-1:RGBWW_dim_curve[output.ww],
(output.cw == -1)?-1:RGBWW_dim_curve[output.cw]);
}
};

Expand Down
4 changes: 2 additions & 2 deletions RGBWWLed.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@
#define RGBWW_CALC_DEPTH 8
#endif

#define RGBWW_VERSION "0.8.0"
#define RGBWW_VERSION "0.8.1"
#define RGBWW_CALC_WIDTH int(pow(2, RGBWW_CALC_DEPTH))
#define RGBWW_CALC_MAXVAL int(RGBWW_CALC_WIDTH - 1)
#define RGBWW_CALC_HUEWHEELMAX int(RGBWW_CALC_MAXVAL * 6)


#define RGBWW_UPDATEFREQUENCY 50
#define RGBWW_MINTIMEDIFF int(1000 / RGBWW_UPDATEFREQUENCY)
#define RGBWW_ANIMATIONQSIZE 50
#define RGBWW_ANIMATIONQSIZE 100
#define RGBWW_WARMWHITEKELVIN 2700
#define RGBWW_COLDWHITEKELVIN 6000

Expand Down
21 changes: 19 additions & 2 deletions RGBWWLedAnimation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@ bool HSVSetOutput::run() {
if (count == 0) {
rgbwwctrl->setOutput(outputcolor);
}
count += 1;
if (steps != 0) {
if (count < steps) {
return false;
}
}
count += 1;

return true;
}

Expand Down Expand Up @@ -194,12 +195,12 @@ bool RAWSetOutput::run() {
if (count == 0) {
rgbwwctrl->setOutput(outputcolor);
}
count += 1;
if (steps != 0) {
if (count < steps) {
return false;
}
}
count += 1;
return true;
}

Expand Down Expand Up @@ -231,8 +232,24 @@ RAWTransition::RAWTransition(const ChannelOutput& output_from, const ChannelOutp
bool RAWTransition::init() {
if (!_hasbasecolor) {
_basecolor = rgbwwctrl->getCurrentOutput();
} else {
// There may be blanks in the basecolor, so fill them from current output.
ChannelOutput current = rgbwwctrl->getCurrentOutput();
if(_basecolor.r == -1)_basecolor.r = current.r;
if(_basecolor.g == -1)_basecolor.g = current.g;
if(_basecolor.b == -1)_basecolor.b = current.b;
if(_basecolor.ww == -1)_basecolor.ww = current.ww;
if(_basecolor.cw == -1)_basecolor.cw = current.cw;
}

// Fill in the "blanks" in _finalcolor with the respective values from _basecolor
if(_finalcolor.r == -1)_finalcolor.r = _basecolor.r;
if(_finalcolor.g == -1)_finalcolor.g = _basecolor.g;
if(_finalcolor.b == -1)_finalcolor.b = _basecolor.b;
if(_finalcolor.ww == -1)_finalcolor.ww = _basecolor.ww;
if(_finalcolor.cw == -1)_finalcolor.cw = _basecolor.cw;


// don`t animate if the color is already the same
if (_basecolor.r == _finalcolor.r && _basecolor.g == _finalcolor.g && _basecolor.b == _finalcolor.b &&
_basecolor.ww == _finalcolor.ww && _basecolor.cw == _finalcolor.cw) {
Expand Down
20 changes: 10 additions & 10 deletions RGBWWLedColor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ void RGBWWColorUtils::getBrightnessCorrection(int& r, int& g, int& b, int& ww, i


void RGBWWColorUtils::correctBrightness(ChannelOutput& output) {
output.red = (output.red * _BrightnessFactor[RGBWW_CHANNELS::RED]) / RGBWW_CALC_MAXVAL;
output.green = (output.green * _BrightnessFactor[RGBWW_CHANNELS::GREEN]) / RGBWW_CALC_MAXVAL;
output.blue = (output.blue * _BrightnessFactor[RGBWW_CHANNELS::BLUE]) / RGBWW_CALC_MAXVAL;
output.warmwhite = (output.warmwhite * _BrightnessFactor[RGBWW_CHANNELS::WW]) / RGBWW_CALC_MAXVAL;
output.coldwhite = (output.coldwhite * _BrightnessFactor[RGBWW_CHANNELS::CW]) / RGBWW_CALC_MAXVAL;
if(output.red != -1) output.red = (output.red * _BrightnessFactor[RGBWW_CHANNELS::RED]) / RGBWW_CALC_MAXVAL;
if(output.green != -1) output.green = (output.green * _BrightnessFactor[RGBWW_CHANNELS::GREEN]) / RGBWW_CALC_MAXVAL;
if(output.blue != -1) output.blue = (output.blue * _BrightnessFactor[RGBWW_CHANNELS::BLUE]) / RGBWW_CALC_MAXVAL;
if(output.warmwhite != -1) output.warmwhite = (output.warmwhite * _BrightnessFactor[RGBWW_CHANNELS::WW]) / RGBWW_CALC_MAXVAL;
if(output.coldwhite != -1) output.coldwhite = (output.coldwhite * _BrightnessFactor[RGBWW_CHANNELS::CW]) / RGBWW_CALC_MAXVAL;
}


Expand Down Expand Up @@ -156,7 +156,7 @@ void RGBWWColorUtils::getHSVcorrection(float& red, float& yellow, float& green,
int wwfactor = ((_ColdWhiteKelvin - rgbw.ct) * RGBWW_CALC_MAXVAL) / (_ColdWhiteKelvin - _WarmWhiteKelvin);
//balance between CW and WW Leds
output.warmwhite = (rgbw.w * wwfactor) /RGBWW_CALC_MAXVAL;
output.coldwhite = (rgbw.w * (1 - wwfactor)) / RGBWW_CALC_MAXVAL;
output.coldwhite = rgbw.w - output.warmwhite;
} else {
// if kelvin outside range - different calculation algorithm
// for now we asume a "neutral white" (0.5 CW, 0.5 WW)
Expand All @@ -167,23 +167,23 @@ void RGBWWColorUtils::getHSVcorrection(float& red, float& yellow, float& green,
case RGBCW:
//TODO implement valid algorithm

output.warmwhite = 0;
output.warmwhite = -1;
output.coldwhite = rgbw.w;
break;

case RGBWW:
//TODO implement valid algorithm
output.warmwhite = rgbw.w;
output.coldwhite = 0;
output.coldwhite = -1;
break;

case RGB:
//TODO implement valid algorithm
output.r += rgbw.w;
output.g += rgbw.w;
output.b += rgbw.w;
output.coldwhite = 0;
output.warmwhite = 0;
output.coldwhite = -1;
output.warmwhite = -1;
break;
}
}
Expand Down
15 changes: 10 additions & 5 deletions RGBWWLedOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ int PWMOutput::getFrequency() {
}

void PWMOutput::setRed(int duty, bool update /* = true */) {
if (duty != getRed()) {
if (duty != getRed() && duty != -1) {
pwm_set_duty(duty, RGBWW_CHANNELS::RED);
_duty[RGBWW_CHANNELS::RED] = pwm_get_duty(RGBWW_CHANNELS::RED);

Expand All @@ -63,7 +63,7 @@ int PWMOutput::getRed(){
}

void PWMOutput::setGreen(int duty, bool update /* = true */) {
if (duty != getGreen()) {
if (duty != getGreen() && duty != -1) {
pwm_set_duty(duty, RGBWW_CHANNELS::GREEN);
_duty[RGBWW_CHANNELS::GREEN] = pwm_get_duty(RGBWW_CHANNELS::GREEN);
if(update) {
Expand All @@ -77,7 +77,7 @@ int PWMOutput::getGreen() {
}

void PWMOutput::setBlue(int duty, bool update /* = true */) {
if (duty != getBlue()) {
if (duty != getBlue() && duty != -1) {
pwm_set_duty(duty, RGBWW_CHANNELS::BLUE);
_duty[RGBWW_CHANNELS::BLUE] = pwm_get_duty(RGBWW_CHANNELS::BLUE);
if(update) {
Expand All @@ -91,7 +91,7 @@ int PWMOutput::getBlue(){
}

void PWMOutput::setWarmWhite(int duty, bool update /* = true */) {
if (duty != getWarmWhite()) {
if (duty != getWarmWhite() && duty != -1) {
pwm_set_duty(duty, RGBWW_CHANNELS::WW);
_duty[RGBWW_CHANNELS::WW] = pwm_get_duty(RGBWW_CHANNELS::WW);
if(update) {
Expand All @@ -105,7 +105,7 @@ int PWMOutput::getWarmWhite() {
}

void PWMOutput::setColdWhite(int duty, bool update /* = true */) {
if (duty != getColdWhite()) {
if (duty != getColdWhite() && duty != -1) {
pwm_set_duty(duty, RGBWW_CHANNELS::CW);
_duty[RGBWW_CHANNELS::CW] = pwm_get_duty(RGBWW_CHANNELS::CW);
if(update) {
Expand Down Expand Up @@ -165,6 +165,7 @@ int PWMOutput::getFrequency() {
}

void PWMOutput::setRed(int value, bool update /* = true */) {
if(value == -1)return;
_duty[RGBWW_CHANNELS::RED] = parseDuty(value);
analogWrite(_pins[RGBWW_CHANNELS::RED], value);
}
Expand All @@ -175,6 +176,7 @@ int PWMOutput::getRed() {


void PWMOutput::setGreen(int value, bool update /* = true */) {
if(value == -1)return;
_duty[RGBWW_CHANNELS::GREEN] = parseDuty(value);
analogWrite(_pins[RGBWW_CHANNELS::GREEN], value);
}
Expand All @@ -184,6 +186,7 @@ int PWMOutput::getGreen() {
}

void PWMOutput::setBlue(int value, bool update /* = true */) {
if(value == -1)return;
_duty[RGBWW_CHANNELS::BLUE] = parseDuty(value);
analogWrite(_pins[RGBWW_CHANNELS::BLUE], value);
}
Expand All @@ -194,6 +197,7 @@ int PWMOutput::getBlue() {


void PWMOutput::setWarmWhite(int value, bool update /* = true */) {
if(value == -1)return;
_duty[RGBWW_CHANNELS::WW] = parseDuty(value);
analogWrite(_pins[RGBWW_CHANNELS::WW], value);
}
Expand All @@ -203,6 +207,7 @@ int PWMOutput::getWarmWhite() {
}

void PWMOutput::setColdWhite(int value, bool update /* = true */) {
if(value == -1)return;
_duty[RGBWW_CHANNELS::CW] = parseDuty(value);
analogWrite(_pins[RGBWW_CHANNELS::CW], value);
}
Expand Down
8 changes: 4 additions & 4 deletions examples/basic/basic.ino
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ RGBWWLed rgbwwctrl;

void saveRGBWW(RGBWWLed* rgbwwctrl) {

HSVK c = rgbwwctrl->getCurrentColor();
HSVCT c = rgbwwctrl->getCurrentColor();
Serial.println("Current color");
Serial.print("H:");
Serial.print(c.h);
Serial.print(" S:+");
Serial.print(c.s);
Serial.print(" V:");
Serial.print(c.v);
Serial.print(" K:");
Serial.println(c.k);
Serial.print(" CT:");
Serial.println(c.ct);

}

Expand All @@ -36,7 +36,7 @@ void setup() {
rgbwwctrl.colorutils.setColorMode(RGBWW_COLORMODE::RGBWWCW);

//show red as initial color
HSVK color = HSVK(0, 100, 100);
HSVCT color = HSVCT(0, 100, 100);
rgbwwctrl.setHSV(color);


Expand Down
4 changes: 2 additions & 2 deletions examples/simple-webserver/simple-webserver.ino
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void handleHSV() {
if (server.hasArg("k")) {
kelvin = server.arg("k").toInt();
}
HSVK color = HSVK(hue, sat, val, kelvin);
HSVCT color = HSVCT(hue, sat, val, kelvin);
rgbled.setHSV(color);
server.send(200, "text/plain", "ok");

Expand All @@ -68,7 +68,7 @@ void handleHSVtransition() {
hue = server.arg("h").toFloat();
sat = server.arg("s").toFloat();
val = server.arg("v").toFloat();
HSVK color(hue, sat, val);
HSVCT color(hue, sat, val);
if (server.hasArg("l")) {
shortway = false;
}
Expand Down