Skip to content

Commit f439867

Browse files
committed
Add speed control to fire and disco
1 parent ee0f2cd commit f439867

1 file changed

Lines changed: 27 additions & 13 deletions

File tree

src/core/led_control.cpp

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -249,24 +249,38 @@ void ledEffectTask(void *pvParameters) {
249249
}
250250
#endif
251251

252-
} else if (ledEffect == LED_EFFECT_FIRE) {
253-
for (int i = 0; i < LED_COUNT; i++) {
254-
uint8_t flicker = random(150, 255);
255-
uint8_t isRed = random(0, 2);
256-
if (isRed) {
257-
leds[i] = CRGB(flicker, random(0, flicker / 3), 0);
258-
} else {
259-
leds[i] = CRGB(255, random(flicker / 2, flicker), 0);
252+
} else if (ledEffect == LED_EFFECT_DISCO) {
253+
uint8_t cycleFrames = 11 - ledEffectSpeed;
254+
#ifdef HAS_ENCODER_LED
255+
if ((ledEffectSpeed == 11 && EncoderLedChange != 0) ||
256+
(ledEffectSpeed < 11 && frame % cycleFrames == 0)) {
257+
if (ledEffectSpeed == 11 && EncoderLedChange != 0) { EncoderLedChange = 0; }
258+
#else
259+
if (frame % cycleFrames == 0) {
260+
#endif
261+
for (int i = 0; i < LED_COUNT; i++) {
262+
short randomHue = random(0, 360);
263+
leds[i] = hsvToRgb(randomHue, 255, 255);
260264
}
261265
}
262266
frame++;
263-
264-
} else if (ledEffect == LED_EFFECT_DISCO) {
265-
uint8_t cycleFrames = 12 - ledEffectSpeed;
267+
} else if (ledEffect == LED_EFFECT_FIRE) {
268+
uint8_t cycleFrames = 11 - ledEffectSpeed;
269+
#ifdef HAS_ENCODER_LED
270+
if ((ledEffectSpeed == 11 && EncoderLedChange != 0) ||
271+
(ledEffectSpeed < 11 && frame % cycleFrames == 0)) {
272+
if (ledEffectSpeed == 11 && EncoderLedChange != 0) { EncoderLedChange = 0; }
273+
#else
266274
if (frame % cycleFrames == 0) {
275+
#endif
267276
for (int i = 0; i < LED_COUNT; i++) {
268-
short randomHue = random(0, 360);
269-
leds[i] = hsvToRgb(randomHue, 200, 255);
277+
uint8_t flicker = random(150, 255);
278+
uint8_t isRed = random(0, 2);
279+
if (isRed) {
280+
leds[i] = CRGB(flicker, random(0, flicker / 3), 0);
281+
} else {
282+
leds[i] = CRGB(255, random(flicker / 2, flicker), 0);
283+
}
270284
}
271285
}
272286
frame++;

0 commit comments

Comments
 (0)