Full segment syncing.

- removed setEffectConfig()
- rate limit handleNightlight()
- fixes in colorUpdated()
- segment color fix in UDP routine
This commit is contained in:
Blaz Kristan 2022-01-15 00:06:06 +01:00
parent 72a6681ac1
commit 3da70c3e8b
4 changed files with 1635 additions and 1629 deletions

View File

@ -390,7 +390,7 @@ uint8_t WS2812FX::getPaletteCount()
//TODO effect transitions
/*
bool WS2812FX::setEffectConfig(uint8_t m, uint8_t s, uint8_t in, uint8_t p) {
Segment& seg = _segments[getMainSegmentId()];
uint8_t modePrev = seg.mode, speedPrev = seg.speed, intensityPrev = seg.intensity, palettePrev = seg.palette;
@ -425,7 +425,7 @@ bool WS2812FX::setEffectConfig(uint8_t m, uint8_t s, uint8_t in, uint8_t p) {
void WS2812FX::setColor(uint8_t slot, uint8_t r, uint8_t g, uint8_t b, uint8_t w) {
setColor(slot, RGBW32(r, g, b, w));
}
*/
void WS2812FX::setColor(uint8_t slot, uint32_t c) {
if (slot >= NUM_COLORS) return;

File diff suppressed because it is too large Load Diff

View File

@ -31,7 +31,6 @@ void toggleOnOff()
briLast = bri;
bri = 0;
}
colorChanged = true;
}
@ -45,8 +44,8 @@ byte scaledBri(byte in)
void setAllLeds() {
strip.setColor(0, col[0], col[1], col[2], col[3]);
strip.setColor(1, colSec[0], colSec[1], colSec[2], colSec[3]);
strip.setColor(0, RGBW32(col[0], col[1], col[2], col[3]));
strip.setColor(1, RGBW32(colSec[0], colSec[1], colSec[2], colSec[3]));
if (!realtimeMode || !arlsForceMaxBri)
{
strip.setBrightness(scaledBri(briT));
@ -66,17 +65,18 @@ void colorUpdated(int callMode)
{
//call for notifier -> 0: init 1: direct change 2: button 3: notification 4: nightlight 5: other (No notification)
// 6: fx changed 7: hue 8: preset cycle 9: blynk 10: alexa 11: ws send only 12: button preset
if (callMode != CALL_MODE_INIT &&
callMode != CALL_MODE_DIRECT_CHANGE &&
callMode != CALL_MODE_NO_NOTIFY &&
callMode != CALL_MODE_BUTTON_PRESET) strip.applyToAllSelected = true; //if not from JSON api, which directly sets segments
// if (callMode != CALL_MODE_INIT &&
// callMode != CALL_MODE_DIRECT_CHANGE &&
// callMode != CALL_MODE_NO_NOTIFY &&
// callMode != CALL_MODE_BUTTON_PRESET) strip.applyToAllSelected = true; //if not from JSON api, which directly sets segments
if (effectChanged || colorChanged) {
effectChanged = false;
colorChanged = false;
if (realtimeTimeout == UINT32_MAX) realtimeTimeout = 0;
currentPreset = 0; //something changed, so we are no longer in the preset
notify(callMode);
if (callMode != CALL_MODE_NOTIFICATION && callMode != CALL_MODE_NO_NOTIFY) notify(callMode);
//set flag to update blynk, ws and mqtt
interfaceUpdateCallMode = callMode;
@ -87,9 +87,6 @@ void colorUpdated(int callMode)
}
}
if (!colorChanged) return; //following code is for e.g. initiating transitions
colorChanged = false;
if (callMode != CALL_MODE_NO_NOTIFY && nightlightActive && (nightlightMode == NL_MODE_FADE || nightlightMode == NL_MODE_COLORFADE)) {
briNlT = bri;
nightlightDelayMs -= (millis() - nightlightStartTime);
@ -110,7 +107,9 @@ void colorUpdated(int callMode)
jsonTransitionOnce = false;
strip.setTransition(transitionDelayTemp);
if (transitionDelayTemp == 0) {
setLedsStandard();
//setLedsStandard();
briOld = briT = bri;
if (!realtimeMode || !arlsForceMaxBri) strip.setBrightness(scaledBri(briT));
strip.trigger();
return;
}
@ -124,7 +123,9 @@ void colorUpdated(int callMode)
transitionStartTime = millis();
} else {
strip.setTransition(0);
setLedsStandard();
//setLedsStandard();
briOld = briT = bri;
if (!realtimeMode || !arlsForceMaxBri) strip.setBrightness(scaledBri(briT));
strip.trigger();
}
}
@ -182,6 +183,12 @@ void handleTransitions()
void handleNightlight()
{
static unsigned long lastNlUpdate;
unsigned long now = millis();
if (now < 100 && lastNlUpdate > 0) lastNlUpdate = 0; //take care of millis() rollover
if (now - lastNlUpdate < 100) return; //allow only 10 NL updates per second
lastNlUpdate = now;
if (nightlightActive)
{
if (!nightlightActiveOld) //init

View File

@ -282,24 +282,23 @@ void handleNotifications()
bool someSel = (receiveNotificationBrightness || receiveNotificationColor || receiveNotificationEffects);
//apply colors from notification
if (receiveNotificationColor || !someSel)
{
col[0] = udpIn[3];
col[1] = udpIn[4];
col[2] = udpIn[5];
if (receiveNotificationColor || !someSel) {
if (version < 11 || !receiveSegmentOptions) {
col[0] = udpIn[3];
col[1] = udpIn[4];
col[2] = udpIn[5];
}
if (version > 0) //sending module's white val is intended
{
col[3] = udpIn[10];
if (version > 1)
{
if (version < 11 || !receiveSegmentOptions) col[3] = udpIn[10];
if (version > 1 && (version < 11 || !receiveSegmentOptions)) {
colSec[0] = udpIn[12];
colSec[1] = udpIn[13];
colSec[2] = udpIn[14];
colSec[3] = udpIn[15];
}
if (version > 6)
{
strip.setColor(2, udpIn[20], udpIn[21], udpIn[22], udpIn[23]); //tertiary color
if (version > 6 && (version < 11 || !receiveSegmentOptions)) {
strip.setColor(2, RGBW32(udpIn[20], udpIn[21], udpIn[22], udpIn[23])); //tertiary color
}
if (version > 9 && version < 200 && udpIn[37] < 255) { //valid CCT/Kelvin value
uint8_t cct = udpIn[38];