fixes trail flickering randomly. thx @blazoncek for discovering

This commit is contained in:
Damian Schneider
2025-01-31 14:10:03 +01:00
committed by Frank
parent ea9ae2c46b
commit 54578f7e61

View File

@@ -2547,10 +2547,27 @@ uint16_t mode_meteor() {
const int max = SEGMENT.palette==5 || !SEGMENT.check1 ? 240 : 255;
// fade all leds to colors[1] in LEDs one step
for (int i = 0; i < SEGLEN; i++) {
if (random8() <= 255 - SEGMENT.intensity) {
byte meteorTrailDecay = 162 + random8(92);
trail[i] = scale8(trail[i], meteorTrailDecay);
uint32_t col = SEGMENT.check1 ? SEGMENT.color_from_palette(i, true, false, 0, trail[i]) : SEGMENT.color_from_palette(trail[i], false, true, 255);
uint32_t col;
if (hw_random8() <= 255 - SEGMENT.intensity) {
if(meteorSmooth) {
if (trail[i] > 0) {
int change = trail[i] + 4 - hw_random8(24); //change each time between -20 and +4
trail[i] = constrain(change, 0, max);
}
col = SEGMENT.check1 ? SEGMENT.color_from_palette(i, true, false, 0, trail[i]) : SEGMENT.color_from_palette(trail[i], false, true, 255);
}
else {
trail[i] = scale8(trail[i], 128 + hw_random8(127));
int index = trail[i];
int idx = 255;
int bri = SEGMENT.palette==35 || SEGMENT.palette==36 ? 255 : trail[i];
if (!SEGMENT.check1) {
idx = 0;
index = map(i,0,SEGLEN,0,max);
bri = trail[i];
}
col = SEGMENT.color_from_palette(index, false, false, idx, bri); // full brightness for Fire
}
SEGMENT.setPixelColor(i, col);
}
}