spots effect improvements
* use native 32bit types (similar to upstream) * avoids gaps on left/right side of strip, by using higher accuracy for zoneLength * prevent overflow on "s" * fix wrongly named slider in "spots fade"
This commit is contained in:
@@ -3015,21 +3015,22 @@ uint16_t spots_base(uint16_t threshold)
|
||||
if (SEGLEN == 1) return mode_oops();
|
||||
if (!SEGMENT.check2) SEGMENT.fill(SEGCOLOR(1));
|
||||
|
||||
uint16_t maxZones = SEGLEN >> 2;
|
||||
uint16_t zones = 1 + ((SEGMENT.intensity * maxZones) >> 8);
|
||||
uint16_t zoneLen = SEGLEN / zones;
|
||||
uint16_t offset = (SEGLEN - zones * zoneLen) >> 1;
|
||||
unsigned maxZones = max(1, SEGLEN >> 2); // WLEDMM prevent "0 zones"
|
||||
unsigned zones = 1U + ((uint32_t(SEGMENT.intensity) * maxZones) >> 8);
|
||||
unsigned zoneLen = SEGLEN / zones;
|
||||
unsigned zoneLen8 = zones < 8 ? zoneLen * 8 : SEGLEN / (zones >> 3); // WLEDMM zoneLength * 8 -> avoids gaps at right/left sides
|
||||
unsigned offset = (uint32_t(SEGLEN) - ((zones * zoneLen8)>>3)) >> 1;
|
||||
|
||||
for (int z = 0; z < zones; z++)
|
||||
for (unsigned z = 0; z < zones; z++)
|
||||
{
|
||||
uint16_t pos = offset + z * zoneLen;
|
||||
for (int i = 0; i < zoneLen; i++)
|
||||
unsigned pos = offset +((z * zoneLen8)>>3);
|
||||
for (unsigned i = 0; i < zoneLen; i++)
|
||||
{
|
||||
uint16_t wave = triwave16((i * 0xFFFF) / zoneLen);
|
||||
unsigned wave = triwave16((i * 0xFFFF) / zoneLen);
|
||||
if (wave > threshold) {
|
||||
uint16_t index = 0 + pos + i;
|
||||
uint8_t s = (wave - threshold)*255 / (0xFFFF - threshold);
|
||||
SEGMENT.setPixelColor(index, color_blend(SEGMENT.color_from_palette(index, true, PALETTE_SOLID_WRAP, 0), SEGCOLOR(1), 255-s));
|
||||
int index = pos + i;
|
||||
unsigned s = ((wave - threshold)*255 / (0xFFFF - threshold)) & 0xFF; // WLEDMM prevent overflow
|
||||
SEGMENT.setPixelColor(index, color_blend(SEGMENT.color_from_palette(index, true, PALETTE_SOLID_WRAP, 0), SEGCOLOR(1), uint8_t(255-s)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3054,7 +3055,7 @@ uint16_t mode_spots_fade()
|
||||
uint16_t tr = (t >> 1) + (t >> 2);
|
||||
return spots_base(tr);
|
||||
}
|
||||
static const char _data_FX_MODE_SPOTS_FADE[] PROGMEM = "Spots Fade@Spread,Width,,,,,Overlay;!,!;!";
|
||||
static const char _data_FX_MODE_SPOTS_FADE[] PROGMEM = "Spots Fade@Speed,Width,,,,,Overlay;!,!;!";
|
||||
|
||||
|
||||
//each needs 12 bytes
|
||||
|
||||
Reference in New Issue
Block a user