refactored LED Display logic to make it more readable

This commit is contained in:
2025-04-16 18:42:06 +02:00
parent 6c5586e71b
commit f53744c23c

View File

@@ -417,20 +417,33 @@ void loop() {
} }
} }
// update the LED Display // If either team has tapped out, skip updating the display.
if (!(buttonREDTEAMtapout || buttonBLUETEAMtapout)) { if (buttonREDTEAMtapout || buttonBLUETEAMtapout) {
return;
}
// Display the Ready CountDown timer if it is running.
if (ReadyCountDown.isRunning()) { if (ReadyCountDown.isRunning()) {
sendTimeDisplay((ReadyCountDown.remaining()/60%60), (ReadyCountDown.remaining()%60), 255, 165, 0, CLOCK_LED_BRIGHTNESS); sendTimeDisplay((ReadyCountDown.remaining()/60%60), (ReadyCountDown.remaining()%60), 255, 165, 0, CLOCK_LED_BRIGHTNESS);
return;
}
// When the RUMBLE switch is active, always show the rumble timer.
if (switchRUMBLE.on()) {
sendTimeDisplay((rumbleTIME.elapsed()/60%60), (rumbleTIME.elapsed()%60), 0, 255, 255, CLOCK_LED_BRIGHTNESS);
return;
}
// If the fight countdown isn't running and isn't paused, determine which countdown color to use.
if (!FightCountDown.isRunning() && !countdownPAUSED) {
// Choose green if both buttons are active; otherwise, choose magenta.
if (buttonREDTEAMvar && buttonBLUETEAMvar) {
sendTimeDisplay((countdownTIME/60%60), (countdownTIME%60), 0, 255, 0, CLOCK_LED_BRIGHTNESS);
} else { } else {
if (!switchRUMBLE.on()) { sendTimeDisplay((countdownTIME/60%60), (countdownTIME%60), 255, 0, 255, CLOCK_LED_BRIGHTNESS);
if (!FightCountDown.isRunning() && countdownPAUSED == false) { }
sendTimeDisplay((countdownTIME/60%60), (countdownTIME%60), 0, XDAS, 0, CLOCK_LED_BRIGHTNESS);
} else { } else {
// Otherwise, show the fight countdown timer.
sendTimeDisplay((FightCountDown.remaining()/60%60), (FightCountDown.remaining()%60), 0, 255, 0, CLOCK_LED_BRIGHTNESS); sendTimeDisplay((FightCountDown.remaining()/60%60), (FightCountDown.remaining()%60), 0, 255, 0, CLOCK_LED_BRIGHTNESS);
} }
} else if (switchRUMBLE.on()) {
sendTimeDisplay((rumbleTIME.elapsed()/60%60), (rumbleTIME.elapsed()%60), 0, 255, 255, CLOCK_LED_BRIGHTNESS);
}
}
}
} }