mirror of
https://github.com/wled/WLED.git
synced 2025-07-18 08:16:32 +00:00
Fix for #3265
This commit is contained in:
parent
b257f476c9
commit
ef3c72a24f
@ -202,7 +202,6 @@ void /*IRAM_ATTR*/ Segment::setPixelColorXY(int x, int y, uint32_t col)
|
|||||||
if (leds) leds[XY(x,y)] = col;
|
if (leds) leds[XY(x,y)] = col;
|
||||||
|
|
||||||
uint8_t _bri_t = currentBri(on ? opacity : 0);
|
uint8_t _bri_t = currentBri(on ? opacity : 0);
|
||||||
if (!_bri_t && !transitional) return;
|
|
||||||
if (_bri_t < 255) {
|
if (_bri_t < 255) {
|
||||||
byte r = scale8(R(col), _bri_t);
|
byte r = scale8(R(col), _bri_t);
|
||||||
byte g = scale8(G(col), _bri_t);
|
byte g = scale8(G(col), _bri_t);
|
||||||
|
@ -305,23 +305,26 @@ CRGBPalette16 &Segment::loadPalette(CRGBPalette16 &targetPalette, uint8_t pal) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Segment::startTransition(uint16_t dur) {
|
void Segment::startTransition(uint16_t dur) {
|
||||||
if (transitional || _t) return; // already in transition no need to store anything
|
if (!dur) {
|
||||||
|
transitional = false;
|
||||||
|
if (_t) {
|
||||||
|
delete _t;
|
||||||
|
_t = nullptr;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (transitional && _t) return; // already in transition no need to store anything
|
||||||
|
|
||||||
// starting a transition has to occur before change so we get current values 1st
|
// starting a transition has to occur before change so we get current values 1st
|
||||||
uint8_t _briT = currentBri(on ? opacity : 0);
|
_t = new Transition(dur); // no previous transition running
|
||||||
uint8_t _cctT = currentBri(cct, true);
|
|
||||||
CRGBPalette16 _palT = CRGBPalette16(DEFAULT_COLOR); loadPalette(_palT, palette);
|
|
||||||
uint8_t _modeP = mode;
|
|
||||||
uint32_t _colorT[NUM_COLORS];
|
|
||||||
for (size_t i=0; i<NUM_COLORS; i++) _colorT[i] = currentColor(i, colors[i]);
|
|
||||||
|
|
||||||
if (!_t) _t = new Transition(dur); // no previous transition running
|
|
||||||
if (!_t) return; // failed to allocate data
|
if (!_t) return; // failed to allocate data
|
||||||
_t->_briT = _briT;
|
|
||||||
_t->_cctT = _cctT;
|
CRGBPalette16 _palT = CRGBPalette16(DEFAULT_COLOR); loadPalette(_palT, palette);
|
||||||
|
_t->_briT = on ? opacity : 0;
|
||||||
|
_t->_cctT = cct;
|
||||||
_t->_palT = _palT;
|
_t->_palT = _palT;
|
||||||
_t->_modeP = _modeP;
|
_t->_modeP = mode;
|
||||||
for (size_t i=0; i<NUM_COLORS; i++) _t->_colorT[i] = _colorT[i];
|
for (size_t i=0; i<NUM_COLORS; i++) _t->_colorT[i] = colors[i];
|
||||||
transitional = true; // setOption(SEG_OPTION_TRANSITIONAL, true);
|
transitional = true; // setOption(SEG_OPTION_TRANSITIONAL, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -334,10 +337,10 @@ uint16_t Segment::progress() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint8_t Segment::currentBri(uint8_t briNew, bool useCct) {
|
uint8_t Segment::currentBri(uint8_t briNew, bool useCct) {
|
||||||
if (transitional && _t) {
|
uint32_t prog = progress();
|
||||||
uint32_t prog = progress() + 1;
|
if (transitional && _t && prog < 0xFFFFU) {
|
||||||
if (useCct) return ((briNew * prog) + _t->_cctT * (0x10000 - prog)) >> 16;
|
if (useCct) return ((briNew * prog) + _t->_cctT * (0xFFFFU - prog)) >> 16;
|
||||||
else return ((briNew * prog) + _t->_briT * (0x10000 - prog)) >> 16;
|
else return ((briNew * prog) + _t->_briT * (0xFFFFU - prog)) >> 16;
|
||||||
} else {
|
} else {
|
||||||
return briNew;
|
return briNew;
|
||||||
}
|
}
|
||||||
@ -368,6 +371,7 @@ CRGBPalette16 &Segment::currentPalette(CRGBPalette16 &targetPalette, uint8_t pal
|
|||||||
void Segment::handleTransition() {
|
void Segment::handleTransition() {
|
||||||
if (!transitional) return;
|
if (!transitional) return;
|
||||||
uint16_t _progress = progress();
|
uint16_t _progress = progress();
|
||||||
|
if (_progress == 0xFFFFU) transitional = false; // finish transitioning segment
|
||||||
if (_t) { // thanks to @nXm AKA https://github.com/NMeirer
|
if (_t) { // thanks to @nXm AKA https://github.com/NMeirer
|
||||||
if (_progress >= 32767U && _t->_modeP != mode) markForReset();
|
if (_progress >= 32767U && _t->_modeP != mode) markForReset();
|
||||||
if (_progress == 0xFFFFU) {
|
if (_progress == 0xFFFFU) {
|
||||||
@ -375,7 +379,6 @@ void Segment::handleTransition() {
|
|||||||
_t = nullptr;
|
_t = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_progress == 0xFFFFU) transitional = false; // finish transitioning segment
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Segment::setUp(uint16_t i1, uint16_t i2, uint8_t grp, uint8_t spc, uint16_t ofs, uint16_t i1Y, uint16_t i2Y) {
|
void Segment::setUp(uint16_t i1, uint16_t i2, uint8_t grp, uint8_t spc, uint16_t ofs, uint16_t i1Y, uint16_t i2Y) {
|
||||||
@ -622,7 +625,6 @@ void IRAM_ATTR Segment::setPixelColor(int i, uint32_t col)
|
|||||||
|
|
||||||
uint16_t len = length();
|
uint16_t len = length();
|
||||||
uint8_t _bri_t = currentBri(on ? opacity : 0);
|
uint8_t _bri_t = currentBri(on ? opacity : 0);
|
||||||
if (!_bri_t && !transitional && fadeTransition) return; // if _bri_t == 0 && segment is not transitionig && transitions are enabled then save a few CPU cycles
|
|
||||||
if (_bri_t < 255) {
|
if (_bri_t < 255) {
|
||||||
byte r = scale8(R(col), _bri_t);
|
byte r = scale8(R(col), _bri_t);
|
||||||
byte g = scale8(G(col), _bri_t);
|
byte g = scale8(G(col), _bri_t);
|
||||||
@ -1590,7 +1592,7 @@ void WS2812FX::setRange(uint16_t i, uint16_t i2, uint32_t col) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void WS2812FX::setTransitionMode(bool t) {
|
void WS2812FX::setTransitionMode(bool t) {
|
||||||
for (segment &seg : _segments) if (!seg.transitional) seg.startTransition(t ? _transitionDur : 0);
|
for (segment &seg : _segments) seg.startTransition(t ? _transitionDur : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WLED_DEBUG
|
#ifdef WLED_DEBUG
|
||||||
|
@ -146,8 +146,8 @@ void stateUpdated(byte callMode) {
|
|||||||
if (transitionActive) {
|
if (transitionActive) {
|
||||||
briOld = briT;
|
briOld = briT;
|
||||||
tperLast = 0;
|
tperLast = 0;
|
||||||
}
|
} else
|
||||||
strip.setTransitionMode(true); // force all segments to transition mode
|
strip.setTransitionMode(true); // force all segments to transition mode
|
||||||
transitionActive = true;
|
transitionActive = true;
|
||||||
transitionStartTime = millis();
|
transitionStartTime = millis();
|
||||||
} else {
|
} else {
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// version code in format yymmddb (b = daily build)
|
// version code in format yymmddb (b = daily build)
|
||||||
#define VERSION 2306210
|
#define VERSION 2306230
|
||||||
|
|
||||||
//uncomment this if you have a "my_config.h" file you'd like to use
|
//uncomment this if you have a "my_config.h" file you'd like to use
|
||||||
//#define WLED_USE_MY_CONFIG
|
//#define WLED_USE_MY_CONFIG
|
||||||
|
Loading…
x
Reference in New Issue
Block a user