diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 2538128d3..e66f9c9f7 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -226,8 +226,11 @@ // Define a pin to turn case light on/off //#define CASE_LIGHT_PIN 4 -//#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on -//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light On / Off entry in main menu +#if PIN_EXISTS(CASE_LIGHT) + #define INVERT_CASE_LIGHT false // Set to true if HIGH is the OFF state (active low) + //#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on + //#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light On / Off entry in main menu +#endif //=========================================================================== //============================ Mechanical Settings ========================== diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 4718b64e1..54615fd2e 100755 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -7328,8 +7328,8 @@ inline void gcode_M907() { uint8_t case_light_brightness = 255; void update_case_light() { - digitalWrite(CASE_LIGHT_PIN, case_light_on ? HIGH : LOW); - analogWrite(CASE_LIGHT_PIN, case_light_on ? case_light_brightness : 0); + digitalWrite(CASE_LIGHT_PIN, case_light_on != INVERT_CASE_LIGHT ? HIGH : LOW); + analogWrite(CASE_LIGHT_PIN, case_light_on != INVERT_CASE_LIGHT ? case_light_brightness : 0); } /** diff --git a/Marlin/example_configurations/Cartesio/Configuration_adv.h b/Marlin/example_configurations/Cartesio/Configuration_adv.h index b5b3546b8..680f49f58 100644 --- a/Marlin/example_configurations/Cartesio/Configuration_adv.h +++ b/Marlin/example_configurations/Cartesio/Configuration_adv.h @@ -226,8 +226,11 @@ // Define a pin to turn case light on/off //#define CASE_LIGHT_PIN 4 -//#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on -//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light On / Off entry in main menu +#if PIN_EXISTS(CASE_LIGHT) + #define INVERT_CASE_LIGHT false // Set to true if HIGH is the OFF state (active low) + //#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on + //#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light On / Off entry in main menu +#endif //=========================================================================== //============================ Mechanical Settings ========================== diff --git a/Marlin/example_configurations/Felix/Configuration_adv.h b/Marlin/example_configurations/Felix/Configuration_adv.h index 50ef6f223..2f848454f 100644 --- a/Marlin/example_configurations/Felix/Configuration_adv.h +++ b/Marlin/example_configurations/Felix/Configuration_adv.h @@ -226,8 +226,11 @@ // Define a pin to turn case light on/off //#define CASE_LIGHT_PIN 4 -//#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on -//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light On / Off entry in main menu +#if PIN_EXISTS(CASE_LIGHT) + #define INVERT_CASE_LIGHT false // Set to true if HIGH is the OFF state (active low) + //#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on + //#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light On / Off entry in main menu +#endif //=========================================================================== //============================ Mechanical Settings ========================== diff --git a/Marlin/example_configurations/Hephestos/Configuration_adv.h b/Marlin/example_configurations/Hephestos/Configuration_adv.h index 7ba3a61b9..5294766e6 100644 --- a/Marlin/example_configurations/Hephestos/Configuration_adv.h +++ b/Marlin/example_configurations/Hephestos/Configuration_adv.h @@ -226,8 +226,11 @@ // Define a pin to turn case light on/off //#define CASE_LIGHT_PIN 4 -//#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on -//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light On / Off entry in main menu +#if PIN_EXISTS(CASE_LIGHT) + #define INVERT_CASE_LIGHT false // Set to true if HIGH is the OFF state (active low) + //#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on + //#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light On / Off entry in main menu +#endif //=========================================================================== //============================ Mechanical Settings ========================== diff --git a/Marlin/example_configurations/Hephestos_2/Configuration_adv.h b/Marlin/example_configurations/Hephestos_2/Configuration_adv.h index fa22b59a8..d48952e1a 100644 --- a/Marlin/example_configurations/Hephestos_2/Configuration_adv.h +++ b/Marlin/example_configurations/Hephestos_2/Configuration_adv.h @@ -226,8 +226,11 @@ // Define a pin to turn case light on/off //#define CASE_LIGHT_PIN 4 -//#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on -//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light On / Off entry in main menu +#if PIN_EXISTS(CASE_LIGHT) + #define INVERT_CASE_LIGHT false // Set to true if HIGH is the OFF state (active low) + //#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on + //#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light On / Off entry in main menu +#endif //=========================================================================== //============================ Mechanical Settings ========================== diff --git a/Marlin/example_configurations/K8200/Configuration_adv.h b/Marlin/example_configurations/K8200/Configuration_adv.h index 679cb6d07..b6acbff10 100644 --- a/Marlin/example_configurations/K8200/Configuration_adv.h +++ b/Marlin/example_configurations/K8200/Configuration_adv.h @@ -239,8 +239,11 @@ // Define a pin to turn case light on/off //#define CASE_LIGHT_PIN 4 -//#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on -//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light On / Off entry in main menu +#if PIN_EXISTS(CASE_LIGHT) + #define INVERT_CASE_LIGHT false // Set to true if HIGH is the OFF state (active low) + //#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on + //#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light On / Off entry in main menu +#endif //=========================================================================== //============================ Mechanical Settings ========================== diff --git a/Marlin/example_configurations/K8400/Configuration_adv.h b/Marlin/example_configurations/K8400/Configuration_adv.h index 4cf838e85..0df0c0d7d 100644 --- a/Marlin/example_configurations/K8400/Configuration_adv.h +++ b/Marlin/example_configurations/K8400/Configuration_adv.h @@ -226,8 +226,11 @@ // Define a pin to turn case light on/off //#define CASE_LIGHT_PIN 4 -//#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on -//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light On / Off entry in main menu +#if PIN_EXISTS(CASE_LIGHT) + #define INVERT_CASE_LIGHT false // Set to true if HIGH is the OFF state (active low) + //#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on + //#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light On / Off entry in main menu +#endif //=========================================================================== //============================ Mechanical Settings ========================== diff --git a/Marlin/example_configurations/RigidBot/Configuration_adv.h b/Marlin/example_configurations/RigidBot/Configuration_adv.h index 18f96aabc..45671c143 100644 --- a/Marlin/example_configurations/RigidBot/Configuration_adv.h +++ b/Marlin/example_configurations/RigidBot/Configuration_adv.h @@ -226,8 +226,11 @@ // Define a pin to turn case light on/off //#define CASE_LIGHT_PIN 4 -//#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on -//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light On / Off entry in main menu +#if PIN_EXISTS(CASE_LIGHT) + #define INVERT_CASE_LIGHT false // Set to true if HIGH is the OFF state (active low) + //#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on + //#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light On / Off entry in main menu +#endif //=========================================================================== //============================ Mechanical Settings ========================== diff --git a/Marlin/example_configurations/SCARA/Configuration_adv.h b/Marlin/example_configurations/SCARA/Configuration_adv.h index 4b9ecba4d..5f4e0e2cf 100644 --- a/Marlin/example_configurations/SCARA/Configuration_adv.h +++ b/Marlin/example_configurations/SCARA/Configuration_adv.h @@ -226,8 +226,11 @@ // Define a pin to turn case light on/off //#define CASE_LIGHT_PIN 4 -//#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on -//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light On / Off entry in main menu +#if PIN_EXISTS(CASE_LIGHT) + #define INVERT_CASE_LIGHT false // Set to true if HIGH is the OFF state (active low) + //#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on + //#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light On / Off entry in main menu +#endif //=========================================================================== //============================ Mechanical Settings ========================== diff --git a/Marlin/example_configurations/TAZ4/Configuration_adv.h b/Marlin/example_configurations/TAZ4/Configuration_adv.h index 706ab81a5..7e6061864 100644 --- a/Marlin/example_configurations/TAZ4/Configuration_adv.h +++ b/Marlin/example_configurations/TAZ4/Configuration_adv.h @@ -234,8 +234,11 @@ // Define a pin to turn case light on/off //#define CASE_LIGHT_PIN 4 -//#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on -//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light On / Off entry in main menu +#if PIN_EXISTS(CASE_LIGHT) + #define INVERT_CASE_LIGHT false // Set to true if HIGH is the OFF state (active low) + //#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on + //#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light On / Off entry in main menu +#endif //=========================================================================== //============================ Mechanical Settings ========================== diff --git a/Marlin/example_configurations/WITBOX/Configuration_adv.h b/Marlin/example_configurations/WITBOX/Configuration_adv.h index 7ba3a61b9..5294766e6 100644 --- a/Marlin/example_configurations/WITBOX/Configuration_adv.h +++ b/Marlin/example_configurations/WITBOX/Configuration_adv.h @@ -226,8 +226,11 @@ // Define a pin to turn case light on/off //#define CASE_LIGHT_PIN 4 -//#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on -//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light On / Off entry in main menu +#if PIN_EXISTS(CASE_LIGHT) + #define INVERT_CASE_LIGHT false // Set to true if HIGH is the OFF state (active low) + //#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on + //#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light On / Off entry in main menu +#endif //=========================================================================== //============================ Mechanical Settings ========================== diff --git a/Marlin/example_configurations/delta/biv2.5/Configuration_adv.h b/Marlin/example_configurations/delta/biv2.5/Configuration_adv.h index b3468cba5..cabcff9cf 100644 --- a/Marlin/example_configurations/delta/biv2.5/Configuration_adv.h +++ b/Marlin/example_configurations/delta/biv2.5/Configuration_adv.h @@ -226,8 +226,11 @@ // Define a pin to turn case light on/off //#define CASE_LIGHT_PIN 4 -//#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on -//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light On / Off entry in main menu +#if PIN_EXISTS(CASE_LIGHT) + #define INVERT_CASE_LIGHT false // Set to true if HIGH is the OFF state (active low) + //#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on + //#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light On / Off entry in main menu +#endif //=========================================================================== //============================ Mechanical Settings ========================== diff --git a/Marlin/example_configurations/delta/generic/Configuration_adv.h b/Marlin/example_configurations/delta/generic/Configuration_adv.h index 7587b1c23..591e89832 100644 --- a/Marlin/example_configurations/delta/generic/Configuration_adv.h +++ b/Marlin/example_configurations/delta/generic/Configuration_adv.h @@ -226,8 +226,11 @@ // Define a pin to turn case light on/off //#define CASE_LIGHT_PIN 4 -//#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on -//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light On / Off entry in main menu +#if PIN_EXISTS(CASE_LIGHT) + #define INVERT_CASE_LIGHT false // Set to true if HIGH is the OFF state (active low) + //#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on + //#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light On / Off entry in main menu +#endif //=========================================================================== //============================ Mechanical Settings ========================== diff --git a/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h b/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h index 7587b1c23..591e89832 100644 --- a/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h +++ b/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h @@ -226,8 +226,11 @@ // Define a pin to turn case light on/off //#define CASE_LIGHT_PIN 4 -//#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on -//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light On / Off entry in main menu +#if PIN_EXISTS(CASE_LIGHT) + #define INVERT_CASE_LIGHT false // Set to true if HIGH is the OFF state (active low) + //#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on + //#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light On / Off entry in main menu +#endif //=========================================================================== //============================ Mechanical Settings ========================== diff --git a/Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h b/Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h index b1cdfe840..0a3becc21 100644 --- a/Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h +++ b/Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h @@ -231,8 +231,11 @@ // Define a pin to turn case light on/off //#define CASE_LIGHT_PIN 4 -//#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on -//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light On / Off entry in main menu +#if PIN_EXISTS(CASE_LIGHT) + #define INVERT_CASE_LIGHT false // Set to true if HIGH is the OFF state (active low) + //#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on + //#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light On / Off entry in main menu +#endif //=========================================================================== //============================ Mechanical Settings ========================== diff --git a/Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h b/Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h index fa838047c..318fe6ecc 100644 --- a/Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h +++ b/Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h @@ -226,8 +226,11 @@ // Define a pin to turn case light on/off //#define CASE_LIGHT_PIN 4 -//#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on -//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light On / Off entry in main menu +#if PIN_EXISTS(CASE_LIGHT) + #define INVERT_CASE_LIGHT false // Set to true if HIGH is the OFF state (active low) + //#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on + //#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light On / Off entry in main menu +#endif //=========================================================================== //============================ Mechanical Settings ========================== diff --git a/Marlin/example_configurations/makibox/Configuration_adv.h b/Marlin/example_configurations/makibox/Configuration_adv.h index 3c65ea02e..749d842bd 100644 --- a/Marlin/example_configurations/makibox/Configuration_adv.h +++ b/Marlin/example_configurations/makibox/Configuration_adv.h @@ -226,8 +226,11 @@ // Define a pin to turn case light on/off //#define CASE_LIGHT_PIN 4 -//#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on -//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light On / Off entry in main menu +#if PIN_EXISTS(CASE_LIGHT) + #define INVERT_CASE_LIGHT false // Set to true if HIGH is the OFF state (active low) + //#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on + //#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light On / Off entry in main menu +#endif //=========================================================================== //============================ Mechanical Settings ========================== diff --git a/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h b/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h index 9d5cd456a..0097c6db2 100644 --- a/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h +++ b/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h @@ -226,8 +226,11 @@ // Define a pin to turn case light on/off //#define CASE_LIGHT_PIN 4 -//#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on -//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light On / Off entry in main menu +#if PIN_EXISTS(CASE_LIGHT) + #define INVERT_CASE_LIGHT false // Set to true if HIGH is the OFF state (active low) + //#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on + //#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light On / Off entry in main menu +#endif //=========================================================================== //============================ Mechanical Settings ========================== diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index dc7974145..a7104d4c1 100755 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -581,7 +581,7 @@ void kill_screen(const char* lcd_msg) { #endif //SDSUPPORT - #if HAS_CASE_LIGHT && ENABLED(MENU_ITEM_CASE_LIGHT) + #if ENABLED(MENU_ITEM_CASE_LIGHT) extern bool case_light_on; extern void update_case_light(); @@ -607,7 +607,7 @@ void kill_screen(const char* lcd_msg) { // // Switch case light on/off // - #if HAS_CASE_LIGHT && ENABLED(MENU_ITEM_CASE_LIGHT) + #if ENABLED(MENU_ITEM_CASE_LIGHT) if (case_light_on) MENU_ITEM(function, MSG_LIGHTS_OFF, toggle_case_light); else