diff --git a/wled00/WS2812FX.cpp b/wled00/WS2812FX.cpp
index 6c8ce598..e9ba412a 100644
--- a/wled00/WS2812FX.cpp
+++ b/wled00/WS2812FX.cpp
@@ -228,7 +228,6 @@ void WS2812FX::mode_static(void) {
setPixelColor(i, _color);
}
show();
-
_mode_delay = 25;
}
@@ -1688,24 +1687,40 @@ void WS2812FX::setLedCount(uint16_t i)
void WS2812FX::setPixelColor(uint16_t i, uint32_t c)
{
+ #ifdef RGBW
+ NeoPixelBrightnessBus::SetPixelColor(i, RgbwColor((c>>16) & 0xFF, (c>>8) & 0xFF, (c) & 0xFF, (c>>24) & 0xFF));
+ #else
NeoPixelBrightnessBus::SetPixelColor(i, RgbColor((c>>16) & 0xFF, (c>>8) & 0xFF, (c) & 0xFF));
+ #endif
}
void WS2812FX::setPixelColor(uint16_t i, uint8_t r, uint8_t g, uint8_t b, uint8_t w)
{
#ifdef RGBW
-
+ NeoPixelBrightnessBus::SetPixelColor(i, RgbwColor(r,g,b,w));
+ #else
NeoPixelBrightnessBus::SetPixelColor(i, RgbColor(r,g,b));
+ #endif
}
void WS2812FX::setPixelColor(uint16_t i, uint8_t r, uint8_t g, uint8_t b)
{
+ #ifdef RGBW
+ NeoPixelBrightnessBus::SetPixelColor(i, RgbwColor(r,g,b,0));
+ #else
NeoPixelBrightnessBus::SetPixelColor(i, RgbColor(r,g,b));
+ #endif
}
uint32_t WS2812FX::getPixelColor(uint16_t i)
{
- return NeoPixelBrightnessBus::GetPixelColor(i).R*65536 + NeoPixelBrightnessBus::GetPixelColor(i).G*256 + NeoPixelBrightnessBus::GetPixelColor(i).B;
+ #ifdef RGBW
+ RgbwColor lColor = NeoPixelBrightnessBus::GetPixelColor(i);
+ return lColor.W*16777216 + lColor.R*65536 + lColor.G*256 + lColor.B;
+ #else
+ RgbColor lColor = NeoPixelBrightnessBus::GetPixelColor(i);
+ return lColor.R*65536 + lColor.G*256 + lColor.B;
+ #endif
}
void WS2812FX::setBrightness(uint8_t b)
@@ -1722,7 +1737,11 @@ void WS2812FX::show()
void WS2812FX::clear()
{
+ #ifdef RGBW
+ NeoPixelBrightnessBus::ClearTo(RgbwColor(0));
+ #else
NeoPixelBrightnessBus::ClearTo(RgbColor(0));
+ #endif
}
void WS2812FX::begin()
diff --git a/wled00/wled00.ino b/wled00/wled00.ino
index b60d44e5..b68564f4 100644
--- a/wled00/wled00.ino
+++ b/wled00/wled00.ino
@@ -20,7 +20,7 @@
#include "CallbackFunction.h"
//version in format yymmddb (b = daily build)
-#define VERSION 1709251
+#define VERSION 1710120
//uncomment if you have an RGBW strip
#define RGBW
@@ -115,14 +115,12 @@ boolean alexaNotify = false;
double transitionResolution = 0.011;
-boolean rgbwEnabled = false;
-
//Internal vars
byte col[]{0, 0, 0};
byte col_old[]{0, 0, 0};
byte col_t[]{0, 0, 0};
byte col_it[]{0, 0, 0};
-byte whiteVal;
+byte white, white_old, white_t, white_it;
unsigned long transitionStartTime;
unsigned long nightlightStartTime;
float tper_last = 0;
diff --git a/wled00/wled01_eeprom.ino b/wled00/wled01_eeprom.ino
index e1e97e03..4f1b8667 100644
--- a/wled00/wled01_eeprom.ino
+++ b/wled00/wled01_eeprom.ino
@@ -102,7 +102,6 @@ void saveSettingsToEEPROM()
EEPROM.write(369, turnOnAtBoot);
EEPROM.write(370, useHSBDefault);
EEPROM.write(371, white_s);
- EEPROM.write(372, rgbwEnabled);
EEPROM.commit();
}
@@ -215,6 +214,5 @@ void loadSettingsFromEEPROM()
turnOnAtBoot = EEPROM.read(369);
useHSBDefault = EEPROM.read(370);
white_s = EEPROM.read(371);
- rgbwEnabled = EEPROM.read(372);
useHSB = useHSBDefault;
}
diff --git a/wled00/wled02_xml.ino b/wled00/wled02_xml.ino
index 99550f38..d4e2e4a2 100644
--- a/wled00/wled02_xml.ino
+++ b/wled00/wled02_xml.ino
@@ -34,8 +34,11 @@ void XML_response()
resp = resp + "";
resp = resp + effectSpeed;
resp = resp + "";
- if (rgbwEnabled) {resp = resp + whiteVal;}
- else {resp = resp + "-1";}
+ #ifdef RGBW
+ resp = resp + white;
+ #else
+ resp = resp + "-1";
+ #endif
resp = resp + "";
resp = resp + useHSB;
resp = resp + "";
@@ -112,7 +115,9 @@ void XML_response_settings()
resp = resp + col_s[i];
resp = resp + "";
}
- resp = resp + "";
+ resp = resp + "";
+ resp = resp + white_s;
+ resp = resp + "";
resp = resp + bri_s;
resp = resp + "";
resp = resp + "";
diff --git a/wled00/wled03_set.ino b/wled00/wled03_set.ino
index 278ffb9d..f2b3bf4a 100644
--- a/wled00/wled03_set.ino
+++ b/wled00/wled03_set.ino
@@ -130,6 +130,11 @@ void handleSettingsSet()
int i = server.arg("CLDFB").toInt();
if (i >= 0 && i <= 255) col_s[2] = i;
}
+ if (server.hasArg("CLDFW"))
+ {
+ int i = server.arg("CLDFW").toInt();
+ if (i >= 0 && i <= 255) white_s = i;
+ }
if (server.hasArg("CLDFA"))
{
int i = server.arg("CLDFA").toInt();
@@ -248,6 +253,10 @@ boolean handleSet(String req)
if (pos > 0) {
col[2] = req.substring(pos + 2).toInt();
}
+ pos = req.indexOf("W=");
+ if (pos > 0) {
+ white = req.substring(pos + 2).toInt();
+ }
pos = req.indexOf("FX=");
if (pos > 0) {
if (effectCurrent != req.substring(pos + 3).toInt())
diff --git a/wled00/wled07_notify.ino b/wled00/wled07_notify.ino
index 1894940f..b39edb08 100644
--- a/wled00/wled07_notify.ino
+++ b/wled00/wled07_notify.ino
@@ -25,7 +25,7 @@ void notify(uint8_t callMode)
udpOut[7] = nightlightDelayMins;
udpOut[8] = effectCurrent;
udpOut[9] = effectSpeed;
- udpOut[10] = whiteVal;
+ udpOut[10] = white;
IPAddress broadcastIp;
broadcastIp = ~WiFi.subnetMask() | WiFi.gatewayIP();
@@ -47,7 +47,7 @@ void handleNotifications()
col[0] = udpIn[3];
col[1] = udpIn[4];
col[2] = udpIn[5];
- whiteVal = udpIn[10];
+ white = udpIn[10];
if (udpIn[8] != effectCurrent)
{
effectCurrent = udpIn[8];
diff --git a/wled00/wled08_led.ino b/wled00/wled08_led.ino
index c4f16dff..5e802d77 100644
--- a/wled00/wled08_led.ino
+++ b/wled00/wled08_led.ino
@@ -12,12 +12,21 @@ void setAllLeds() {
} else {
strip.setBrightness(val);
}
+ #ifdef RGBW
+ if (useGammaCorrectionRGB)
+ {
+ strip.setColor(gamma8[col_t[0]], gamma8[col_t[1]], gamma8[col_t[2]], gamma8[white_t]);
+ } else {
+ strip.setColor(col_t[0], col_t[1], col_t[2], white_t);
+ }
+ #else
if (useGammaCorrectionRGB)
{
strip.setColor(gamma8[col_t[0]], gamma8[col_t[1]], gamma8[col_t[2]]);
} else {
strip.setColor(col_t[0], col_t[1], col_t[2]);
}
+ #endif
}
void setLedsStandard()
@@ -25,10 +34,12 @@ void setLedsStandard()
col_old[0] = col[0];
col_old[1] = col[1];
col_old[2] = col[2];
+ white_old = white;
bri_old = bri;
col_t[0] = col[0];
col_t[1] = col[1];
col_t[2] = col[2];
+ white_t = white;
bri_t = bri;
setAllLeds();
}
@@ -36,7 +47,7 @@ void setLedsStandard()
void colorUpdated(int callMode)
{
//call for notifier -> 0: init 1: direct change 2: button 3: notification 4: nightlight 5: other (no not.) (NN)6: fx changed
- if (col[0] == col_it[0] && col[1] == col_it[1] && col[2] == col_it[2] && bri == bri_it)
+ if (col[0] == col_it[0] && col[1] == col_it[1] && col[2] == col_it[2] && white == white_it && bri == bri_it)
{
if (callMode == 6) notify(6);
return; //no change
@@ -50,6 +61,7 @@ void colorUpdated(int callMode)
col_it[0] = col[0];
col_it[1] = col[1];
col_it[2] = col[2];
+ white_it = white;
bri_it = bri;
if (bri > 0) bri_last = bri;
notify(callMode);
@@ -60,6 +72,7 @@ void colorUpdated(int callMode)
col_old[0] = col_t[0];
col_old[1] = col_t[1];
col_old[2] = col_t[2];
+ white_old = white_t;
bri_old = bri_t;
tper_last = 0;
}
@@ -93,7 +106,8 @@ void handleTransitions()
col_t[0] = col_old[0]+((col[0] - col_old[0])*tper);
col_t[1] = col_old[1]+((col[1] - col_old[1])*tper);
col_t[2] = col_old[2]+((col[2] - col_old[2])*tper);
- bri_t = bri_old+((bri - bri_old)*tper);
+ white_t = white_old +((white - white_old )*tper);
+ bri_t = bri_old +((bri - bri_old )*tper);
}
setAllLeds();
}