1
0
mirror of https://github.com/MarlinFirmware/Marlin.git synced 2024-11-23 12:04:19 +00:00

[2.0.x] Fix TEMP_STAT_LED startup init (#13120)

This commit is contained in:
Giuliano Zaro 2019-02-12 00:27:59 +01:00 committed by Scott Lahteine
parent 2bd6ce4b62
commit f7efe6f6c5

View File

@ -32,26 +32,24 @@
#include "../../module/temperature.h"
void handle_status_leds(void) {
static uint8_t red_led = LOW;
static int8_t old_red = -1; // Invalid value to force LED initialization
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
float max_temp = 0.0;
#if HAS_HEATED_BED
max_temp = MAX(max_temp, thermalManager.degTargetBed(), thermalManager.degBed());
max_temp = MAX(thermalManager.degTargetBed(), thermalManager.degBed());
#endif
HOTEND_LOOP()
max_temp = MAX(max_temp, thermalManager.degHotend(e), thermalManager.degTargetHotend(e));
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;
const int8_t new_red = (max_temp > 55.0) ? HIGH : (max_temp < 54.0 || old_red < 0) ? LOW : old_red;
if (new_red != old_red) {
old_red = new_red;
#if PIN_EXISTS(STAT_LED_RED)
WRITE(STAT_LED_RED_PIN, new_led);
#if PIN_EXISTS(STAT_LED_BLUE)
WRITE(STAT_LED_BLUE_PIN, !new_led);
#endif
#else
WRITE(STAT_LED_BLUE_PIN, new_led);
WRITE(STAT_LED_RED_PIN, new_red);
#endif
#if PIN_EXISTS(STAT_LED_BLUE)
WRITE(STAT_LED_BLUE_PIN, !new_red);
#endif
}
}