From f60b4f8659ce32652fc805a5ea8109fdc493963d Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 1 Dec 2016 23:31:03 -0600 Subject: [PATCH] Allow case light pin to be active low --- Marlin/Configuration_adv.h | 7 +++++-- Marlin/Marlin_main.cpp | 4 ++-- Marlin/example_configurations/Cartesio/Configuration_adv.h | 7 +++++-- Marlin/example_configurations/Felix/Configuration_adv.h | 7 +++++-- .../example_configurations/Hephestos/Configuration_adv.h | 7 +++++-- .../example_configurations/Hephestos_2/Configuration_adv.h | 7 +++++-- Marlin/example_configurations/K8200/Configuration_adv.h | 7 +++++-- Marlin/example_configurations/K8400/Configuration_adv.h | 7 +++++-- Marlin/example_configurations/RigidBot/Configuration_adv.h | 7 +++++-- Marlin/example_configurations/SCARA/Configuration_adv.h | 7 +++++-- Marlin/example_configurations/TAZ4/Configuration_adv.h | 7 +++++-- Marlin/example_configurations/WITBOX/Configuration_adv.h | 7 +++++-- .../delta/biv2.5/Configuration_adv.h | 7 +++++-- .../delta/generic/Configuration_adv.h | 7 +++++-- .../delta/kossel_mini/Configuration_adv.h | 7 +++++-- .../delta/kossel_pro/Configuration_adv.h | 7 +++++-- .../delta/kossel_xl/Configuration_adv.h | 7 +++++-- Marlin/example_configurations/makibox/Configuration_adv.h | 7 +++++-- .../tvrrug/Round2/Configuration_adv.h | 7 +++++-- Marlin/ultralcd.cpp | 4 ++-- 20 files changed, 94 insertions(+), 40 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 2538128d3b..e66f9c9f7b 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 4718b64e16..54615fd2ea 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 b5b3546b86..680f49f580 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 50ef6f2231..2f848454f7 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 7ba3a61b9e..5294766e62 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 fa22b59a87..d48952e1a9 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 679cb6d07a..b6acbff103 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 4cf838e85e..0df0c0d7d3 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 18f96aabca..45671c1431 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 4b9ecba4d0..5f4e0e2cf3 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 706ab81a58..7e60618641 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 7ba3a61b9e..5294766e62 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 b3468cba5a..cabcff9cfe 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 7587b1c233..591e898320 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 7587b1c233..591e898320 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 b1cdfe8406..0a3becc21f 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 fa838047c8..318fe6eccc 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 3c65ea02ea..749d842bd7 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 9d5cd456a7..0097c6db25 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 8cb790ce98..a9c96707f4 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