From 9b786910d808ce6b29a41928863218ea18b618e9 Mon Sep 17 00:00:00 2001 From: cschwinne Date: Sun, 30 Oct 2016 14:49:51 +0100 Subject: [PATCH] fade transition working --- TODO.txt | 6 ++++-- wled00/wled00.ino | 21 ++++++++++++++------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/TODO.txt b/TODO.txt index c3e3f8a..4096282 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,7 +1,5 @@ -toolbar preparation color cycle sequence -fade transition simple slide transition add toolbar conf in settings additional color picker field @@ -14,6 +12,10 @@ implement discrete range color setter implement discrete single color setter do not reboot after settings set -> add reboot button svg icons in html +notifier function -> send get request +nightlight function -> turns off after set time (+implement fading) +(replace StrContains and num functions) +settings getter/setter/html for fade transition BUGS static ip disables mdns diff --git a/wled00/wled00.ino b/wled00/wled00.ino index cb0a361..92c97a6 100644 --- a/wled00/wled00.ino +++ b/wled00/wled00.ino @@ -627,13 +627,20 @@ void setLedsStandard() void colorUpdated() { - if (col[0] != col_old[0] && col[1] != col_old[1] && col[2] != col_old[2] && bri != bri_old) + if (col[0] == col_old[0] && col[1] == col_old[1] && col[2] == col_old[2] && bri == bri_old) { return; //no change } notify(); if (fadeTransition || seqTransition) { + if (transitionActive) + { + col_old[0] = col_t[0]; + col_old[1] = col_t[1]; + col_old[2] = col_t[2]; + bri_old = bri_t; + } transitionActive = true; transitionStartTime = millis(); } else @@ -644,9 +651,9 @@ void colorUpdated() void handleTransitions() { - if (transitionActive) + if (transitionActive && transitionDelay > 0) { - float tper = (millis() - transitionStartTime)/transitionDelay; + float tper = (millis() - transitionStartTime)/(float)transitionDelay; if (tper >= 1.0) { transitionActive = false; @@ -655,10 +662,10 @@ void handleTransitions() } if (fadeTransition) { - col_t[0] = col_old[0]+((col[0] - col_old[0])/tper); - col_t[1] = col_old[1]+((col[1] - col_old[1])/tper); - col_t[2] = col_old[2]+((col[2] - col_old[2])/tper); - bri_t = bri_old+((bri - bri_old)/tper); + col_t[0] = col_old[0]+((col[0] - col_old[0])*tper); + col_t[1] = col_old[1]+((col[1] - col_old[1])*tper); + col_t[2] = col_old[2]+((col[2] - col_old[2])*tper); + bri_t = bri_old+((bri - bri_old)*tper); } if (seqTransition) {