From 1711ac9a88f65ce4315622cdf341d9ce6f272154 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Kristan?= Date: Mon, 22 Aug 2022 14:35:34 +0200 Subject: [PATCH 01/10] Fix in is2D() Horizontal and vertical 1D segment Index overshoot fix. --- wled00/FX.h | 2 +- wled00/FX_2Dfcn.cpp | 1 + wled00/FX_fcn.cpp | 22 +++++++++++++++++----- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/wled00/FX.h b/wled00/FX.h index 486c9af45..2bb88a2bb 100644 --- a/wled00/FX.h +++ b/wled00/FX.h @@ -501,7 +501,7 @@ typedef struct Segment { inline bool getOption(uint8_t n) const { return ((options >> n) & 0x01); } inline bool isSelected(void) const { return selected; } inline bool isActive(void) const { return stop > start; } - inline bool is2D(void) const { return !(startY == 0 && stopY == 1); } + inline bool is2D(void) const { return (width()>1 && height()>1); } inline uint16_t width(void) const { return stop - start; } // segment width in physical pixels (length if 1D) inline uint16_t height(void) const { return stopY - startY; } // segment height (if 2D) in physical pixels inline uint16_t length(void) const { return width() * height(); } // segment length (count) in physical pixels diff --git a/wled00/FX_2Dfcn.cpp b/wled00/FX_2Dfcn.cpp index bbbae7598..a99894769 100644 --- a/wled00/FX_2Dfcn.cpp +++ b/wled00/FX_2Dfcn.cpp @@ -150,6 +150,7 @@ uint16_t IRAM_ATTR Segment::XY(uint16_t x, uint16_t y) { void IRAM_ATTR Segment::setPixelColorXY(int x, int y, uint32_t col) { if (!strip.isMatrix) return; // not a matrix set-up + if (x >= virtualWidth() || y >= virtualHeight()) return; // if pixel would fall out of virtual segment just exit if (leds) leds[XY(x,y)] = col; diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index dedff0eff..dd621d711 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -442,11 +442,16 @@ void IRAM_ATTR Segment::setPixelColor(int i, uint32_t col) break; case M12_Circle: // expand in circular fashion from center - for (float degrees = 0.0f; degrees <= 90.0f; degrees += 89.99f / (sqrtf((float)max(vH,vW))*i+1)) { // this may prove too many iterations on larger matrices - // may want to try float version as well (with or without antialiasing) - int x = roundf(sin_t(degrees*DEG_TO_RAD) * i); - int y = roundf(cos_t(degrees*DEG_TO_RAD) * i); - setPixelColorXY(x, y, col); + if (i==0) + setPixelColorXY(0, 0, col); + else { + float step = HALF_PI / (2*i+1); // sqrtf((float)max(vH,vW))*i+1 + for (float rad = 0.0f; rad <= HALF_PI; rad += step) { + // may want to try float version as well (with or without antialiasing) + int x = roundf(sin_t(rad) * i); + int y = roundf(cos_t(rad) * i); + setPixelColorXY(x, y, col); + } } break; case M12_Block: @@ -455,9 +460,16 @@ void IRAM_ATTR Segment::setPixelColor(int i, uint32_t col) break; } return; + } else if (width()==1 && height()>1) { + // we have a vertical 1D segment + setPixelColorXY(0, i, col); // transpose + } else if (width()>1 && height()==1) { + // we have a horizontal 1D segment + setPixelColorXY(i, 0, col); } #endif + if (i >= virtualLength()) return; // if pixel would fall out of segment just exit if (leds) leds[i] = col; uint16_t len = length(); From 59b038b8c428983a52d88a9b7c487a5c6c28dcd8 Mon Sep 17 00:00:00 2001 From: Blaz Kristan Date: Mon, 22 Aug 2022 16:48:19 +0200 Subject: [PATCH 02/10] Index under- shooting. Fix for arc 1D to 2D mapping. UI segment 2D mapping fix. Watchdog reposition & flicker reduction. --- wled00/FX_2Dfcn.cpp | 2 +- wled00/FX_fcn.cpp | 6 +- wled00/data/index.js | 32 +- wled00/html_ui.h | 3678 +++++++++++++++++++++--------------------- wled00/wled.cpp | 5 +- wled00/wled.h | 4 +- 6 files changed, 1868 insertions(+), 1859 deletions(-) diff --git a/wled00/FX_2Dfcn.cpp b/wled00/FX_2Dfcn.cpp index a99894769..e567e49fd 100644 --- a/wled00/FX_2Dfcn.cpp +++ b/wled00/FX_2Dfcn.cpp @@ -150,7 +150,7 @@ uint16_t IRAM_ATTR Segment::XY(uint16_t x, uint16_t y) { void IRAM_ATTR Segment::setPixelColorXY(int x, int y, uint32_t col) { if (!strip.isMatrix) return; // not a matrix set-up - if (x >= virtualWidth() || y >= virtualHeight()) return; // if pixel would fall out of virtual segment just exit + if (x >= virtualWidth() || y >= virtualHeight() || x<0 || y<0) return; // if pixel would fall out of virtual segment just exit if (leds) leds[XY(x,y)] = col; diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index dd621d711..4edf05c13 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -445,8 +445,8 @@ void IRAM_ATTR Segment::setPixelColor(int i, uint32_t col) if (i==0) setPixelColorXY(0, 0, col); else { - float step = HALF_PI / (2*i+1); // sqrtf((float)max(vH,vW))*i+1 - for (float rad = 0.0f; rad <= HALF_PI; rad += step) { + float step = HALF_PI / (2*i); + for (float rad = 0.0f; rad <= HALF_PI+step/2; rad += step) { // may want to try float version as well (with or without antialiasing) int x = roundf(sin_t(rad) * i); int y = roundf(cos_t(rad) * i); @@ -469,7 +469,7 @@ void IRAM_ATTR Segment::setPixelColor(int i, uint32_t col) } #endif - if (i >= virtualLength()) return; // if pixel would fall out of segment just exit + if (i >= virtualLength() || i<0) return; // if pixel would fall out of segment just exit if (leds) leds[i] = col; uint16_t len = length(); diff --git a/wled00/data/index.js b/wled00/data/index.js index f9f74111f..5985a6d97 100644 --- a/wled00/data/index.js +++ b/wled00/data/index.js @@ -701,6 +701,10 @@ function populateSegments(s)
`; + let staX = inst.start; + let stoX = inst.stop; + let staY = inst.startY; + let stoY = inst.stopY; let rvXck = ``; let miXck = ``; let rvYck = "", miYck =""; @@ -745,14 +749,14 @@ function populateSegments(s) ${isM?'':'Offset'} - - + + ${isM?miXck+'
'+rvXck:''} ${isM ? 'Start Y'+(cfg.comp.seglen?'Height':'Stop Y')+''+ ''+ - ''+ - ''+ + ''+ + ''+ ''+miYck+'
'+rvYck+''+ '':''} @@ -768,7 +772,7 @@ function populateSegments(s)
${!isM?rvXck:''} - ${isM?map2D:''} + ${isM&&stoY-staY>1&&stoX-staX>1?map2D:''} ${s.AudioReactive && s.AudioReactive.on ? "" : sndSim}