[2.0.x] Fix TEMP_STAT_LED startup init (#13120)
This commit is contained in:
		
				
					committed by
					
						
						Scott Lahteine
					
				
			
			
				
	
			
			
			
						parent
						
							2bd6ce4b62
						
					
				
				
					commit
					f7efe6f6c5
				
			@@ -32,26 +32,24 @@
 | 
				
			|||||||
#include "../../module/temperature.h"
 | 
					#include "../../module/temperature.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void handle_status_leds(void) {
 | 
					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;
 | 
					  static millis_t next_status_led_update_ms = 0;
 | 
				
			||||||
  if (ELAPSED(millis(), next_status_led_update_ms)) {
 | 
					  if (ELAPSED(millis(), next_status_led_update_ms)) {
 | 
				
			||||||
    next_status_led_update_ms += 500; // Update every 0.5s
 | 
					    next_status_led_update_ms += 500; // Update every 0.5s
 | 
				
			||||||
    float max_temp = 0.0;
 | 
					    float max_temp = 0.0;
 | 
				
			||||||
    #if HAS_HEATED_BED
 | 
					    #if HAS_HEATED_BED
 | 
				
			||||||
      max_temp = MAX(max_temp, thermalManager.degTargetBed(), thermalManager.degBed());
 | 
					      max_temp = MAX(thermalManager.degTargetBed(), thermalManager.degBed());
 | 
				
			||||||
    #endif
 | 
					    #endif
 | 
				
			||||||
    HOTEND_LOOP()
 | 
					    HOTEND_LOOP()
 | 
				
			||||||
      max_temp = MAX(max_temp, thermalManager.degHotend(e), thermalManager.degTargetHotend(e));
 | 
					      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;
 | 
					    const int8_t new_red = (max_temp > 55.0) ? HIGH : (max_temp < 54.0 || old_red < 0) ? LOW : old_red;
 | 
				
			||||||
    if (new_led != red_led) {
 | 
					    if (new_red != old_red) {
 | 
				
			||||||
      red_led = new_led;
 | 
					      old_red = new_red;
 | 
				
			||||||
      #if PIN_EXISTS(STAT_LED_RED)
 | 
					      #if PIN_EXISTS(STAT_LED_RED)
 | 
				
			||||||
        WRITE(STAT_LED_RED_PIN, new_led);
 | 
					        WRITE(STAT_LED_RED_PIN, new_red);
 | 
				
			||||||
        #if PIN_EXISTS(STAT_LED_BLUE)
 | 
					      #endif
 | 
				
			||||||
          WRITE(STAT_LED_BLUE_PIN, !new_led);
 | 
					      #if PIN_EXISTS(STAT_LED_BLUE)
 | 
				
			||||||
        #endif
 | 
					        WRITE(STAT_LED_BLUE_PIN, !new_red);
 | 
				
			||||||
      #else
 | 
					 | 
				
			||||||
        WRITE(STAT_LED_BLUE_PIN, new_led);
 | 
					 | 
				
			||||||
      #endif
 | 
					      #endif
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user