Refactor PRINTER_EVENT_LEDS, apply to M303 (#12038)

Co-Authored-By: Giuliano Zaro <gmagician@users.noreply.github.com>
This commit is contained in:
Giuliano Zaro
2018-10-11 04:25:43 +02:00
committed by Scott Lahteine
parent d8d76cd2ba
commit d43d4e4219
13 changed files with 205 additions and 73 deletions

View File

@@ -32,7 +32,7 @@
#include "../../module/temperature.h"
void handle_status_leds(void) {
static bool red_led = false;
static uint8_t red_led = LOW;
static millis_t next_status_led_update_ms = 0;
if (ELAPSED(millis(), next_status_led_update_ms)) {
next_status_led_update_ms += 500; // Update every 0.5s
@@ -42,16 +42,16 @@ void handle_status_leds(void) {
#endif
HOTEND_LOOP()
max_temp = MAX(max_temp, thermalManager.degHotend(e), thermalManager.degTargetHotend(e));
const bool new_led = (max_temp > 55.0) ? true : (max_temp < 54.0) ? false : red_led;
const uint8_t new_led = (max_temp > 55.0) ? HIGH : (max_temp < 54.0) ? LOW : red_led;
if (new_led != red_led) {
red_led = new_led;
#if PIN_EXISTS(STAT_LED_RED)
WRITE(STAT_LED_RED_PIN, new_led ? HIGH : LOW);
WRITE(STAT_LED_RED_PIN, new_led);
#if PIN_EXISTS(STAT_LED_BLUE)
WRITE(STAT_LED_BLUE_PIN, new_led ? LOW : HIGH);
WRITE(STAT_LED_BLUE_PIN, !new_led);
#endif
#else
WRITE(STAT_LED_BLUE_PIN, new_led ? HIGH : LOW);
WRITE(STAT_LED_BLUE_PIN, new_led);
#endif
}
}