From 8c5b3fe23ef057c31bd81ae0f17bbde0f0094ba0 Mon Sep 17 00:00:00 2001 From: Proto-molecule Date: Sun, 6 Feb 2022 19:00:03 -0800 Subject: [PATCH 1/3] bugs, json remote repeat, cmd &R= --- wled00/ir.cpp | 87 ++++++++++++++++++++++++++------------------------ wled00/set.cpp | 2 ++ 2 files changed, 47 insertions(+), 42 deletions(-) diff --git a/wled00/ir.cpp b/wled00/ir.cpp index 321b72bc..6a8cd919 100644 --- a/wled00/ir.cpp +++ b/wled00/ir.cpp @@ -194,52 +194,55 @@ void decodeIR(uint32_t code) } void applyRepeatActions(){ - - if (lastRepeatableAction == ACTION_BRIGHT_UP) - { - incBrightness(); colorUpdated(CALL_MODE_BUTTON); - } - else if (lastRepeatableAction == ACTION_BRIGHT_DOWN ) - { - decBrightness(); colorUpdated(CALL_MODE_BUTTON); - } - if (lastRepeatableAction == ACTION_SPEED_UP) - { - changeEffectSpeed(lastRepeatableValue); colorUpdated(CALL_MODE_BUTTON); - } - else if (lastRepeatableAction == ACTION_SPEED_DOWN ) - { - changeEffectSpeed(lastRepeatableValue); colorUpdated(CALL_MODE_BUTTON); - } - - if (lastRepeatableAction == ACTION_INTENSITY_UP) - { - changeEffectIntensity(lastRepeatableValue); colorUpdated(CALL_MODE_BUTTON); - } - else if (lastRepeatableAction == ACTION_INTENSITY_DOWN ) - { - changeEffectIntensity(lastRepeatableValue); colorUpdated(CALL_MODE_BUTTON); - } - - if (lastValidCode == IR40_WPLUS) - { - relativeChangeWhite(10); colorUpdated(CALL_MODE_BUTTON); - } - else if (lastValidCode == IR40_WMINUS) - { - relativeChangeWhite(-10, 5); colorUpdated(CALL_MODE_BUTTON); - } - else if ((lastValidCode == IR24_ON || lastValidCode == IR40_ON) && irTimesRepeated > 7 ) - { - nightlightActive = true; - nightlightStartTime = millis(); - colorUpdated(CALL_MODE_BUTTON); - } - else if (irEnabled == 8) + if (irEnabled == 8) { decodeIRJson(lastValidCode); } + else + { + if (lastRepeatableAction == ACTION_BRIGHT_UP) + { + incBrightness(); colorUpdated(CALL_MODE_BUTTON); + } + else if (lastRepeatableAction == ACTION_BRIGHT_DOWN ) + { + decBrightness(); colorUpdated(CALL_MODE_BUTTON); + } + + if (lastRepeatableAction == ACTION_SPEED_UP) + { + changeEffectSpeed(lastRepeatableValue); colorUpdated(CALL_MODE_BUTTON); + } + else if (lastRepeatableAction == ACTION_SPEED_DOWN ) + { + changeEffectSpeed(lastRepeatableValue); colorUpdated(CALL_MODE_BUTTON); + } + + if (lastRepeatableAction == ACTION_INTENSITY_UP) + { + changeEffectIntensity(lastRepeatableValue); colorUpdated(CALL_MODE_BUTTON); + } + else if (lastRepeatableAction == ACTION_INTENSITY_DOWN ) + { + changeEffectIntensity(lastRepeatableValue); colorUpdated(CALL_MODE_BUTTON); + } + + if (lastValidCode == IR40_WPLUS) + { + relativeChangeWhite(10); colorUpdated(CALL_MODE_BUTTON); + } + else if (lastValidCode == IR40_WMINUS) + { + relativeChangeWhite(-10, 5); colorUpdated(CALL_MODE_BUTTON); + } + else if ((lastValidCode == IR24_ON || lastValidCode == IR40_ON) && irTimesRepeated > 7 ) + { + nightlightActive = true; + nightlightStartTime = millis(); + colorUpdated(CALL_MODE_BUTTON); + } + } } void decodeIR24(uint32_t code) diff --git a/wled00/set.cpp b/wled00/set.cpp index ff165214..8ab7205f 100644 --- a/wled00/set.cpp +++ b/wled00/set.cpp @@ -720,11 +720,13 @@ bool handleSet(AsyncWebServerRequest *request, const String& req, bool apply) updateVal(&req, "&B=", &col[2]); updateVal(&req, "&W=", &col[3]); for (byte i=0; i<4; i++) if (prevCol[i]!=col[i]) col0Changed = colorChanged = true; + if (col0Changed) selseg.setColor(0, RGBW32(col[0], col[1], col[2], col[3]), selectedSeg); updateVal(&req, "R2=", &colSec[0]); updateVal(&req, "G2=", &colSec[1]); updateVal(&req, "B2=", &colSec[2]); updateVal(&req, "W2=", &colSec[3]); for (byte i=0; i<4; i++) if (prevColSec[i]!=colSec[i]) col1Changed = colorChanged = true; + if (col1Changed) selseg.setColor(1, RGBW32(colSec[0], colSec[1], colSec[2], colSec[3]), selectedSeg); #ifdef WLED_ENABLE_LOXONE //lox parser From 4eb0dbb5a43278fbf03f3392a53fe6c6bd5f742c Mon Sep 17 00:00:00 2001 From: Blaz Kristan Date: Mon, 7 Feb 2022 11:13:12 +0100 Subject: [PATCH 2/3] repeat actions cleanup & fix --- wled00/ir.cpp | 76 ++++++++++++++++++--------------------------------- 1 file changed, 26 insertions(+), 50 deletions(-) diff --git a/wled00/ir.cpp b/wled00/ir.cpp index 6a8cd919..0358fdfa 100644 --- a/wled00/ir.cpp +++ b/wled00/ir.cpp @@ -162,6 +162,7 @@ void decodeIR(uint32_t code) return; } lastValidCode = 0; irTimesRepeated = 0; + lastRepeatableAction = ACTION_NONE; if (decodeIRCustom(code)) return; if (irEnabled == 8) { // any remote configurable with ir.json file decodeIRJson(code); @@ -193,56 +194,31 @@ void decodeIR(uint32_t code) colorUpdated(CALL_MODE_BUTTON); //for notifier, IR is considered a button input } -void applyRepeatActions(){ - - if (irEnabled == 8) - { - decodeIRJson(lastValidCode); - } - else - { - if (lastRepeatableAction == ACTION_BRIGHT_UP) - { - incBrightness(); colorUpdated(CALL_MODE_BUTTON); - } - else if (lastRepeatableAction == ACTION_BRIGHT_DOWN ) - { - decBrightness(); colorUpdated(CALL_MODE_BUTTON); - } - - if (lastRepeatableAction == ACTION_SPEED_UP) - { - changeEffectSpeed(lastRepeatableValue); colorUpdated(CALL_MODE_BUTTON); - } - else if (lastRepeatableAction == ACTION_SPEED_DOWN ) - { - changeEffectSpeed(lastRepeatableValue); colorUpdated(CALL_MODE_BUTTON); - } - - if (lastRepeatableAction == ACTION_INTENSITY_UP) - { - changeEffectIntensity(lastRepeatableValue); colorUpdated(CALL_MODE_BUTTON); - } - else if (lastRepeatableAction == ACTION_INTENSITY_DOWN ) - { - changeEffectIntensity(lastRepeatableValue); colorUpdated(CALL_MODE_BUTTON); - } - - if (lastValidCode == IR40_WPLUS) - { - relativeChangeWhite(10); colorUpdated(CALL_MODE_BUTTON); - } - else if (lastValidCode == IR40_WMINUS) - { - relativeChangeWhite(-10, 5); colorUpdated(CALL_MODE_BUTTON); - } - else if ((lastValidCode == IR24_ON || lastValidCode == IR40_ON) && irTimesRepeated > 7 ) - { - nightlightActive = true; - nightlightStartTime = millis(); - colorUpdated(CALL_MODE_BUTTON); - } - } +void applyRepeatActions() +{ + if (irEnabled == 8) { + decodeIRJson(lastValidCode); + return; + } else switch (lastRepeatableAction) { + case ACTION_BRIGHT_UP : incBrightness(); colorUpdated(CALL_MODE_BUTTON); return; + case ACTION_BRIGHT_DOWN : decBrightness(); colorUpdated(CALL_MODE_BUTTON); return; + case ACTION_SPEED_UP : changeEffectSpeed(lastRepeatableValue); colorUpdated(CALL_MODE_BUTTON); return; + case ACTION_SPEED_DOWN : changeEffectSpeed(lastRepeatableValue); colorUpdated(CALL_MODE_BUTTON); return; + case ACTION_INTENSITY_UP : changeEffectIntensity(lastRepeatableValue); colorUpdated(CALL_MODE_BUTTON); return; + case ACTION_INTENSITY_DOWN : changeEffectIntensity(lastRepeatableValue); colorUpdated(CALL_MODE_BUTTON); return; + default: break; + } + if (lastValidCode == IR40_WPLUS) { + relativeChangeWhite(10); + colorUpdated(CALL_MODE_BUTTON); + } else if (lastValidCode == IR40_WMINUS) { + relativeChangeWhite(-10, 5); + colorUpdated(CALL_MODE_BUTTON); + } else if ((lastValidCode == IR24_ON || lastValidCode == IR40_ON) && irTimesRepeated > 7 ) { + nightlightActive = true; + nightlightStartTime = millis(); + colorUpdated(CALL_MODE_BUTTON); + } } void decodeIR24(uint32_t code) From fa981a389f61d0b9999fa86d59c9b811c5d4dd09 Mon Sep 17 00:00:00 2001 From: Blaz Kristan Date: Thu, 10 Feb 2022 13:59:59 +0100 Subject: [PATCH 3/3] Add transitions to other segments. --- wled00/set.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wled00/set.cpp b/wled00/set.cpp index 8ab7205f..7b32d090 100644 --- a/wled00/set.cpp +++ b/wled00/set.cpp @@ -965,8 +965,8 @@ bool handleSet(AsyncWebServerRequest *request, const String& req, bool apply) if (effectSpeed != prevSpeed) seg.speed = effectSpeed; if (effectIntensity != prevIntensity) seg.intensity = effectIntensity; if (effectPalette != prevPalette) seg.palette = effectPalette; - if (col0Changed) seg.colors[0] = RGBW32(col[0], col[1], col[2], col[3]); - if (col1Changed) seg.colors[1] = RGBW32(colSec[0], colSec[1], colSec[2], colSec[3]); + if (col0Changed) seg.setColor(0, RGBW32(col[0], col[1], col[2], col[3]), i); // use transitions + if (col1Changed) seg.setColor(1, RGBW32(colSec[0], colSec[1], colSec[2], colSec[3]), i); // use transitions if (col2Changed) seg.colors[2] = RGBW32(tmpCol[0], tmpCol[1], tmpCol[2], tmpCol[3]); } }