Browse Source

Move M355 caselight to cpp

Scott Lahteine 8 years ago
parent
commit
8ca0b2fd68

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

130
   #include "feature/leds/tempstat.h"
130
   #include "feature/leds/tempstat.h"
131
 #endif
131
 #endif
132
 
132
 
133
+#if HAS_CASE_LIGHT
134
+  #include "feature/caselight.h"
135
+#endif
136
+
133
 bool Running = true;
137
 bool Running = true;
134
 
138
 
135
 /**
139
 /**
358
   SYNC_PLAN_POSITION_KINEMATIC();
362
   SYNC_PLAN_POSITION_KINEMATIC();
359
 }
363
 }
360
 
364
 
361
-#include "gcode/feature/caselight/M355.h"
362
-
363
 #if ENABLED(MIXING_EXTRUDER)
365
 #if ENABLED(MIXING_EXTRUDER)
364
   #include "gcode/feature/mixing/M163.h"
366
   #include "gcode/feature/mixing/M163.h"
365
   #if MIXING_VIRTUAL_TOOLS > 1
367
   #if MIXING_VIRTUAL_TOOLS > 1
859
   #endif
861
   #endif
860
 
862
 
861
   #if HAS_CASE_LIGHT
863
   #if HAS_CASE_LIGHT
862
-    case_light_on = CASE_LIGHT_DEFAULT_ON;
863
-    case_light_brightness = CASE_LIGHT_DEFAULT_BRIGHTNESS;
864
     update_case_light();
864
     update_case_light();
865
   #endif
865
   #endif
866
 
866
 

+ 46
- 0
Marlin/src/feature/caselight.cpp View File

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
+#include "../inc/MarlinConfig.h"
24
+
25
+#if HAS_CASE_LIGHT
26
+
27
+int case_light_brightness = CASE_LIGHT_DEFAULT_BRIGHTNESS;
28
+bool case_light_on = CASE_LIGHT_DEFAULT_ON;
29
+    
30
+#ifndef INVERT_CASE_LIGHT
31
+  #define INVERT_CASE_LIGHT false
32
+#endif
33
+
34
+void update_case_light() {
35
+  SET_OUTPUT(CASE_LIGHT_PIN);
36
+  uint8_t case_light_bright = (uint8_t)case_light_brightness;
37
+  if (case_light_on) {
38
+    if (USEABLE_HARDWARE_PWM(CASE_LIGHT_PIN)) {
39
+      analogWrite(CASE_LIGHT_PIN, INVERT_CASE_LIGHT ? 255 - case_light_brightness : case_light_brightness );
40
+    }
41
+    else WRITE(CASE_LIGHT_PIN, INVERT_CASE_LIGHT ? LOW : HIGH);
42
+  }
43
+  else WRITE(CASE_LIGHT_PIN, INVERT_CASE_LIGHT ? HIGH : LOW);
44
+}
45
+
46
+#endif // HAS_CASE_LIGHT

+ 31
- 0
Marlin/src/feature/caselight.h View File

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
+#ifndef __CASELIGHT_H__
24
+#define __CASELIGHT_H__
25
+
26
+extern int case_light_brightness;  // LCD routine wants INT
27
+extern bool case_light_on;
28
+
29
+void update_case_light();
30
+
31
+#endif // __CASELIGHT_H__

Marlin/src/gcode/feature/caselight/M355.h → Marlin/src/gcode/feature/caselight/M355.cpp View File

20
  *
20
  *
21
  */
21
  */
22
 
22
 
23
-#if HAS_CASE_LIGHT
23
+#include "../../gcode.h"
24
 
24
 
25
-  #ifndef INVERT_CASE_LIGHT
26
-    #define INVERT_CASE_LIGHT false
27
-  #endif
28
-  int case_light_brightness;  // LCD routine wants INT
29
-  bool case_light_on;
25
+#include "../../../inc/MarlinConfig.h"
30
 
26
 
31
-  void update_case_light() {
32
-    pinMode(CASE_LIGHT_PIN, OUTPUT); // digitalWrite doesn't set the port mode
33
-    uint8_t case_light_bright = (uint8_t)case_light_brightness;
34
-    if (case_light_on) {
35
-      if (USEABLE_HARDWARE_PWM(CASE_LIGHT_PIN)) {
36
-        analogWrite(CASE_LIGHT_PIN, INVERT_CASE_LIGHT ? 255 - case_light_brightness : case_light_brightness );
37
-      }
38
-      else WRITE(CASE_LIGHT_PIN, INVERT_CASE_LIGHT ? LOW : HIGH);
39
-    }
40
-    else WRITE(CASE_LIGHT_PIN, INVERT_CASE_LIGHT ? HIGH : LOW);
41
-  }
42
-
43
-#endif // HAS_CASE_LIGHT
27
+#if HAS_CASE_LIGHT
28
+  #include "../../../feature/caselight.h"
29
+#endif
44
 
30
 
45
 /**
31
 /**
46
  * M355: Turn case light on/off and set brightness
32
  * M355: Turn case light on/off and set brightness
54
  *   M355 P200 S0 turns off the light & sets the brightness level
40
  *   M355 P200 S0 turns off the light & sets the brightness level
55
  *   M355 S1 turns on the light with a brightness of 200 (assuming a PWM pin)
41
  *   M355 S1 turns on the light with a brightness of 200 (assuming a PWM pin)
56
  */
42
  */
57
-void gcode_M355() {
43
+void GcodeSuite::M355() {
58
   #if HAS_CASE_LIGHT
44
   #if HAS_CASE_LIGHT
59
     uint8_t args = 0;
45
     uint8_t args = 0;
60
     if (parser.seenval('P')) ++args, case_light_brightness = parser.value_byte();
46
     if (parser.seenval('P')) ++args, case_light_brightness = parser.value_byte();

+ 1
- 4
Marlin/src/gcode/gcode.cpp View File

119
 extern void gcode_M163();
119
 extern void gcode_M163();
120
 extern void gcode_M164();
120
 extern void gcode_M164();
121
 extern void gcode_M165();
121
 extern void gcode_M165();
122
-extern void gcode_M355();
123
 extern void gcode_M999();
122
 extern void gcode_M999();
124
 extern void gcode_T(uint8_t tmp_extruder);
123
 extern void gcode_T(uint8_t tmp_extruder);
125
 
124
 
676
         case 351: M351(); break;    // M351: Toggle MS1 MS2 pins directly, S# determines MS1 or MS2, X# sets the pin high/low.
675
         case 351: M351(); break;    // M351: Toggle MS1 MS2 pins directly, S# determines MS1 or MS2, X# sets the pin high/low.
677
       #endif
676
       #endif
678
 
677
 
679
-      case 355: // M355 set case light brightness
680
-        gcode_M355();
681
-        break;
678
+      case 355: M355(); break;      // M355: Set case light brightness
682
 
679
 
683
       #if ENABLED(DEBUG_GCODE_PARSER)
680
       #if ENABLED(DEBUG_GCODE_PARSER)
684
         case 800:
681
         case 800:

Loading…
Cancel
Save