From d36796429e908694e477e0b6c3ec2d975ba4011e Mon Sep 17 00:00:00 2001 From: cschwinne Date: Sat, 14 Mar 2020 11:28:42 +0100 Subject: [PATCH] Various small fixes Fixed color of main segment returned in JSON API during transition not being target color - Fixed arlsLock() being called after pixels set in E1.31, (closes #772) - Fixed HTTP API calls not having an effect if no segment selected (now applies to main segment) --- CHANGELOG.md | 6 ++++++ wled00/FX_fcn.cpp | 14 ++++++++++++-- wled00/wled00.ino | 2 +- wled00/wled07_notify.ino | 5 ++++- wled00/wled19_json.ino | 27 +++++++++++++++++++-------- 5 files changed, 42 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fd5aa846..cbc45e92 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,12 @@ ### Development versions after 0.9.1 release +#### Build 2003141 + +- Fixed color of main segment returned in JSON API during transition not being target color (closes #765) +- Fixed arlsLock() being called after pixels set in E1.31 (closes #772) +- Fixed HTTP API calls not having an effect if no segment selected (now applies to main segment) + #### Build 2003121 - Created changelog.md - make tracking changes to code easier diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index 2392392d..59f69da4 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -335,6 +335,8 @@ 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; + bool applied = false; + if (applyToAllSelected) { for (uint8_t i = 0; i < MAX_NUM_SEGMENTS; i++) { @@ -344,9 +346,12 @@ bool WS2812FX::setEffectConfig(uint8_t m, uint8_t s, uint8_t in, uint8_t p) { _segments[i].intensity = in; _segments[i].palette = p; setMode(i, m); + applied = true; } } - } else { + } + + if (!applyToAllSelected || !applied) { seg.speed = s; seg.intensity = in; seg.palette = p; @@ -363,12 +368,17 @@ void WS2812FX::setColor(uint8_t slot, uint8_t r, uint8_t g, uint8_t b, uint8_t w void WS2812FX::setColor(uint8_t slot, uint32_t c) { if (slot >= NUM_COLORS) return; + + bool applied = false; + if (applyToAllSelected) { for (uint8_t i = 0; i < MAX_NUM_SEGMENTS; i++) { if (_segments[i].isSelected()) _segments[i].colors[slot] = c; } - } else { + } + + if (!applyToAllSelected || !applied) { _segments[getMainSegmentId()].colors[slot] = c; } } diff --git a/wled00/wled00.ino b/wled00/wled00.ino index ba2d4b68..f9648dcf 100644 --- a/wled00/wled00.ino +++ b/wled00/wled00.ino @@ -119,7 +119,7 @@ #endif //version code in format yymmddb (b = daily build) -#define VERSION 2003121 +#define VERSION 2003141 char versionString[] = "0.9.1"; diff --git a/wled00/wled07_notify.ino b/wled00/wled07_notify.ino index b1fab41e..8fcbdbe8 100644 --- a/wled00/wled07_notify.ino +++ b/wled00/wled07_notify.ino @@ -121,6 +121,7 @@ void handleE131Packet(e131_packet_t* p, IPAddress clientIP){ case DMX_MODE_SINGLE_RGB: if (uni != e131Universe) return; if (dmxChannels-DMXAddress+1 < 3) return; + arlsLock(realtimeTimeoutMs, REALTIME_MODE_E131); for (uint16_t i = 0; i < ledCount; i++) setRealtimePixel(i, p->property_values[DMXAddress+0], p->property_values[DMXAddress+1], p->property_values[DMXAddress+2], 0); break; @@ -128,6 +129,7 @@ void handleE131Packet(e131_packet_t* p, IPAddress clientIP){ case DMX_MODE_SINGLE_DRGB: if (uni != e131Universe) return; if (dmxChannels-DMXAddress+1 < 4) return; + arlsLock(realtimeTimeoutMs, REALTIME_MODE_E131); if (DMXOldDimmer != p->property_values[DMXAddress+0]) { DMXOldDimmer = p->property_values[DMXAddress+0]; bri = p->property_values[DMXAddress+0]; @@ -166,6 +168,7 @@ void handleE131Packet(e131_packet_t* p, IPAddress clientIP){ break; case DMX_MODE_MULTIPLE_RGB: + arlsLock(realtimeTimeoutMs, REALTIME_MODE_E131); if (previousUniverses == 0) { // first universe of this fixture possibleLEDsInCurrentUniverse = (dmxChannels - DMXAddress + 1) / 3; @@ -187,6 +190,7 @@ void handleE131Packet(e131_packet_t* p, IPAddress clientIP){ break; case DMX_MODE_MULTIPLE_DRGB: + arlsLock(realtimeTimeoutMs, REALTIME_MODE_E131); if (previousUniverses == 0) { // first universe of this fixture if (DMXOldDimmer != p->property_values[DMXAddress+0]) { @@ -218,7 +222,6 @@ void handleE131Packet(e131_packet_t* p, IPAddress clientIP){ break; } - arlsLock(realtimeTimeoutMs, REALTIME_MODE_E131); e131NewData = true; } diff --git a/wled00/wled19_json.ino b/wled00/wled19_json.ino index 237912d6..df9bcead 100644 --- a/wled00/wled19_json.ino +++ b/wled00/wled19_json.ino @@ -31,12 +31,14 @@ void deserializeSegment(JsonObject elem, byte it) { int rgbw[] = {0,0,0,0}; byte cp = copyArray(colX, rgbw); - seg.colors[i] = ((rgbw[3] << 24) | ((rgbw[0]&0xFF) << 16) | ((rgbw[1]&0xFF) << 8) | ((rgbw[2]&0xFF))); + if (cp == 1 && rgbw[0] == 0) seg.colors[i] = 0; - if (id == strip.getMainSegmentId()) //temporary + if (id == strip.getMainSegmentId() && i < 2) //temporary, to make transition work on main segment { if (i == 0) {col[0] = rgbw[0]; col[1] = rgbw[1]; col[2] = rgbw[2]; col[3] = rgbw[3];} if (i == 1) {colSec[0] = rgbw[0]; colSec[1] = rgbw[1]; colSec[2] = rgbw[2]; colSec[3] = rgbw[3];} + } else { + seg.colors[i] = ((rgbw[3] << 24) | ((rgbw[0]&0xFF) << 16) | ((rgbw[1]&0xFF) << 8) | ((rgbw[2]&0xFF))); } } } @@ -175,15 +177,24 @@ void serializeSegment(JsonObject& root, WS2812FX::Segment& seg, byte id) root["spc"] = seg.spacing; JsonArray colarr = root.createNestedArray("col"); - + for (uint8_t i = 0; i < 3; i++) { JsonArray colX = colarr.createNestedArray(); - colX.add((seg.colors[i] >> 16) & 0xFF); - colX.add((seg.colors[i] >> 8) & 0xFF); - colX.add((seg.colors[i]) & 0xFF); - if (useRGBW) - colX.add((seg.colors[i] >> 24) & 0xFF); + if (id == strip.getMainSegmentId() && i < 2) //temporary, to make transition work on main segment + { + if (i == 0) { + colX.add(col[0]); colX.add(col[1]); colX.add(col[2]); if (useRGBW) colX.add(col[3]); + } else { + colX.add(colSec[0]); colX.add(colSec[1]); colX.add(colSec[2]); if (useRGBW) colX.add(colSec[3]); + } + } else { + colX.add((seg.colors[i] >> 16) & 0xFF); + colX.add((seg.colors[i] >> 8) & 0xFF); + colX.add((seg.colors[i]) & 0xFF); + if (useRGBW) + colX.add((seg.colors[i] >> 24) & 0xFF); + } } root["fx"] = seg.mode;