Browse Source

Temp stat LEDs

Scott Lahteine 7 years ago
parent
commit
a41130f854
3 changed files with 96 additions and 31 deletions
  1. 4
    31
      Marlin/src/Marlin.cpp
  2. 60
    0
      Marlin/src/feature/leds/tempstat.cpp
  3. 32
    0
      Marlin/src/feature/leds/tempstat.h

+ 4
- 31
Marlin/src/Marlin.cpp View File

@@ -129,6 +129,10 @@
129 129
   #include "feature/pause.h"
130 130
 #endif
131 131
 
132
+#if ENABLED(TEMP_STAT_LEDS)
133
+  #include "feature/leds/tempstat.h"
134
+#endif
135
+
132 136
 bool Running = true;
133 137
 
134 138
 /**
@@ -657,37 +661,6 @@ void quickstop_stepper() {
657 661
 
658 662
 #endif // USE_CONTROLLER_FAN
659 663
 
660
-#if ENABLED(TEMP_STAT_LEDS)
661
-
662
-  static bool red_led = false;
663
-  static millis_t next_status_led_update_ms = 0;
664
-
665
-  void handle_status_leds(void) {
666
-    if (ELAPSED(millis(), next_status_led_update_ms)) {
667
-      next_status_led_update_ms += 500; // Update every 0.5s
668
-      float max_temp = 0.0;
669
-      #if HAS_TEMP_BED
670
-        max_temp = MAX3(max_temp, thermalManager.degTargetBed(), thermalManager.degBed());
671
-      #endif
672
-      HOTEND_LOOP()
673
-        max_temp = MAX3(max_temp, thermalManager.degHotend(e), thermalManager.degTargetHotend(e));
674
-      const bool new_led = (max_temp > 55.0) ? true : (max_temp < 54.0) ? false : red_led;
675
-      if (new_led != red_led) {
676
-        red_led = new_led;
677
-        #if PIN_EXISTS(STAT_LED_RED)
678
-          WRITE(STAT_LED_RED_PIN, new_led ? HIGH : LOW);
679
-          #if PIN_EXISTS(STAT_LED_BLUE)
680
-            WRITE(STAT_LED_BLUE_PIN, new_led ? LOW : HIGH);
681
-          #endif
682
-        #else
683
-          WRITE(STAT_LED_BLUE_PIN, new_led ? HIGH : LOW);
684
-        #endif
685
-      }
686
-    }
687
-  }
688
-
689
-#endif
690
-
691 664
 #if ENABLED(FILAMENT_RUNOUT_SENSOR)
692 665
 
693 666
   void handle_filament_runout() {

+ 60
- 0
Marlin/src/feature/leds/tempstat.cpp View File

@@ -0,0 +1,60 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+/**
24
+ * Marlin RGB LED general support
25
+ */
26
+
27
+#include "../../inc/MarlinConfig.h"
28
+
29
+#if ENABLED(TEMP_STAT_LEDS)
30
+
31
+#include "tempstat.h"
32
+#include "../../module/temperature.h"
33
+
34
+void handle_status_leds(void) {
35
+  static bool red_led = false;
36
+  static millis_t next_status_led_update_ms = 0;
37
+  if (ELAPSED(millis(), next_status_led_update_ms)) {
38
+    next_status_led_update_ms += 500; // Update every 0.5s
39
+    float max_temp = 0.0;
40
+    #if HAS_TEMP_BED
41
+      max_temp = MAX3(max_temp, thermalManager.degTargetBed(), thermalManager.degBed());
42
+    #endif
43
+    HOTEND_LOOP()
44
+      max_temp = MAX3(max_temp, thermalManager.degHotend(e), thermalManager.degTargetHotend(e));
45
+    const bool new_led = (max_temp > 55.0) ? true : (max_temp < 54.0) ? false : red_led;
46
+    if (new_led != red_led) {
47
+      red_led = new_led;
48
+      #if PIN_EXISTS(STAT_LED_RED)
49
+        WRITE(STAT_LED_RED_PIN, new_led ? HIGH : LOW);
50
+        #if PIN_EXISTS(STAT_LED_BLUE)
51
+          WRITE(STAT_LED_BLUE_PIN, new_led ? LOW : HIGH);
52
+        #endif
53
+      #else
54
+        WRITE(STAT_LED_BLUE_PIN, new_led ? HIGH : LOW);
55
+      #endif
56
+    }
57
+  }
58
+}
59
+
60
+#endif // TEMP_STAT_LEDS

+ 32
- 0
Marlin/src/feature/leds/tempstat.h View File

@@ -0,0 +1,32 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+/**
24
+ * Marlin general RGB LED support
25
+ */
26
+
27
+#ifndef __TEMPSTAT_H__
28
+#define __TEMPSTAT_H__
29
+
30
+void handle_status_leds(void);
31
+
32
+#endif // __TEMPSTAT_H__

Loading…
Cancel
Save