Semi-working segment on/off transition

This commit is contained in:
cschwinne 2021-09-20 21:22:04 +02:00
parent 3577da05ac
commit baf49b88f4
4 changed files with 16 additions and 7 deletions

View File

@ -2,6 +2,12 @@
### Builds after release 0.12.0
#### Build 2109200
- Added segment names (PR #2184)
- Improved Police and other effects (PR #2184)
- Reverted PR #1902 (Live color correction - will be implemented as usermod) (PR #2175)
#### Build 2109100
- Added an auto create segments per bus setting

View File

@ -274,8 +274,8 @@ class WS2812FX {
}*/
void setOption(uint8_t n, bool val, uint8_t segn = 255)
{
//bool prevOn = false;
//if (n == SEG_OPTION_ON) prevOn = getOption(SEG_OPTION_ON);
bool prevOn = false;
if (n == SEG_OPTION_ON) prevOn = getOption(SEG_OPTION_ON);
if (val) {
options |= 0x01 << n;
} else
@ -283,13 +283,13 @@ class WS2812FX {
options &= ~(0x01 << n);
}
//transitions on segment on/off don't work correctly at this point
/*if (n == SEG_OPTION_ON && segn < MAX_NUM_SEGMENTS && getOption(SEG_OPTION_ON) != prevOn) {
if (getOption(SEG_OPTION_ON)) {
if (n == SEG_OPTION_ON && segn < MAX_NUM_SEGMENTS && val != prevOn) {
if (val) {
ColorTransition::startTransition(0, colors[0], instance->_transitionDur, segn, 0);
} else {
ColorTransition::startTransition(opacity, colors[0], instance->_transitionDur, segn, 0);
}
}*/
}
}
bool getOption(uint8_t n)
{
@ -473,6 +473,7 @@ class WS2812FX {
uint8_t segn = segment & 0x3F;
if (segn >= MAX_NUM_SEGMENTS) return 0;
uint8_t briNew = instance->_segments[segn].opacity;
if (!instance->_segments[segn].getOption(SEG_OPTION_ON)) briNew = 0; //NEW
uint32_t prog = progress() + 1;
return ((briNew * prog) + (briOld * (0x10000 - prog))) >> 16;
}

View File

@ -70,7 +70,9 @@ void deserializeSegment(JsonObject elem, byte it, byte presetId)
seg.setOption(SEG_OPTION_ON, 1, id);
}
seg.setOption(SEG_OPTION_ON, elem["on"] | seg.getOption(SEG_OPTION_ON), id);
bool on = elem["on"] | seg.getOption(SEG_OPTION_ON);
if (elem["on"].is<const char*>() && elem["on"].as<const char*>()[0] == 't') on = !on;
seg.setOption(SEG_OPTION_ON, on, id);
JsonArray colarr = elem["col"];
if (!colarr.isNull())

View File

@ -8,7 +8,7 @@
*/
// version code in format yymmddb (b = daily build)
#define VERSION 2109100
#define VERSION 2109200
//uncomment this if you have a "my_config.h" file you'd like to use
//#define WLED_USE_MY_CONFIG