add sizing to scan mode

This commit is contained in:
fishbone-git 2019-12-23 22:49:29 +01:00
parent 9bc72df1b5
commit f07578e0cb

View File

@ -302,6 +302,7 @@ uint16_t WS2812FX::scan(bool dual)
uint32_t perc = now % cycleTime; uint32_t perc = now % cycleTime;
uint16_t prog = (perc * 65535) / cycleTime; uint16_t prog = (perc * 65535) / cycleTime;
uint16_t ledIndex = (prog * ((SEGLEN * 2) - 2)) >> 16; uint16_t ledIndex = (prog * ((SEGLEN * 2) - 2)) >> 16;
uint16_t size = 1 + SEGMENT.intensity >> 3;
fill(SEGCOLOR(1)); fill(SEGCOLOR(1));
@ -309,18 +310,21 @@ uint16_t WS2812FX::scan(bool dual)
led_offset = abs(led_offset); led_offset = abs(led_offset);
uint16_t i = SEGMENT.start + 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) { if (dual) {
uint16_t i2 = SEGMENT.start + SEGLEN - led_offset - 1; 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; return FRAMETIME;
} }
//NOTE: add intensity (more than 1 pixel lit)
/* /*
* Runs a single pixel back and forth. * Runs a single pixel back and forth.
*/ */