From 3e9504d306653b3819ae0a35ab010fe3ee4c1f69 Mon Sep 17 00:00:00 2001 From: jmdearras Date: Wed, 1 Nov 2017 22:17:23 -0400 Subject: [PATCH] Fix case light "off" function (#8205) * Fix case light "off" function It would only turn the light off if brightness was 255 * Update Marlin_main.cpp --- Marlin/Marlin_main.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index c4bb3b38a..5d2afb45c 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -10468,12 +10468,17 @@ inline void gcode_M907() { void update_case_light() { pinMode(CASE_LIGHT_PIN, OUTPUT); // digitalWrite doesn't set the port mode if (case_light_on) { - if (USEABLE_HARDWARE_PWM(CASE_LIGHT_PIN)) { + if (USEABLE_HARDWARE_PWM(CASE_LIGHT_PIN)) analogWrite(CASE_LIGHT_PIN, INVERT_CASE_LIGHT ? 255 - case_light_brightness : case_light_brightness); - } - else WRITE(CASE_LIGHT_PIN, INVERT_CASE_LIGHT ? LOW : HIGH); + else + WRITE(CASE_LIGHT_PIN, INVERT_CASE_LIGHT ? LOW : HIGH); + } + else { + if (USEABLE_HARDWARE_PWM(CASE_LIGHT_PIN)) + analogWrite(CASE_LIGHT_PIN, INVERT_CASE_LIGHT ? 255 : 0); + else + WRITE(CASE_LIGHT_PIN, INVERT_CASE_LIGHT ? HIGH : LOW); } - else WRITE(CASE_LIGHT_PIN, INVERT_CASE_LIGHT ? HIGH : LOW); } #endif // HAS_CASE_LIGHT