Added basic second color support via HTTP calls &R2= ...
Added second color notifier support
This commit is contained in:
parent
dcc57bee75
commit
c5450229c6
@ -20,7 +20,7 @@
|
|||||||
#include "CallbackFunction.h"
|
#include "CallbackFunction.h"
|
||||||
|
|
||||||
//version in format yymmddb (b = daily build)
|
//version in format yymmddb (b = daily build)
|
||||||
#define VERSION 1711271
|
#define VERSION 1711281
|
||||||
|
|
||||||
|
|
||||||
//If you have an RGBW strip, uncomment first line in WS2812FX.h!
|
//If you have an RGBW strip, uncomment first line in WS2812FX.h!
|
||||||
@ -128,7 +128,10 @@ byte col[]{0, 0, 0};
|
|||||||
byte col_old[]{0, 0, 0};
|
byte col_old[]{0, 0, 0};
|
||||||
byte col_t[]{0, 0, 0};
|
byte col_t[]{0, 0, 0};
|
||||||
byte col_it[]{0, 0, 0};
|
byte col_it[]{0, 0, 0};
|
||||||
|
byte col_sec[]{0, 0, 0};
|
||||||
|
byte col_sec_it[]{0, 0, 0};
|
||||||
byte white, white_old, white_t, white_it;
|
byte white, white_old, white_t, white_it;
|
||||||
|
byte white_sec, white_sec_it;
|
||||||
unsigned long transitionStartTime;
|
unsigned long transitionStartTime;
|
||||||
unsigned long nightlightStartTime;
|
unsigned long nightlightStartTime;
|
||||||
float tper_last = 0;
|
float tper_last = 0;
|
||||||
|
@ -230,6 +230,7 @@ void loadSettingsFromEEPROM()
|
|||||||
apWaitTimeSecs = EEPROM.read(375);
|
apWaitTimeSecs = EEPROM.read(375);
|
||||||
recoveryAPDisabled = EEPROM.read(376);
|
recoveryAPDisabled = EEPROM.read(376);
|
||||||
}
|
}
|
||||||
|
//377-380 reserved for second color default
|
||||||
|
|
||||||
//favorite setting memory (25 slots/ each 20byte)
|
//favorite setting memory (25 slots/ each 20byte)
|
||||||
//400 - 899 reserved
|
//400 - 899 reserved
|
||||||
|
@ -270,6 +270,26 @@ boolean handleSet(String req)
|
|||||||
if (pos > 0) {
|
if (pos > 0) {
|
||||||
white = req.substring(pos + 2).toInt();
|
white = req.substring(pos + 2).toInt();
|
||||||
}
|
}
|
||||||
|
//set 2nd red value
|
||||||
|
pos = req.indexOf("R2=");
|
||||||
|
if (pos > 0) {
|
||||||
|
col_sec[0] = req.substring(pos + 3).toInt();
|
||||||
|
}
|
||||||
|
//set 2nd green value
|
||||||
|
pos = req.indexOf("G2=");
|
||||||
|
if (pos > 0) {
|
||||||
|
col_sec[1] = req.substring(pos + 3).toInt();
|
||||||
|
}
|
||||||
|
//set 2nd blue value
|
||||||
|
pos = req.indexOf("B2=");
|
||||||
|
if (pos > 0) {
|
||||||
|
col_sec[2] = req.substring(pos + 3).toInt();
|
||||||
|
}
|
||||||
|
//set 2nd white value
|
||||||
|
pos = req.indexOf("W2=");
|
||||||
|
if (pos > 0) {
|
||||||
|
white_sec = req.substring(pos + 3).toInt();
|
||||||
|
}
|
||||||
//set current effect index
|
//set current effect index
|
||||||
pos = req.indexOf("FX=");
|
pos = req.indexOf("FX=");
|
||||||
if (pos > 0) {
|
if (pos > 0) {
|
||||||
|
@ -27,6 +27,10 @@ void notify(uint8_t callMode)
|
|||||||
udpOut[9] = effectSpeed;
|
udpOut[9] = effectSpeed;
|
||||||
udpOut[10] = white;
|
udpOut[10] = white;
|
||||||
udpOut[11] = 1; //boolean byte, lowest bit to confirm white value compatibility
|
udpOut[11] = 1; //boolean byte, lowest bit to confirm white value compatibility
|
||||||
|
udpOut[12] = col_sec[0];
|
||||||
|
udpOut[13] = col_sec[1];
|
||||||
|
udpOut[14] = col_sec[2];
|
||||||
|
udpOut[15] = white_sec;
|
||||||
|
|
||||||
IPAddress broadcastIp;
|
IPAddress broadcastIp;
|
||||||
broadcastIp = ~WiFi.subnetMask() | WiFi.gatewayIP();
|
broadcastIp = ~WiFi.subnetMask() | WiFi.gatewayIP();
|
||||||
@ -48,7 +52,14 @@ void handleNotifications()
|
|||||||
col[0] = udpIn[3];
|
col[0] = udpIn[3];
|
||||||
col[1] = udpIn[4];
|
col[1] = udpIn[4];
|
||||||
col[2] = udpIn[5];
|
col[2] = udpIn[5];
|
||||||
if (udpIn[11] %2 == 1) white = udpIn[10]; //check if sending modules white val is inteded
|
col_sec[0] = udpIn[12];
|
||||||
|
col_sec[1] = udpIn[13];
|
||||||
|
col_sec[2] = udpIn[14];
|
||||||
|
if (udpIn[11] %2 == 1) //check if sending modules white val is inteded
|
||||||
|
{
|
||||||
|
white = udpIn[10];
|
||||||
|
white_sec = udpIn[15];
|
||||||
|
}
|
||||||
if (udpIn[8] != effectCurrent)
|
if (udpIn[8] != effectCurrent)
|
||||||
{
|
{
|
||||||
effectCurrent = udpIn[8];
|
effectCurrent = udpIn[8];
|
||||||
@ -60,7 +71,7 @@ void handleNotifications()
|
|||||||
strip.setSpeed(effectSpeed);
|
strip.setSpeed(effectSpeed);
|
||||||
}
|
}
|
||||||
nightlightActive = udpIn[6];
|
nightlightActive = udpIn[6];
|
||||||
if (!udpIn[6])
|
if (!nightlightActive)
|
||||||
{
|
{
|
||||||
bri = udpIn[2];
|
bri = udpIn[2];
|
||||||
colorUpdated(3);
|
colorUpdated(3);
|
||||||
|
@ -15,8 +15,10 @@ void setAllLeds() {
|
|||||||
if (useGammaCorrectionRGB)
|
if (useGammaCorrectionRGB)
|
||||||
{
|
{
|
||||||
strip.setColor(gamma8[col_t[0]], gamma8[col_t[1]], gamma8[col_t[2]], gamma8[white_t]);
|
strip.setColor(gamma8[col_t[0]], gamma8[col_t[1]], gamma8[col_t[2]], gamma8[white_t]);
|
||||||
|
strip.setSecondaryColor(gamma8[col_sec[0]], gamma8[col_sec[1]], gamma8[col_sec[2]], gamma8[white_sec]);
|
||||||
} else {
|
} else {
|
||||||
strip.setColor(col_t[0], col_t[1], col_t[2], white_t);
|
strip.setColor(col_t[0], col_t[1], col_t[2], white_t);
|
||||||
|
strip.setSecondaryColor(col_sec[0], col_sec[1], col_sec[2], white_sec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,10 +37,22 @@ void setLedsStandard()
|
|||||||
setAllLeds();
|
setAllLeds();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool colorChanged()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 3; i++)
|
||||||
|
{
|
||||||
|
if (col[i] != col_it[i]) return true;
|
||||||
|
if (col_sec[i] != col_sec_it[i]) return true;
|
||||||
|
}
|
||||||
|
if (white != white_it || white_sec != white_sec_it) return true;
|
||||||
|
if (bri != bri_it) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void colorUpdated(int callMode)
|
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
|
//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] && white == white_it && bri == bri_it)
|
if (!colorChanged())
|
||||||
{
|
{
|
||||||
if (callMode == 6) notify(6);
|
if (callMode == 6) notify(6);
|
||||||
return; //no change
|
return; //no change
|
||||||
@ -52,7 +66,11 @@ void colorUpdated(int callMode)
|
|||||||
col_it[0] = col[0];
|
col_it[0] = col[0];
|
||||||
col_it[1] = col[1];
|
col_it[1] = col[1];
|
||||||
col_it[2] = col[2];
|
col_it[2] = col[2];
|
||||||
|
col_sec_it[0] = col_sec[0];
|
||||||
|
col_sec_it[1] = col_sec[1];
|
||||||
|
col_sec_it[2] = col_sec[2];
|
||||||
white_it = white;
|
white_it = white;
|
||||||
|
white_sec_it = white_sec;
|
||||||
bri_it = bri;
|
bri_it = bri;
|
||||||
if (bri > 0) bri_last = bri;
|
if (bri > 0) bri_last = bri;
|
||||||
notify(callMode);
|
notify(callMode);
|
||||||
|
Loading…
Reference in New Issue
Block a user