fade transition working

This commit is contained in:
cschwinne 2016-10-30 14:49:51 +01:00
parent b040559d17
commit 9b786910d8
2 changed files with 18 additions and 9 deletions

View File

@ -1,7 +1,5 @@
toolbar preparation
color cycle color cycle
sequence sequence
fade transition
simple slide transition simple slide transition
add toolbar conf in settings add toolbar conf in settings
additional color picker field additional color picker field
@ -14,6 +12,10 @@ implement discrete range color setter
implement discrete single color setter implement discrete single color setter
do not reboot after settings set -> add reboot button do not reboot after settings set -> add reboot button
svg icons in html 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 BUGS
static ip disables mdns static ip disables mdns

View File

@ -627,13 +627,20 @@ void setLedsStandard()
void colorUpdated() 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 return; //no change
} }
notify(); notify();
if (fadeTransition || seqTransition) 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; transitionActive = true;
transitionStartTime = millis(); transitionStartTime = millis();
} else } else
@ -644,9 +651,9 @@ void colorUpdated()
void handleTransitions() void handleTransitions()
{ {
if (transitionActive) if (transitionActive && transitionDelay > 0)
{ {
float tper = (millis() - transitionStartTime)/transitionDelay; float tper = (millis() - transitionStartTime)/(float)transitionDelay;
if (tper >= 1.0) if (tper >= 1.0)
{ {
transitionActive = false; transitionActive = false;
@ -655,10 +662,10 @@ void handleTransitions()
} }
if (fadeTransition) if (fadeTransition)
{ {
col_t[0] = col_old[0]+((col[0] - col_old[0])/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[1] = col_old[1]+((col[1] - col_old[1])*tper);
col_t[2] = col_old[2]+((col[2] - col_old[2])/tper); col_t[2] = col_old[2]+((col[2] - col_old[2])*tper);
bri_t = bri_old+((bri - bri_old)/tper); bri_t = bri_old+((bri - bri_old)*tper);
} }
if (seqTransition) if (seqTransition)
{ {