Started working on RGBW support
This commit is contained in:
parent
7f42ed2d32
commit
8a38af0282
@ -104,6 +104,11 @@ void WS2812FX::setColor(uint8_t r, uint8_t g, uint8_t b) {
|
||||
setColor(((uint32_t)r << 16) | ((uint32_t)g << 8) | b);
|
||||
}
|
||||
|
||||
|
||||
void WS2812FX::setColor(uint8_t r, uint8_t g, uint8_t b, uint8_t w) {
|
||||
setColor(((uint32_t)w << 24)|((uint32_t)r << 16) | ((uint32_t)g << 8) | b);
|
||||
}
|
||||
|
||||
void WS2812FX::setColor(uint32_t c) {
|
||||
_color = c;
|
||||
_mode_color = _color;
|
||||
@ -1686,6 +1691,13 @@ void WS2812FX::setPixelColor(uint16_t i, uint32_t c)
|
||||
NeoPixelBrightnessBus::SetPixelColor(i, RgbColor((c>>16) & 0xFF, (c>>8) & 0xFF, (c) & 0xFF));
|
||||
}
|
||||
|
||||
void WS2812FX::setPixelColor(uint16_t i, uint8_t r, uint8_t g, uint8_t b, uint8_t w)
|
||||
{
|
||||
#ifdef RGBW
|
||||
|
||||
NeoPixelBrightnessBus::SetPixelColor(i, RgbColor(r,g,b));
|
||||
}
|
||||
|
||||
void WS2812FX::setPixelColor(uint16_t i, uint8_t r, uint8_t g, uint8_t b)
|
||||
{
|
||||
NeoPixelBrightnessBus::SetPixelColor(i, RgbColor(r,g,b));
|
||||
|
@ -103,13 +103,19 @@
|
||||
#define FX_MODE_DUAL_COLOR_WIPE_OUT_IN 51
|
||||
#define FX_MODE_CIRCUS_COMBUSTUS 52
|
||||
|
||||
#ifdef RGBW
|
||||
class WS2812FX : public NeoPixelBrightnessBus<NeoGrbwFeature, NeoEsp8266Uart800KbpsMethod> {
|
||||
#else
|
||||
class WS2812FX : public NeoPixelBrightnessBus<NeoGrbFeature, NeoEsp8266Uart800KbpsMethod> {
|
||||
|
||||
#endif
|
||||
typedef void (WS2812FX::*mode_ptr)(void);
|
||||
|
||||
public:
|
||||
|
||||
#ifdef RGBW
|
||||
WS2812FX(uint16_t n) : NeoPixelBrightnessBus<NeoGrbwFeature, NeoEsp8266Uart800KbpsMethod>(n) {
|
||||
#else
|
||||
WS2812FX(uint16_t n) : NeoPixelBrightnessBus<NeoGrbFeature, NeoEsp8266Uart800KbpsMethod>(n) {
|
||||
#endif
|
||||
_mode[FX_MODE_STATIC] = &WS2812FX::mode_static;
|
||||
_mode[FX_MODE_BLINK] = &WS2812FX::mode_blink;
|
||||
_mode[FX_MODE_BREATH] = &WS2812FX::mode_breath;
|
||||
@ -242,6 +248,7 @@ class WS2812FX : public NeoPixelBrightnessBus<NeoGrbFeature, NeoEsp8266Uart800Kb
|
||||
increaseSpeed(uint8_t s),
|
||||
decreaseSpeed(uint8_t s),
|
||||
setColor(uint8_t r, uint8_t g, uint8_t b),
|
||||
setColor(uint8_t r, uint8_t g, uint8_t b, uint8_t w),
|
||||
setColor(uint32_t c),
|
||||
setBrightness(uint8_t b),
|
||||
increaseBrightness(uint8_t s),
|
||||
@ -284,6 +291,7 @@ class WS2812FX : public NeoPixelBrightnessBus<NeoGrbFeature, NeoEsp8266Uart800Kb
|
||||
clear(void),
|
||||
setPixelColor(uint16_t i, uint32_t c),
|
||||
setPixelColor(uint16_t i, uint8_t r, uint8_t g, uint8_t b),
|
||||
setPixelColor(uint16_t i, uint8_t r, uint8_t g, uint8_t b, uint8_t w),
|
||||
dofade(void),
|
||||
strip_off(void),
|
||||
strip_off_respectLock(void),
|
||||
|
@ -22,6 +22,9 @@
|
||||
//version in format yymmddb (b = daily build)
|
||||
#define VERSION 1709251
|
||||
|
||||
//uncomment if you have an RGBW strip
|
||||
#define RGBW
|
||||
|
||||
//to toggle usb serial debug (un)comment following line
|
||||
//#define DEBUG
|
||||
|
||||
@ -84,6 +87,7 @@ IPAddress staticsubnet(255, 255, 255, 0);
|
||||
boolean useHSB = false, useHSBDefault = false;
|
||||
boolean turnOnAtBoot = true;
|
||||
byte col_s[]{255, 159, 0};
|
||||
byte white_s = 0;
|
||||
byte bri_s = 127;
|
||||
uint8_t bri_nl = 0, bri_nls;
|
||||
boolean fadeTransition = true;
|
||||
@ -111,11 +115,14 @@ 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;
|
||||
unsigned long transitionStartTime;
|
||||
unsigned long nightlightStartTime;
|
||||
float tper_last = 0;
|
||||
|
@ -101,6 +101,8 @@ void saveSettingsToEEPROM()
|
||||
EEPROM.write(368, abs(arlsOffset));
|
||||
EEPROM.write(369, turnOnAtBoot);
|
||||
EEPROM.write(370, useHSBDefault);
|
||||
EEPROM.write(371, white_s);
|
||||
EEPROM.write(372, rgbwEnabled);
|
||||
EEPROM.commit();
|
||||
}
|
||||
|
||||
@ -212,5 +214,7 @@ void loadSettingsFromEEPROM()
|
||||
if (!arlsSign) arlsOffset = -arlsOffset;
|
||||
turnOnAtBoot = EEPROM.read(369);
|
||||
useHSBDefault = EEPROM.read(370);
|
||||
white_s = EEPROM.read(371);
|
||||
rgbwEnabled = EEPROM.read(372);
|
||||
useHSB = useHSBDefault;
|
||||
}
|
||||
|
@ -33,8 +33,10 @@ void XML_response()
|
||||
resp = resp + effectCurrent;
|
||||
resp = resp + "</fx><sx>";
|
||||
resp = resp + effectSpeed;
|
||||
resp = resp + "</sx>";
|
||||
resp = resp + "<md>";
|
||||
resp = resp + "</sx><wv>";
|
||||
if (rgbwEnabled) {resp = resp + whiteVal;}
|
||||
else {resp = resp + "-1";}
|
||||
resp = resp + "</wv><md>";
|
||||
resp = resp + useHSB;
|
||||
resp = resp + "</md><desc>";
|
||||
resp = resp + serverDescription;
|
||||
|
@ -25,6 +25,7 @@ void notify(uint8_t callMode)
|
||||
udpOut[7] = nightlightDelayMins;
|
||||
udpOut[8] = effectCurrent;
|
||||
udpOut[9] = effectSpeed;
|
||||
udpOut[10] = whiteVal;
|
||||
|
||||
IPAddress broadcastIp;
|
||||
broadcastIp = ~WiFi.subnetMask() | WiFi.gatewayIP();
|
||||
@ -46,6 +47,7 @@ void handleNotifications()
|
||||
col[0] = udpIn[3];
|
||||
col[1] = udpIn[4];
|
||||
col[2] = udpIn[5];
|
||||
whiteVal = udpIn[10];
|
||||
if (udpIn[8] != effectCurrent)
|
||||
{
|
||||
effectCurrent = udpIn[8];
|
||||
|
Loading…
Reference in New Issue
Block a user