Percent Effect with speed-slider (#637)
This commit is contained in:
parent
b41dacb6c0
commit
2b0a38d25d
@ -2985,23 +2985,26 @@ uint16_t WS2812FX::mode_plasma(void) {
|
|||||||
uint16_t WS2812FX::mode_percent(void) {
|
uint16_t WS2812FX::mode_percent(void) {
|
||||||
|
|
||||||
uint8_t percent = max(0, min(100, SEGMENT.intensity));
|
uint8_t percent = max(0, min(100, SEGMENT.intensity));
|
||||||
|
uint16_t active_leds = SEGLEN * percent / 100.0;
|
||||||
float active_float = SEGLEN * percent / 100.0;
|
|
||||||
uint16_t active_leds = active_float;
|
if (SEGENV.call == 0) SEGENV.step = 0;
|
||||||
uint16_t active_part = (active_float - active_leds) * 255;
|
uint8_t size = (1 + ((SEGMENT.speed * SEGLEN) >> 11)) & 0xFF ;
|
||||||
CRGB color;
|
|
||||||
|
for (uint16_t i = 0; i < SEGLEN; i++) {
|
||||||
for (uint16_t i = 0; i < SEGLEN; i++) {
|
if (i < SEGENV.step) {
|
||||||
if (i < active_leds) {
|
|
||||||
setPixelColor(i, color_from_palette(i, true, PALETTE_SOLID_WRAP, 0));
|
setPixelColor(i, color_from_palette(i, true, PALETTE_SOLID_WRAP, 0));
|
||||||
}
|
}
|
||||||
else if (i == active_leds) {
|
|
||||||
setPixelColor(i, color_from_palette(i, true, PALETTE_SOLID_WRAP, 0, active_part));
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
setPixelColor(i, SEGCOLOR(1));
|
setPixelColor(i, SEGCOLOR(1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(active_leds > SEGENV.step) {
|
||||||
|
SEGENV.step += size;
|
||||||
|
if (SEGENV.step > active_leds) SEGENV.step = active_leds;
|
||||||
|
} else if (active_leds < SEGENV.step) {
|
||||||
|
SEGENV.step -= size;
|
||||||
|
if (SEGENV.step < active_leds) SEGENV.step = active_leds;
|
||||||
|
}
|
||||||
|
|
||||||
return FRAMETIME;
|
return FRAMETIME;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user