Merge effectChanged and colorChanged to stateChanged
This commit is contained in:
parent
5f871bc01f
commit
44739c5198
@ -501,7 +501,7 @@ public:
|
||||
#endif
|
||||
effectCurrentIndex = max(min((increase ? effectCurrentIndex+1 : effectCurrentIndex-1), strip.getModeCount()-1), 0);
|
||||
effectCurrent = modes_alpha_indexes[effectCurrentIndex];
|
||||
effectChanged = true;
|
||||
stateChanged = true;
|
||||
if (applyToAll) {
|
||||
for (byte i=0; i<strip.getMaxSegments(); i++) {
|
||||
WS2812FX::Segment& seg = strip.getSegment(i);
|
||||
@ -529,7 +529,7 @@ public:
|
||||
display->updateRedrawTime();
|
||||
#endif
|
||||
effectSpeed = max(min((increase ? effectSpeed+fadeAmount : effectSpeed-fadeAmount), 255), 0);
|
||||
effectChanged = true;
|
||||
stateChanged = true;
|
||||
if (applyToAll) {
|
||||
for (byte i=0; i<strip.getMaxSegments(); i++) {
|
||||
WS2812FX::Segment& seg = strip.getSegment(i);
|
||||
@ -557,7 +557,7 @@ public:
|
||||
display->updateRedrawTime();
|
||||
#endif
|
||||
effectIntensity = max(min((increase ? effectIntensity+fadeAmount : effectIntensity-fadeAmount), 255), 0);
|
||||
effectChanged = true;
|
||||
stateChanged = true;
|
||||
if (applyToAll) {
|
||||
for (byte i=0; i<strip.getMaxSegments(); i++) {
|
||||
WS2812FX::Segment& seg = strip.getSegment(i);
|
||||
@ -586,7 +586,7 @@ public:
|
||||
#endif
|
||||
effectPaletteIndex = max(min((increase ? effectPaletteIndex+1 : effectPaletteIndex-1), strip.getPaletteCount()-1), 0);
|
||||
effectPalette = palettes_alpha_indexes[effectPaletteIndex];
|
||||
effectChanged = true;
|
||||
stateChanged = true;
|
||||
if (applyToAll) {
|
||||
for (byte i=0; i<strip.getMaxSegments(); i++) {
|
||||
WS2812FX::Segment& seg = strip.getSegment(i);
|
||||
@ -615,7 +615,7 @@ public:
|
||||
#endif
|
||||
currentHue1 = max(min((increase ? currentHue1+fadeAmount : currentHue1-fadeAmount), 255), 0);
|
||||
colorHStoRGB(currentHue1*256, currentSat1, col);
|
||||
colorChanged = true;
|
||||
stateChanged = true;
|
||||
if (applyToAll) {
|
||||
for (byte i=0; i<strip.getMaxSegments(); i++) {
|
||||
WS2812FX::Segment& seg = strip.getSegment(i);
|
||||
|
@ -135,17 +135,13 @@ void deserializeSegment(JsonObject elem, byte it, byte presetId)
|
||||
byte sz = colX.size();
|
||||
if (sz == 0) continue; //do nothing on empty array
|
||||
|
||||
byte cp = copyArray(colX, rgbw, 4);
|
||||
if (cp == 1 && rgbw[0] == 0)
|
||||
seg.setColor(i, 0, id);
|
||||
byte cp = copyArray(colX, rgbw, 4);
|
||||
colValid = true;
|
||||
}
|
||||
|
||||
if (!colValid) continue;
|
||||
|
||||
uint32_t color = RGBW32(rgbw[0],rgbw[1],rgbw[2],rgbw[3]);
|
||||
colorChanged |= (seg.colors[i] != color);
|
||||
seg.setColor(i, color, id);
|
||||
seg.setColor(i, RGBW32(rgbw[0],rgbw[1],rgbw[2],rgbw[3]), id);
|
||||
if (seg.mode == FX_MODE_STATIC) strip.trigger(); //instant refresh
|
||||
}
|
||||
}
|
||||
@ -231,7 +227,7 @@ void deserializeSegment(JsonObject elem, byte it, byte presetId)
|
||||
seg.setOption(SEG_OPTION_FREEZE, false);
|
||||
}
|
||||
//send UDP if not in preset and something changed that is not just selection
|
||||
if (!presetId && (seg.differs(prev) & 0x7F)) effectChanged = true;
|
||||
if (!presetId && (seg.differs(prev) & 0x7F)) stateChanged = true;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -25,19 +25,19 @@ void applyValuesToSelectedSegs()
|
||||
if (i != strip.getMainSegmentId() && (!seg.isActive() || !seg.isSelected())) continue;
|
||||
|
||||
if (effectSpeed != mainsegPrev.speed) {
|
||||
seg.speed = effectSpeed; effectChanged = true;}
|
||||
seg.speed = effectSpeed; stateChanged = true;}
|
||||
if (effectIntensity != mainsegPrev.intensity) {
|
||||
seg.intensity = effectIntensity; effectChanged = true;}
|
||||
seg.intensity = effectIntensity; stateChanged = true;}
|
||||
if (effectPalette != mainsegPrev.palette) {
|
||||
seg.palette = effectPalette; effectChanged = true;}
|
||||
seg.palette = effectPalette; stateChanged = true;}
|
||||
if (effectCurrent != mainsegPrev.mode) {
|
||||
strip.setMode(i, effectCurrent); effectChanged = true;}
|
||||
strip.setMode(i, effectCurrent); stateChanged = true;}
|
||||
uint32_t col0 = RGBW32(col[0],col[1],col[2],col[3]);
|
||||
uint32_t col1 = RGBW32(colSec[0], colSec[1], colSec[2], colSec[3]);
|
||||
if (col0 != mainsegPrev.colors[0]) {
|
||||
seg.setColor(0, col0, i); colorChanged = true;}
|
||||
seg.setColor(0, col0, i); stateChanged = true;}
|
||||
if (col1 != mainsegPrev.colors[1]) {
|
||||
seg.setColor(1, col1, i); colorChanged = true;}
|
||||
seg.setColor(1, col1, i); stateChanged = true;}
|
||||
}
|
||||
}
|
||||
|
||||
@ -94,16 +94,15 @@ void stateUpdated(byte callMode) {
|
||||
// 6: fx changed 7: hue 8: preset cycle 9: blynk 10: alexa 11: ws send only 12: button preset
|
||||
setValuesFromMainSeg();
|
||||
|
||||
if (bri != briOld || effectChanged || colorChanged) {
|
||||
if (bri != briOld || stateChanged) {
|
||||
if (realtimeTimeout == UINT32_MAX) realtimeTimeout = 0;
|
||||
if (effectChanged) currentPreset = 0; //something changed, so we are no longer in the preset
|
||||
if (stateChanged) currentPreset = 0; //something changed, so we are no longer in the preset
|
||||
|
||||
if (callMode != CALL_MODE_NOTIFICATION && callMode != CALL_MODE_NO_NOTIFY) notify(callMode);
|
||||
|
||||
//set flag to update blynk, ws and mqtt
|
||||
interfaceUpdateCallMode = callMode;
|
||||
effectChanged = false;
|
||||
colorChanged = false;
|
||||
stateChanged = false;
|
||||
} else {
|
||||
if (nightlightActive && !nightlightActiveOld && callMode != CALL_MODE_NOTIFICATION && callMode != CALL_MODE_NO_NOTIFY) {
|
||||
notify(CALL_MODE_NIGHTLIGHT);
|
||||
|
@ -779,7 +779,7 @@ bool handleSet(AsyncWebServerRequest *request, const String& req, bool apply)
|
||||
colorFromDecOrHexString(tmpCol, (char*)req.substring(pos + 3).c_str());
|
||||
uint32_t col2 = RGBW32(tmpCol[0], tmpCol[1], tmpCol[2], tmpCol[3]);
|
||||
selseg.setColor(2, col2, selectedSeg); // defined above (SS= or main)
|
||||
colorChanged = true;
|
||||
stateChanged = true;
|
||||
if (!singleSegment) strip.setColor(2, col2);
|
||||
}
|
||||
|
||||
@ -805,14 +805,14 @@ bool handleSet(AsyncWebServerRequest *request, const String& req, bool apply)
|
||||
|
||||
// apply colors to selected segment, and all selected segments if applicable
|
||||
if (col0Changed) {
|
||||
colorChanged = true;
|
||||
stateChanged = true;
|
||||
uint32_t colIn0 = RGBW32(colIn[0], colIn[1], colIn[2], colIn[3]);
|
||||
selseg.setColor(0, colIn0, selectedSeg);
|
||||
if (!singleSegment) strip.setColor(0, colIn0);
|
||||
}
|
||||
|
||||
if (col1Changed) {
|
||||
colorChanged = true;
|
||||
stateChanged = true;
|
||||
uint32_t colIn1 = RGBW32(colInSec[0], colInSec[1], colInSec[2], colInSec[3]);
|
||||
selseg.setColor(1, colIn1, selectedSeg);
|
||||
if (!singleSegment) strip.setColor(1, colIn1);
|
||||
@ -828,7 +828,7 @@ bool handleSet(AsyncWebServerRequest *request, const String& req, bool apply)
|
||||
intensityChanged = updateVal(&req, "IX=", &intensityIn);
|
||||
paletteChanged = updateVal(&req, "FP=", &paletteIn, 0, strip.getPaletteCount()-1);
|
||||
|
||||
effectChanged = (fxModeChanged || speedChanged || intensityChanged || paletteChanged);
|
||||
stateChanged |= (fxModeChanged || speedChanged || intensityChanged || paletteChanged);
|
||||
|
||||
for (uint8_t i = 0; i < strip.getMaxSegments(); i++) {
|
||||
WS2812FX::Segment& seg = strip.getSegment(i);
|
||||
|
@ -359,8 +359,7 @@ void handleNotifications()
|
||||
strip.setSegment(id, selseg.start, selseg.stop, udpIn[5+ofs], udpIn[6+ofs], selseg.offset);
|
||||
}
|
||||
}
|
||||
effectChanged = true;
|
||||
colorChanged = true;
|
||||
stateChanged = true;
|
||||
}
|
||||
|
||||
if (applyEffects && (version < 11 || !receiveSegmentOptions)) { //simple effect sync, applies to all selected
|
||||
|
@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
// version code in format yymmddb (b = daily build)
|
||||
#define VERSION 2202210
|
||||
#define VERSION 2202211
|
||||
|
||||
//uncomment this if you have a "my_config.h" file you'd like to use
|
||||
//#define WLED_USE_MY_CONFIG
|
||||
@ -478,8 +478,7 @@ WLED_GLOBAL byte effectCurrent _INIT(0);
|
||||
WLED_GLOBAL byte effectSpeed _INIT(128);
|
||||
WLED_GLOBAL byte effectIntensity _INIT(128);
|
||||
WLED_GLOBAL byte effectPalette _INIT(0);
|
||||
WLED_GLOBAL bool effectChanged _INIT(false);
|
||||
WLED_GLOBAL bool colorChanged _INIT(false);
|
||||
WLED_GLOBAL bool stateChanged _INIT(false);
|
||||
|
||||
// network
|
||||
WLED_GLOBAL bool udpConnected _INIT(false), udp2Connected _INIT(false), udpRgbConnected _INIT(false);
|
||||
|
Loading…
Reference in New Issue
Block a user