diff --git a/wled00/FX.cpp b/wled00/FX.cpp index 5ff60a08..b6069ebb 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -3470,9 +3470,9 @@ static const char _data_FX_MODE_DRIP[] PROGMEM = "Drip@Gravity,# of drips;!,!;!; typedef struct Tetris { float pos; float speed; - uint32_t col; - uint16_t aux0; // 2D-fication of SEGENV.aux0 (brick size) - uint16_t aux1; // 2D-fication of SEGENV.aux1 (stack size) + uint8_t col; // color index + uint16_t brick; // brick size in pixels + uint16_t stack; // stack size in pixels uint32_t step; // 2D-fication of SEGENV.step (state) } tetris; @@ -3491,7 +3491,7 @@ uint16_t mode_tetrix(void) { static void runStrip(size_t stripNr, Tetris *drop) { // initialize dropping on first call or segment full if (SEGENV.call == 0) { - drop->aux1 = 0; // reset brick stack size + drop->stack = 0; // reset brick stack size drop->step = 0; //for (int i=0; ispeed = float(SEGLEN * FRAMETIME) / float(speed); // set speed drop->pos = SEGLEN; // start at end of segment (no need to subtract 1) - drop->col = SEGMENT.color_from_palette(random8(0,15)<<4,false,false,0); // limit color choices so there is enough HUE gap + drop->col = random8(0,15)<<4; // limit color choices so there is enough HUE gap drop->step = 1; // drop state (0 init, 1 forming, 2 falling) - drop->aux0 = (SEGMENT.intensity ? (SEGMENT.intensity>>5)+1 : random8(1,5)) * (1+(SEGLEN>>6)); // size of brick + drop->brick = (SEGMENT.intensity ? (SEGMENT.intensity>>5)+1 : random8(1,5)) * (1+(SEGLEN>>6)); // size of brick } if (drop->step == 1) { // forming @@ -3516,24 +3516,27 @@ uint16_t mode_tetrix(void) { } if (drop->step == 2) { // falling - if (drop->pos > drop->aux1) { // fall until top of stack + if (drop->pos > drop->stack) { // fall until top of stack drop->pos -= drop->speed; // may add gravity as: speed += gravity - if (uint16_t(drop->pos) < drop->aux1) drop->pos = drop->aux1; - for (int i=int(drop->pos); ipos)+drop->aux0 ? drop->col : SEGCOLOR(1)); + if (uint16_t(drop->pos) < drop->stack) drop->pos = drop->stack; + for (int i=int(drop->pos); ipos)+drop->brick ? SEGMENT.color_from_palette(drop->col, false, false, 0) : SEGCOLOR(1); + SEGMENT.setPixelColor(i | int((stripNr+1)<<16), col); + } } else { // we hit bottom drop->step = 0; // proceed with next brick, go back to init - drop->aux1 += drop->aux0; // increase the stack size - if (drop->aux1 >= SEGLEN) drop->step = millis() + 2000; // fade out stack + drop->stack += drop->brick; // increase the stack size + if (drop->stack >= SEGLEN) drop->step = millis() + 2000; // fade out stack } } - if (drop->step > 2) { - drop->aux0 = 0; // reset brick size (no more growing) + if (drop->step > 2) { // fade strip + drop->brick = 0; // reset brick size (no more growing) if (drop->step > millis()) { // allow fading of virtual strip - for (int i=0; iaux1 = 0; // reset brick stack size + drop->stack = 0; // reset brick stack size drop->step = 0; // proceed with next brick } } diff --git a/wled00/FX.h b/wled00/FX.h index c7f0d9b7..38539a9d 100644 --- a/wled00/FX.h +++ b/wled00/FX.h @@ -357,26 +357,21 @@ typedef struct Segment { union { uint16_t options; //bit pattern: msb first: [transposed mirrorY reverseY] transitional (tbd) paused needspixelstate mirrored on reverse selected struct { - bool selected : 1; // 0 : selected - bool reverse : 1; // 1 : reversed - bool on : 1; // 2 : is On - bool mirror : 1; // 3 : mirrored - bool pxs : 1; // 4 : indicates that the effect does not use FRAMETIME or needs getPixelColor (?) - bool freeze : 1; // 5 : paused/frozen - bool reset : 1; // 6 : indicates that Segment runtime requires reset - bool transitional: 1; // 7 : transitional (there is transition occuring) - bool reverse_y : 1; // 8 : reversed Y (2D) - bool mirror_y : 1; // 9 : mirrored Y (2D) - bool transpose : 1; // 10 : transposed (2D, swapped X & Y) - uint8_t map1D2D : 3; // 11-13 : mapping for 1D effect on 2D (0-use as strip, 1-expand vertically, 2-circular/arc, 3-rectangular/corner, ...) - uint8_t soundSim : 2; // 14-15 : 0-3 sound simulation types + bool selected : 1; // 0 : selected + bool reverse : 1; // 1 : reversed + bool on : 1; // 2 : is On + bool mirror : 1; // 3 : mirrored + bool freeze : 1; // 4 : paused/frozen + bool reset : 1; // 5 : indicates that Segment runtime requires reset + bool transitional: 1; // 6 : transitional (there is transition occuring) + bool reverse_y : 1; // 7 : reversed Y (2D) + bool mirror_y : 1; // 8 : mirrored Y (2D) + bool transpose : 1; // 9 : transposed (2D, swapped X & Y) + uint8_t map1D2D : 3; // 10-12 : mapping for 1D effect on 2D (0-use as strip, 1-expand vertically, 2-circular/arc, 3-rectangular/corner, ...) + uint8_t soundSim : 3; // 13-15 : 0-7 sound simulation types }; }; uint8_t grouping, spacing; - //struct { - // uint8_t grouping : 4; // maximum 15 pixels in a group - // uint8_t spacing : 4; // maximum 15 pixels per gap - //}; uint8_t opacity; uint32_t colors[NUM_COLORS]; uint8_t cct; //0==1900K, 255==10091K @@ -418,17 +413,20 @@ typedef struct Segment { // transition data, valid only if transitional==true, holds values during transition struct Transition { uint32_t _colorT[NUM_COLORS]; - uint8_t _briT; // temporary brightness - uint8_t _cctT; // temporary CCT - CRGBPalette16 _palT; // temporary palette - uint8_t _modeP; // previous mode/effect + uint8_t _briT; // temporary brightness + uint8_t _cctT; // temporary CCT + CRGBPalette16 _palT; // temporary palette + uint8_t _modeP; // previous mode/effect + //uint16_t _aux0, _aux1; // previous mode/effect runtime data + //uint32_t _step, _call; // previous mode/effect runtime data + //byte *_data; // previous mode/effect runtime data 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) { for (size_t i=0; i_briT = _briT; - _t->_cctT = _cctT; + _t->_briT = _briT; + _t->_cctT = _cctT; _t->_palT = _palT; _t->_modeP = _modeP; for (size_t i=0; i_colorT[i] = _colorT[i]; @@ -625,7 +625,7 @@ uint8_t Segment::differs(Segment& b) const { if (stopY != b.stopY) d |= SEG_DIFFERS_BOUNDS; //bit pattern: msb first: [transposed mirrorY reverseY] transitional (tbd) paused needspixelstate mirrored on reverse selected - if ((options & 0b1111111100101110) != (b.options & 0b1111111100101110)) d |= SEG_DIFFERS_OPT; + if ((options & 0b1111111110011110) != (b.options & 0b1111111110011110)) d |= SEG_DIFFERS_OPT; if ((options & 0x01) != (b.options & 0x01)) d |= SEG_DIFFERS_SEL; for (uint8_t i = 0; i < NUM_COLORS; i++) if (colors[i] != b.colors[i]) d |= SEG_DIFFERS_COL; diff --git a/wled00/const.h b/wled00/const.h index 377e7b35..c1676bc4 100644 --- a/wled00/const.h +++ b/wled00/const.h @@ -226,13 +226,12 @@ #define SEG_OPTION_REVERSED 1 #define SEG_OPTION_ON 2 #define SEG_OPTION_MIRROR 3 //Indicates that the effect will be mirrored within the segment -#define SEG_OPTION_NONUNITY 4 //Indicates that the effect does not use FRAMETIME or needs getPixelColor -#define SEG_OPTION_FREEZE 5 //Segment contents will not be refreshed -#define SEG_OPTION_RESET 6 //Segment runtime requires reset -#define SEG_OPTION_TRANSITIONAL 7 -#define SEG_OPTION_REVERSED_Y 8 -#define SEG_OPTION_MIRROR_Y 9 -#define SEG_OPTION_TRANSPOSED 10 +#define SEG_OPTION_FREEZE 4 //Segment contents will not be refreshed +#define SEG_OPTION_RESET 5 //Segment runtime requires reset +#define SEG_OPTION_TRANSITIONAL 6 +#define SEG_OPTION_REVERSED_Y 7 +#define SEG_OPTION_MIRROR_Y 8 +#define SEG_OPTION_TRANSPOSED 9 //Segment differs return byte #define SEG_DIFFERS_BRI 0x01 diff --git a/wled00/data/index.js b/wled00/data/index.js index eb31302d..d8bbbdd1 100644 --- a/wled00/data/index.js +++ b/wled00/data/index.js @@ -714,7 +714,7 @@ function populateSegments(s) } let map2D = `
Expand 1D FX