First working multisegment transitions

This commit is contained in:
cschwinne
2021-01-09 00:35:48 +01:00
parent 0df6826c91
commit 9551519a35
10 changed files with 220 additions and 103 deletions

View File

@@ -51,24 +51,20 @@ void setAllLeds() {
}
if (useRGBW && strip.rgbwMode == RGBW_MODE_LEGACY)
{
colorRGBtoRGBW(colT);
colorRGBtoRGBW(colSecT);
colorRGBtoRGBW(col);
colorRGBtoRGBW(colSec);
}
strip.setColor(0, col[0], col[1], col[2], col[3]);
strip.setColor(1, colSec[0], colSec[1], colSec[2], colSec[3]);
if (useRGBW && strip.rgbwMode == RGBW_MODE_LEGACY)
{
col[3] = 0; colSec[3] = 0;
}
strip.setColor(0, colT[0], colT[1], colT[2], colT[3]);
strip.setColor(1, colSecT[0], colSecT[1], colSecT[2], colSecT[3]);
}
void setLedsStandard(bool justColors)
void setLedsStandard()
{
for (byte i=0; i<4; i++)
{
colOld[i] = col[i];
colT[i] = col[i];
colSecOld[i] = colSec[i];
colSecT[i] = colSec[i];
}
if (justColors) return;
briOld = bri;
briT = bri;
setAllLeds();
@@ -145,7 +141,7 @@ void colorUpdated(int callMode)
}
if (briT == 0)
{
setLedsStandard(true); //do not color transition if starting from off
//setLedsStandard(true); //do not color transition if starting from off!
if (callMode != NOTIFIER_CALL_MODE_NOTIFICATION) resetTimebase(); //effect start from beginning
}
@@ -160,15 +156,11 @@ void colorUpdated(int callMode)
//set correct delay if not using notification delay
if (callMode != NOTIFIER_CALL_MODE_NOTIFICATION && !jsonTransitionOnce) transitionDelayTemp = transitionDelay;
jsonTransitionOnce = false;
strip.setTransition(transitionDelayTemp);
if (transitionDelayTemp == 0) {setLedsStandard(); strip.trigger(); return;}
if (transitionActive)
{
for (byte i=0; i<4; i++)
{
colOld[i] = colT[i];
colSecOld[i] = colSecT[i];
}
briOld = briT;
tperLast = 0;
}
@@ -177,6 +169,7 @@ void colorUpdated(int callMode)
transitionStartTime = millis();
} else
{
strip.setTransition(0);
setLedsStandard();
strip.trigger();
}
@@ -222,11 +215,6 @@ void handleTransitions()
}
if (tper - tperLast < 0.004) return;
tperLast = tper;
for (byte i=0; i<4; i++)
{
colT[i] = colOld[i]+((col[i] - colOld[i])*tper);
colSecT[i] = colSecOld[i]+((colSec[i] - colSecOld[i])*tper);
}
briT = briOld +((bri - briOld )*tper);
setAllLeds();