From f07578e0cbc0faebd1d2ca82da5f248b9e33e5e6 Mon Sep 17 00:00:00 2001 From: fishbone-git Date: Mon, 23 Dec 2019 22:49:29 +0100 Subject: [PATCH 1/2] add sizing to scan mode --- wled00/FX.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/wled00/FX.cpp b/wled00/FX.cpp index 465d6e44..2f951281 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -302,6 +302,7 @@ uint16_t WS2812FX::scan(bool dual) uint32_t perc = now % cycleTime; uint16_t prog = (perc * 65535) / cycleTime; uint16_t ledIndex = (prog * ((SEGLEN * 2) - 2)) >> 16; + uint16_t size = 1 + SEGMENT.intensity >> 3; fill(SEGCOLOR(1)); @@ -309,18 +310,21 @@ uint16_t WS2812FX::scan(bool dual) led_offset = abs(led_offset); uint16_t i = SEGMENT.start + led_offset; - setPixelColor(i, color_from_palette(i, true, PALETTE_SOLID_WRAP, 0)); + for (int16_t j=i-size/2; j<=i+size/2; j++) { + if (j>=0) setPixelColor(j, color_from_palette(i, true, PALETTE_SOLID_WRAP, 0)); + } if (dual) { uint16_t i2 = SEGMENT.start + SEGLEN - led_offset - 1; - setPixelColor(i2, color_from_palette(i2, true, PALETTE_SOLID_WRAP, 0)); + for (int16_t j=i2-size/2; j<=i2+size/2; j++) { + if (j>=0) setPixelColor(j, color_from_palette(i2, true, PALETTE_SOLID_WRAP, 0)); + } } return FRAMETIME; } -//NOTE: add intensity (more than 1 pixel lit) /* * Runs a single pixel back and forth. */ From 924f97cbe818f79b90d411c6ca23c986155d137e Mon Sep 17 00:00:00 2001 From: cschwinne Date: Tue, 24 Dec 2019 00:48:51 +0100 Subject: [PATCH 2/2] Improvements to scan and segment fixes --- wled00/FX.cpp | 28 ++++++++++++++-------------- wled00/wled00.ino | 2 +- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/wled00/FX.cpp b/wled00/FX.cpp index 8349f0f6..aeba1485 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -301,24 +301,24 @@ uint16_t WS2812FX::scan(bool dual) uint32_t cycleTime = 750 + (255 - SEGMENT.speed)*150; uint32_t perc = now % cycleTime; uint16_t prog = (perc * 65535) / cycleTime; - uint16_t ledIndex = (prog * ((SEGLEN * 2) - 2)) >> 16; - uint16_t size = 1 + SEGMENT.intensity >> 3; + uint16_t size = 1 + ((SEGMENT.intensity * SEGLEN) >>9); + uint16_t ledIndex = (prog * ((SEGLEN *2) - size *2)) >> 16; fill(SEGCOLOR(1)); - int led_offset = ledIndex - (SEGLEN - 1); + int led_offset = ledIndex - (SEGLEN - size); led_offset = abs(led_offset); - uint16_t i = SEGMENT.start + led_offset; - for (int16_t j=i-size/2; j<=i+size/2; j++) { - if (j>=0) setPixelColor(j, color_from_palette(i, true, PALETTE_SOLID_WRAP, 0)); + if (dual) { + for (uint16_t j = led_offset; j < led_offset + size; j++) { + uint16_t i2 = SEGMENT.stop -1 -j; + setPixelColor(i2, color_from_palette(i2, true, PALETTE_SOLID_WRAP, (SEGCOLOR(2))? 2:0)); + } } - if (dual) { - uint16_t i2 = SEGMENT.start + SEGLEN - led_offset - 1; - for (int16_t j=i2-size/2; j<=i2+size/2; j++) { - if (j>=0) setPixelColor(j, color_from_palette(i2, true, PALETTE_SOLID_WRAP, 0)); - } + for (uint16_t j = led_offset; j < led_offset + size; j++) { + uint16_t i = SEGMENT.start + j; + setPixelColor(i, color_from_palette(i, true, PALETTE_SOLID_WRAP, 0)); } return FRAMETIME; @@ -998,7 +998,7 @@ uint16_t WS2812FX::larson_scanner(bool dual) { for (uint16_t i = SEGENV.step; i < index; i++) { uint16_t j = (SEGENV.aux0)?i:SEGLEN-1-i; - setPixelColor(j, color_from_palette(j, true, PALETTE_SOLID_WRAP, 0)); + setPixelColor(SEGMENT.start + j, color_from_palette(j, true, PALETTE_SOLID_WRAP, 0)); } if (dual) { uint32_t c; @@ -1010,7 +1010,7 @@ uint16_t WS2812FX::larson_scanner(bool dual) { for (uint16_t i = SEGENV.step; i < index; i++) { uint16_t j = (SEGENV.aux0)?SEGLEN-1-i:i; - setPixelColor(j, c); + setPixelColor(SEGMENT.start + j, c); } } @@ -1028,7 +1028,7 @@ uint16_t WS2812FX::mode_comet(void) { fade_out(SEGMENT.intensity); - setPixelColor(index, color_from_palette(index, true, PALETTE_SOLID_WRAP, 0)); + setPixelColor(SEGMENT.start + index, color_from_palette(index, true, PALETTE_SOLID_WRAP, 0)); return FRAMETIME; } diff --git a/wled00/wled00.ino b/wled00/wled00.ino index 90bf0ac8..a577c95d 100644 --- a/wled00/wled00.ino +++ b/wled00/wled00.ino @@ -98,7 +98,7 @@ //version code in format yymmddb (b = daily build) -#define VERSION 1912231 +#define VERSION 1912232 char versionString[] = "0.9.0-b2";