Kaynağa Gözat

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

Giuliano Zaro 6 yıl önce
ebeveyn
işleme
f7efe6f6c5
1 değiştirilmiş dosya ile 9 ekleme ve 11 silme
  1. 9
    11
      Marlin/src/feature/leds/tempstat.cpp

+ 9
- 11
Marlin/src/feature/leds/tempstat.cpp Dosyayı Görüntüle

@@ -32,26 +32,24 @@
32 32
 #include "../../module/temperature.h"
33 33
 
34 34
 void handle_status_leds(void) {
35
-  static uint8_t red_led = LOW;
35
+  static int8_t old_red = -1;  // Invalid value to force LED initialization
36 36
   static millis_t next_status_led_update_ms = 0;
37 37
   if (ELAPSED(millis(), next_status_led_update_ms)) {
38 38
     next_status_led_update_ms += 500; // Update every 0.5s
39 39
     float max_temp = 0.0;
40 40
     #if HAS_HEATED_BED
41
-      max_temp = MAX(max_temp, thermalManager.degTargetBed(), thermalManager.degBed());
41
+      max_temp = MAX(thermalManager.degTargetBed(), thermalManager.degBed());
42 42
     #endif
43 43
     HOTEND_LOOP()
44 44
       max_temp = MAX(max_temp, thermalManager.degHotend(e), thermalManager.degTargetHotend(e));
45
-    const uint8_t new_led = (max_temp > 55.0) ? HIGH : (max_temp < 54.0) ? LOW : red_led;
46
-    if (new_led != red_led) {
47
-      red_led = new_led;
45
+    const int8_t new_red = (max_temp > 55.0) ? HIGH : (max_temp < 54.0 || old_red < 0) ? LOW : old_red;
46
+    if (new_red != old_red) {
47
+      old_red = new_red;
48 48
       #if PIN_EXISTS(STAT_LED_RED)
49
-        WRITE(STAT_LED_RED_PIN, new_led);
50
-        #if PIN_EXISTS(STAT_LED_BLUE)
51
-          WRITE(STAT_LED_BLUE_PIN, !new_led);
52
-        #endif
53
-      #else
54
-        WRITE(STAT_LED_BLUE_PIN, new_led);
49
+        WRITE(STAT_LED_RED_PIN, new_red);
50
+      #endif
51
+      #if PIN_EXISTS(STAT_LED_BLUE)
52
+        WRITE(STAT_LED_BLUE_PIN, !new_red);
55 53
       #endif
56 54
     }
57 55
   }

Loading…
İptal
Kaydet