diff --git a/wled00/FX.h b/wled00/FX.h index 98cb5131..61b64189 100644 --- a/wled00/FX.h +++ b/wled00/FX.h @@ -245,9 +245,10 @@ class WS2812FX { // segment parameters public: - typedef struct Segment { // 24 bytes + typedef struct Segment { // 25 (28 in memory?) bytes uint16_t start; uint16_t stop; //segment invalid if stop == 0 + uint16_t offset; uint8_t speed; uint8_t intensity; uint8_t palette; @@ -863,8 +864,8 @@ class WS2812FX { uint8_t _segment_index = 0; uint8_t _segment_index_palette_last = 99; segment _segments[MAX_NUM_SEGMENTS] = { // SRAM footprint: 24 bytes per element - // start, stop, speed, intensity, palette, mode, options, grouping, spacing, opacity (unused), color[] - { 0, 7, DEFAULT_SPEED, 128, 0, DEFAULT_MODE, NO_OPTIONS, 1, 0, 255, {DEFAULT_COLOR}} + // start, stop, offset, speed, intensity, palette, mode, options, grouping, spacing, opacity (unused), color[] + {0, 7, 0, DEFAULT_SPEED, 128, 0, DEFAULT_MODE, NO_OPTIONS, 1, 0, 255, {DEFAULT_COLOR}} }; segment_runtime _segment_runtimes[MAX_NUM_SEGMENTS]; // SRAM footprint: 28 bytes per element friend class Segment_runtime; diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index 81f9f689..8a9d2cb3 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -237,15 +237,24 @@ void WS2812FX::setPixelColor(uint16_t i, byte r, byte g, byte b, byte w) bool reversed = IS_REVERSE; uint16_t realIndex = realPixelIndex(i); + uint16_t len = SEGMENT.length(); for (uint16_t j = 0; j < SEGMENT.grouping; j++) { int indexSet = realIndex + (reversed ? -j : j); if (indexSet >= SEGMENT.start && indexSet < SEGMENT.stop) { if (IS_MIRROR) { //set the corresponding mirrored pixel uint16_t indexMir = SEGMENT.stop - indexSet + SEGMENT.start - 1; + /* offset/phase */ + indexMir += SEGMENT.offset; + if (indexMir >= SEGMENT.stop) indexMir -= len; + if (indexMir < customMappingSize) indexMir = customMappingTable[indexMir]; busses.setPixelColor(indexMir, col); } + /* offset/phase */ + indexSet += SEGMENT.offset; + if (indexSet >= SEGMENT.stop) indexSet -= len; + if (indexSet < customMappingSize) indexSet = customMappingTable[indexSet]; busses.setPixelColor(indexSet, col); } @@ -525,11 +534,15 @@ uint32_t WS2812FX::getColor(void) { uint32_t WS2812FX::getPixelColor(uint16_t i) { i = realPixelIndex(i); + + if (SEGLEN) { + /* offset/phase */ + i += SEGMENT.offset; + if (i >= SEGMENT.stop) i -= SEGMENT.length(); + } if (i < customMappingSize) i = customMappingTable[i]; - if (i >= _length) return 0; - return busses.getPixelColor(i); } diff --git a/wled00/data/settings_leds.htm b/wled00/data/settings_leds.htm index 5c00c827..b24648fb 100644 --- a/wled00/data/settings_leds.htm +++ b/wled00/data/settings_leds.htm @@ -183,7 +183,6 @@ gId('ledwarning').style.color = (sLC > maxPB || maxLC > maxPB || bquot > 100) ? 'red':'orange'; gId('wreason').innerHTML = (bquot > 80) ? "80% of max. LED memory" +(bquot>100 ? ` (WARNING: Using over ${maxM}B!)` : "") : "800 LEDs per pin"; - //var val = Math.ceil((100 + d.Sf.LC.value * laprev)/500)/2; var val = Math.ceil((100 + sLC * laprev)/500)/2; val = (val > 5) ? Math.ceil(val) : val; var s = ""; @@ -209,6 +208,8 @@ function lastEnd(i) { if (i<1) return 0; v = parseInt(d.getElementsByName("LS"+(i-1))[0].value) + parseInt(d.getElementsByName("LC"+(i-1))[0].value); + var type = parseInt(d.getElementsByName("LT"+(i-1))[0].value); + if (type > 31 && type < 48) v = 1; //PWM busses if (isNaN(v)) return 0; return v; } diff --git a/wled00/html_settings.h b/wled00/html_settings.h index e1729af5..c982eda8 100644 --- a/wled00/html_settings.h +++ b/wled00/html_settings.h @@ -75,7 +75,7 @@ onclick="B()">Back // Autogenerated from wled00/data/settings_leds.htm, do not edit!! const char PAGE_settings_leds[] PROGMEM = R"=====(LED Settings