diff --git a/wled00/FX.cpp b/wled00/FX.cpp index 0a9b075ea..e6eaa3566 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -7272,7 +7272,7 @@ static const char _data_FX_MODE_2DFUNKYPLANK[] PROGMEM = "Funky Plank@Scroll spe ///////////////////////// // 2D Akemi // ///////////////////////// -static uint8_t akemi[][] PROGMEM = { +static uint8_t akemi[] PROGMEM = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,2,2,3,3,3,3,3,3,2,2,0,0,0,0,0,0,0,0,0,0,0, diff --git a/wled00/FX.h b/wled00/FX.h index 5bfdd1930..1fc4ffe06 100644 --- a/wled00/FX.h +++ b/wled00/FX.h @@ -454,11 +454,11 @@ typedef struct Segment { uint8_t _briT; // temporary brightness uint8_t _cctT; // temporary CCT CRGBPalette16 _palT; // temporary palette - //uint8_t _modeP; // previous mode/effect (transitioning effects is way more complex than this) + uint8_t _modeP; // previous mode/effect uint32_t _start; uint16_t _dur; - Transition(uint16_t dur=750) : _briT(255), _cctT(127), _palT(CRGBPalette16(CRGB::Black)), /*_modeP(FX_MODE_STATIC),*/ _start(millis()), _dur(dur) {} - Transition(uint16_t d, uint8_t b, uint8_t c, const uint32_t *o) : _briT(b), _cctT(c), _palT(CRGBPalette16(CRGB::Black)), /*_modeP(FX_MODE_STATIC),*/ _start(millis()), _dur(d) { + Transition(uint16_t dur=750) : _briT(255), _cctT(127), _palT(CRGBPalette16(CRGB::Black)), _modeP(FX_MODE_STATIC), _start(millis()), _dur(dur) {} + Transition(uint16_t d, uint8_t b, uint8_t c, const uint32_t *o) : _briT(b), _cctT(c), _palT(CRGBPalette16(CRGB::Black)), _modeP(FX_MODE_STATIC), _start(millis()), _dur(d) { for (size_t i=0; i_briT = _briT; _t->_cctT = _cctT; _t->_palT = _palT; - //_t->_modeT = _modeP; + _t->_modeP = _modeP; for (size_t i=0; i_colorT[i] = _colorT[i]; // comment out if using transition struct as it is done in constructor //_dur = dur; @@ -240,6 +240,14 @@ uint8_t Segment::currentBri(uint8_t briNew, bool useCct) { } } +uint8_t Segment::currentMode(uint8_t newMode) { + if (transitional && _t) { + return _t->_modeP; + } else { + return newMode; + } +} + uint32_t Segment::currentColor(uint8_t slot, uint32_t colorNew) { return transitional && _t ? color_blend(_t->_colorT[slot], colorNew, progress(), true) : colorNew; } @@ -340,6 +348,7 @@ void Segment::handleTransition() { if (mode == FX_MODE_STATIC && next_time > maxWait) next_time = maxWait; if (progress() == 0xFFFFU) { if (_t) { + if (_t->_modeP != mode) markForReset(); delete _t; _t = nullptr; } @@ -884,14 +893,14 @@ void WS2812FX::service() { if (!cctFromRgb || correctWB) busses.setSegmentCCT(seg.currentBri(seg.cct, true), correctWB); for (uint8_t c = 0; c < NUM_COLORS; c++) _colors_t[c] = gamma32(_colors_t[c]); - seg.handleTransition(); - // effect blending (execute previous effect) // actual code may be a bit more involved as effects have runtime data including allocated memory //if (getOption(SEG_OPTION_TRANSITIONAL) && seg._modeP) (*_mode[seg._modeP])(progress()); - delay = (*_mode[seg.mode])(); + delay = (*_mode[seg.currentMode(seg.mode)])(); if (seg.mode != FX_MODE_HALLOWEEN_EYES) seg.call++; if (seg.transitional && delay > FRAMETIME) delay = FRAMETIME; // foce faster updates during transition + + seg.handleTransition(); } seg.next_time = nowUp + delay; @@ -1457,7 +1466,7 @@ void WS2812FX::printSize() { size_t size = 0; for (Segment seg : _segments) size += seg.getSize(); - DEBUG_PRINTF("Segments: %d -> %uB\n", sizeof(Segment), _segments.size(), size); + DEBUG_PRINTF("Segments: %d -> %uB\n", _segments.size(), size); DEBUG_PRINTF("Modes: %d*%d=%uB\n", sizeof(mode_ptr), _mode.size(), (_mode.capacity()*sizeof(mode_ptr))); DEBUG_PRINTF("Data: %d*%d=%uB\n", sizeof(const char *), _modeData.size(), (_modeData.capacity()*sizeof(const char *))); DEBUG_PRINTF("Map: %d*%d=%uB\n", sizeof(uint16_t), (int)customMappingSize, customMappingSize*sizeof(uint16_t)); diff --git a/wled00/json.cpp b/wled00/json.cpp index c8b5941ea..9aacdd60f 100644 --- a/wled00/json.cpp +++ b/wled00/json.cpp @@ -175,8 +175,8 @@ void deserializeSegment(JsonObject elem, byte it, byte presetId) if (getVal(elem["fx"], &fx, 0, strip.getModeCount())) { //load effect ('r' random, '~' inc/dec, 0-255 exact value) if (!presetId && currentPlaylist>=0) unloadPlaylist(); if (fx != seg.mode) { - //seg.startTransition(strip.getTransition()); // set effect transitions - seg.markForReset(); + seg.startTransition(strip.getTransition()); // set effect transitions + //seg.markForReset(); seg.mode = fx; // load default values from effect string if effect is selected without // any other effect parameter (i.e. effect clicked in UI)