Browse Source

Merge pull request #5343 from thinkyhead/rc_invert_case_light

Allow case light pin to be active low
Scott Lahteine 7 years ago
parent
commit
b0361ebe4f

+ 5
- 2
Marlin/Configuration_adv.h View File

@@ -226,8 +226,11 @@
226 226
 
227 227
 // Define a pin to turn case light on/off
228 228
 //#define CASE_LIGHT_PIN 4
229
-//#define CASE_LIGHT_DEFAULT_ON   // Uncomment to set default state to on
230
-//#define MENU_ITEM_CASE_LIGHT    // Uncomment to have a Case Light On / Off entry in main menu
229
+#if PIN_EXISTS(CASE_LIGHT)
230
+  #define INVERT_CASE_LIGHT false   // Set to true if HIGH is the OFF state (active low)
231
+  //#define CASE_LIGHT_DEFAULT_ON   // Uncomment to set default state to on
232
+  //#define MENU_ITEM_CASE_LIGHT    // Uncomment to have a Case Light On / Off entry in main menu
233
+#endif
231 234
 
232 235
 //===========================================================================
233 236
 //============================ Mechanical Settings ==========================

+ 2
- 2
Marlin/Marlin_main.cpp View File

@@ -7328,8 +7328,8 @@ inline void gcode_M907() {
7328 7328
   uint8_t case_light_brightness = 255;
7329 7329
 
7330 7330
   void update_case_light() {
7331
-    digitalWrite(CASE_LIGHT_PIN, case_light_on ? HIGH : LOW);
7332
-    analogWrite(CASE_LIGHT_PIN, case_light_on ? case_light_brightness : 0);
7331
+    digitalWrite(CASE_LIGHT_PIN, case_light_on != INVERT_CASE_LIGHT ? HIGH : LOW);
7332
+    analogWrite(CASE_LIGHT_PIN, case_light_on != INVERT_CASE_LIGHT ? case_light_brightness : 0);
7333 7333
   }
7334 7334
 
7335 7335
   /**

+ 5
- 2
Marlin/example_configurations/Cartesio/Configuration_adv.h View File

@@ -226,8 +226,11 @@
226 226
 
227 227
 // Define a pin to turn case light on/off
228 228
 //#define CASE_LIGHT_PIN 4
229
-//#define CASE_LIGHT_DEFAULT_ON   // Uncomment to set default state to on
230
-//#define MENU_ITEM_CASE_LIGHT    // Uncomment to have a Case Light On / Off entry in main menu
229
+#if PIN_EXISTS(CASE_LIGHT)
230
+  #define INVERT_CASE_LIGHT false   // Set to true if HIGH is the OFF state (active low)
231
+  //#define CASE_LIGHT_DEFAULT_ON   // Uncomment to set default state to on
232
+  //#define MENU_ITEM_CASE_LIGHT    // Uncomment to have a Case Light On / Off entry in main menu
233
+#endif
231 234
 
232 235
 //===========================================================================
233 236
 //============================ Mechanical Settings ==========================

+ 5
- 2
Marlin/example_configurations/Felix/Configuration_adv.h View File

@@ -226,8 +226,11 @@
226 226
 
227 227
 // Define a pin to turn case light on/off
228 228
 //#define CASE_LIGHT_PIN 4
229
-//#define CASE_LIGHT_DEFAULT_ON   // Uncomment to set default state to on
230
-//#define MENU_ITEM_CASE_LIGHT    // Uncomment to have a Case Light On / Off entry in main menu
229
+#if PIN_EXISTS(CASE_LIGHT)
230
+  #define INVERT_CASE_LIGHT false   // Set to true if HIGH is the OFF state (active low)
231
+  //#define CASE_LIGHT_DEFAULT_ON   // Uncomment to set default state to on
232
+  //#define MENU_ITEM_CASE_LIGHT    // Uncomment to have a Case Light On / Off entry in main menu
233
+#endif
231 234
 
232 235
 //===========================================================================
233 236
 //============================ Mechanical Settings ==========================

+ 5
- 2
Marlin/example_configurations/Hephestos/Configuration_adv.h View File

@@ -226,8 +226,11 @@
226 226
 
227 227
 // Define a pin to turn case light on/off
228 228
 //#define CASE_LIGHT_PIN 4
229
-//#define CASE_LIGHT_DEFAULT_ON   // Uncomment to set default state to on
230
-//#define MENU_ITEM_CASE_LIGHT    // Uncomment to have a Case Light On / Off entry in main menu
229
+#if PIN_EXISTS(CASE_LIGHT)
230
+  #define INVERT_CASE_LIGHT false   // Set to true if HIGH is the OFF state (active low)
231
+  //#define CASE_LIGHT_DEFAULT_ON   // Uncomment to set default state to on
232
+  //#define MENU_ITEM_CASE_LIGHT    // Uncomment to have a Case Light On / Off entry in main menu
233
+#endif
231 234
 
232 235
 //===========================================================================
233 236
 //============================ Mechanical Settings ==========================

+ 5
- 2
Marlin/example_configurations/Hephestos_2/Configuration_adv.h View File

@@ -226,8 +226,11 @@
226 226
 
227 227
 // Define a pin to turn case light on/off
228 228
 //#define CASE_LIGHT_PIN 4
229
-//#define CASE_LIGHT_DEFAULT_ON   // Uncomment to set default state to on
230
-//#define MENU_ITEM_CASE_LIGHT    // Uncomment to have a Case Light On / Off entry in main menu
229
+#if PIN_EXISTS(CASE_LIGHT)
230
+  #define INVERT_CASE_LIGHT false   // Set to true if HIGH is the OFF state (active low)
231
+  //#define CASE_LIGHT_DEFAULT_ON   // Uncomment to set default state to on
232
+  //#define MENU_ITEM_CASE_LIGHT    // Uncomment to have a Case Light On / Off entry in main menu
233
+#endif
231 234
 
232 235
 //===========================================================================
233 236
 //============================ Mechanical Settings ==========================

+ 5
- 2
Marlin/example_configurations/K8200/Configuration_adv.h View File

@@ -239,8 +239,11 @@
239 239
 
240 240
 // Define a pin to turn case light on/off
241 241
 //#define CASE_LIGHT_PIN 4
242
-//#define CASE_LIGHT_DEFAULT_ON   // Uncomment to set default state to on
243
-//#define MENU_ITEM_CASE_LIGHT    // Uncomment to have a Case Light On / Off entry in main menu
242
+#if PIN_EXISTS(CASE_LIGHT)
243
+  #define INVERT_CASE_LIGHT false   // Set to true if HIGH is the OFF state (active low)
244
+  //#define CASE_LIGHT_DEFAULT_ON   // Uncomment to set default state to on
245
+  //#define MENU_ITEM_CASE_LIGHT    // Uncomment to have a Case Light On / Off entry in main menu
246
+#endif
244 247
 
245 248
 //===========================================================================
246 249
 //============================ Mechanical Settings ==========================

+ 5
- 2
Marlin/example_configurations/K8400/Configuration_adv.h View File

@@ -226,8 +226,11 @@
226 226
 
227 227
 // Define a pin to turn case light on/off
228 228
 //#define CASE_LIGHT_PIN 4
229
-//#define CASE_LIGHT_DEFAULT_ON   // Uncomment to set default state to on
230
-//#define MENU_ITEM_CASE_LIGHT    // Uncomment to have a Case Light On / Off entry in main menu
229
+#if PIN_EXISTS(CASE_LIGHT)
230
+  #define INVERT_CASE_LIGHT false   // Set to true if HIGH is the OFF state (active low)
231
+  //#define CASE_LIGHT_DEFAULT_ON   // Uncomment to set default state to on
232
+  //#define MENU_ITEM_CASE_LIGHT    // Uncomment to have a Case Light On / Off entry in main menu
233
+#endif
231 234
 
232 235
 //===========================================================================
233 236
 //============================ Mechanical Settings ==========================

+ 5
- 2
Marlin/example_configurations/RigidBot/Configuration_adv.h View File

@@ -226,8 +226,11 @@
226 226
 
227 227
 // Define a pin to turn case light on/off
228 228
 //#define CASE_LIGHT_PIN 4
229
-//#define CASE_LIGHT_DEFAULT_ON   // Uncomment to set default state to on
230
-//#define MENU_ITEM_CASE_LIGHT    // Uncomment to have a Case Light On / Off entry in main menu
229
+#if PIN_EXISTS(CASE_LIGHT)
230
+  #define INVERT_CASE_LIGHT false   // Set to true if HIGH is the OFF state (active low)
231
+  //#define CASE_LIGHT_DEFAULT_ON   // Uncomment to set default state to on
232
+  //#define MENU_ITEM_CASE_LIGHT    // Uncomment to have a Case Light On / Off entry in main menu
233
+#endif
231 234
 
232 235
 //===========================================================================
233 236
 //============================ Mechanical Settings ==========================

+ 5
- 2
Marlin/example_configurations/SCARA/Configuration_adv.h View File

@@ -226,8 +226,11 @@
226 226
 
227 227
 // Define a pin to turn case light on/off
228 228
 //#define CASE_LIGHT_PIN 4
229
-//#define CASE_LIGHT_DEFAULT_ON   // Uncomment to set default state to on
230
-//#define MENU_ITEM_CASE_LIGHT    // Uncomment to have a Case Light On / Off entry in main menu
229
+#if PIN_EXISTS(CASE_LIGHT)
230
+  #define INVERT_CASE_LIGHT false   // Set to true if HIGH is the OFF state (active low)
231
+  //#define CASE_LIGHT_DEFAULT_ON   // Uncomment to set default state to on
232
+  //#define MENU_ITEM_CASE_LIGHT    // Uncomment to have a Case Light On / Off entry in main menu
233
+#endif
231 234
 
232 235
 //===========================================================================
233 236
 //============================ Mechanical Settings ==========================

+ 5
- 2
Marlin/example_configurations/TAZ4/Configuration_adv.h View File

@@ -234,8 +234,11 @@
234 234
 
235 235
 // Define a pin to turn case light on/off
236 236
 //#define CASE_LIGHT_PIN 4
237
-//#define CASE_LIGHT_DEFAULT_ON   // Uncomment to set default state to on
238
-//#define MENU_ITEM_CASE_LIGHT    // Uncomment to have a Case Light On / Off entry in main menu
237
+#if PIN_EXISTS(CASE_LIGHT)
238
+  #define INVERT_CASE_LIGHT false   // Set to true if HIGH is the OFF state (active low)
239
+  //#define CASE_LIGHT_DEFAULT_ON   // Uncomment to set default state to on
240
+  //#define MENU_ITEM_CASE_LIGHT    // Uncomment to have a Case Light On / Off entry in main menu
241
+#endif
239 242
 
240 243
 //===========================================================================
241 244
 //============================ Mechanical Settings ==========================

+ 5
- 2
Marlin/example_configurations/WITBOX/Configuration_adv.h View File

@@ -226,8 +226,11 @@
226 226
 
227 227
 // Define a pin to turn case light on/off
228 228
 //#define CASE_LIGHT_PIN 4
229
-//#define CASE_LIGHT_DEFAULT_ON   // Uncomment to set default state to on
230
-//#define MENU_ITEM_CASE_LIGHT    // Uncomment to have a Case Light On / Off entry in main menu
229
+#if PIN_EXISTS(CASE_LIGHT)
230
+  #define INVERT_CASE_LIGHT false   // Set to true if HIGH is the OFF state (active low)
231
+  //#define CASE_LIGHT_DEFAULT_ON   // Uncomment to set default state to on
232
+  //#define MENU_ITEM_CASE_LIGHT    // Uncomment to have a Case Light On / Off entry in main menu
233
+#endif
231 234
 
232 235
 //===========================================================================
233 236
 //============================ Mechanical Settings ==========================

+ 5
- 2
Marlin/example_configurations/delta/biv2.5/Configuration_adv.h View File

@@ -226,8 +226,11 @@
226 226
 
227 227
 // Define a pin to turn case light on/off
228 228
 //#define CASE_LIGHT_PIN 4
229
-//#define CASE_LIGHT_DEFAULT_ON   // Uncomment to set default state to on
230
-//#define MENU_ITEM_CASE_LIGHT    // Uncomment to have a Case Light On / Off entry in main menu
229
+#if PIN_EXISTS(CASE_LIGHT)
230
+  #define INVERT_CASE_LIGHT false   // Set to true if HIGH is the OFF state (active low)
231
+  //#define CASE_LIGHT_DEFAULT_ON   // Uncomment to set default state to on
232
+  //#define MENU_ITEM_CASE_LIGHT    // Uncomment to have a Case Light On / Off entry in main menu
233
+#endif
231 234
 
232 235
 //===========================================================================
233 236
 //============================ Mechanical Settings ==========================

+ 5
- 2
Marlin/example_configurations/delta/generic/Configuration_adv.h View File

@@ -226,8 +226,11 @@
226 226
 
227 227
 // Define a pin to turn case light on/off
228 228
 //#define CASE_LIGHT_PIN 4
229
-//#define CASE_LIGHT_DEFAULT_ON   // Uncomment to set default state to on
230
-//#define MENU_ITEM_CASE_LIGHT    // Uncomment to have a Case Light On / Off entry in main menu
229
+#if PIN_EXISTS(CASE_LIGHT)
230
+  #define INVERT_CASE_LIGHT false   // Set to true if HIGH is the OFF state (active low)
231
+  //#define CASE_LIGHT_DEFAULT_ON   // Uncomment to set default state to on
232
+  //#define MENU_ITEM_CASE_LIGHT    // Uncomment to have a Case Light On / Off entry in main menu
233
+#endif
231 234
 
232 235
 //===========================================================================
233 236
 //============================ Mechanical Settings ==========================

+ 5
- 2
Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h View File

@@ -226,8 +226,11 @@
226 226
 
227 227
 // Define a pin to turn case light on/off
228 228
 //#define CASE_LIGHT_PIN 4
229
-//#define CASE_LIGHT_DEFAULT_ON   // Uncomment to set default state to on
230
-//#define MENU_ITEM_CASE_LIGHT    // Uncomment to have a Case Light On / Off entry in main menu
229
+#if PIN_EXISTS(CASE_LIGHT)
230
+  #define INVERT_CASE_LIGHT false   // Set to true if HIGH is the OFF state (active low)
231
+  //#define CASE_LIGHT_DEFAULT_ON   // Uncomment to set default state to on
232
+  //#define MENU_ITEM_CASE_LIGHT    // Uncomment to have a Case Light On / Off entry in main menu
233
+#endif
231 234
 
232 235
 //===========================================================================
233 236
 //============================ Mechanical Settings ==========================

+ 5
- 2
Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h View File

@@ -231,8 +231,11 @@
231 231
 
232 232
 // Define a pin to turn case light on/off
233 233
 //#define CASE_LIGHT_PIN 4
234
-//#define CASE_LIGHT_DEFAULT_ON   // Uncomment to set default state to on
235
-//#define MENU_ITEM_CASE_LIGHT    // Uncomment to have a Case Light On / Off entry in main menu
234
+#if PIN_EXISTS(CASE_LIGHT)
235
+  #define INVERT_CASE_LIGHT false   // Set to true if HIGH is the OFF state (active low)
236
+  //#define CASE_LIGHT_DEFAULT_ON   // Uncomment to set default state to on
237
+  //#define MENU_ITEM_CASE_LIGHT    // Uncomment to have a Case Light On / Off entry in main menu
238
+#endif
236 239
 
237 240
 //===========================================================================
238 241
 //============================ Mechanical Settings ==========================

+ 5
- 2
Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h View File

@@ -226,8 +226,11 @@
226 226
 
227 227
 // Define a pin to turn case light on/off
228 228
 //#define CASE_LIGHT_PIN 4
229
-//#define CASE_LIGHT_DEFAULT_ON   // Uncomment to set default state to on
230
-//#define MENU_ITEM_CASE_LIGHT    // Uncomment to have a Case Light On / Off entry in main menu
229
+#if PIN_EXISTS(CASE_LIGHT)
230
+  #define INVERT_CASE_LIGHT false   // Set to true if HIGH is the OFF state (active low)
231
+  //#define CASE_LIGHT_DEFAULT_ON   // Uncomment to set default state to on
232
+  //#define MENU_ITEM_CASE_LIGHT    // Uncomment to have a Case Light On / Off entry in main menu
233
+#endif
231 234
 
232 235
 //===========================================================================
233 236
 //============================ Mechanical Settings ==========================

+ 5
- 2
Marlin/example_configurations/makibox/Configuration_adv.h View File

@@ -226,8 +226,11 @@
226 226
 
227 227
 // Define a pin to turn case light on/off
228 228
 //#define CASE_LIGHT_PIN 4
229
-//#define CASE_LIGHT_DEFAULT_ON   // Uncomment to set default state to on
230
-//#define MENU_ITEM_CASE_LIGHT    // Uncomment to have a Case Light On / Off entry in main menu
229
+#if PIN_EXISTS(CASE_LIGHT)
230
+  #define INVERT_CASE_LIGHT false   // Set to true if HIGH is the OFF state (active low)
231
+  //#define CASE_LIGHT_DEFAULT_ON   // Uncomment to set default state to on
232
+  //#define MENU_ITEM_CASE_LIGHT    // Uncomment to have a Case Light On / Off entry in main menu
233
+#endif
231 234
 
232 235
 //===========================================================================
233 236
 //============================ Mechanical Settings ==========================

+ 5
- 2
Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h View File

@@ -226,8 +226,11 @@
226 226
 
227 227
 // Define a pin to turn case light on/off
228 228
 //#define CASE_LIGHT_PIN 4
229
-//#define CASE_LIGHT_DEFAULT_ON   // Uncomment to set default state to on
230
-//#define MENU_ITEM_CASE_LIGHT    // Uncomment to have a Case Light On / Off entry in main menu
229
+#if PIN_EXISTS(CASE_LIGHT)
230
+  #define INVERT_CASE_LIGHT false   // Set to true if HIGH is the OFF state (active low)
231
+  //#define CASE_LIGHT_DEFAULT_ON   // Uncomment to set default state to on
232
+  //#define MENU_ITEM_CASE_LIGHT    // Uncomment to have a Case Light On / Off entry in main menu
233
+#endif
231 234
 
232 235
 //===========================================================================
233 236
 //============================ Mechanical Settings ==========================

+ 2
- 2
Marlin/ultralcd.cpp View File

@@ -581,7 +581,7 @@ void kill_screen(const char* lcd_msg) {
581 581
 
582 582
   #endif //SDSUPPORT
583 583
 
584
-  #if HAS_CASE_LIGHT && ENABLED(MENU_ITEM_CASE_LIGHT)
584
+  #if ENABLED(MENU_ITEM_CASE_LIGHT)
585 585
 
586 586
     extern bool case_light_on;
587 587
     extern void update_case_light();
@@ -607,7 +607,7 @@ void kill_screen(const char* lcd_msg) {
607 607
     //
608 608
     // Switch case light on/off
609 609
     //
610
-    #if HAS_CASE_LIGHT && ENABLED(MENU_ITEM_CASE_LIGHT)
610
+    #if ENABLED(MENU_ITEM_CASE_LIGHT)
611 611
       if (case_light_on)
612 612
         MENU_ITEM(function, MSG_LIGHTS_OFF, toggle_case_light);
613 613
       else

Loading…
Cancel
Save