|
@ -868,11 +868,20 @@ void setup_homepin(void) { |
|
|
#if HAS_CASE_LIGHT |
|
|
#if HAS_CASE_LIGHT |
|
|
|
|
|
|
|
|
void setup_case_light() { |
|
|
void setup_case_light() { |
|
|
#if ENABLED(CASE_LIGHT_DEFAULT_ON) |
|
|
digitalWrite(CASE_LIGHT_PIN, |
|
|
OUT_WRITE(CASE_LIGHT_PIN, HIGH); |
|
|
#if ENABLED(CASE_LIGHT_DEFAULT_ON) |
|
|
#else |
|
|
255 |
|
|
OUT_WRITE(CASE_LIGHT_PIN, LOW); |
|
|
#else |
|
|
#endif |
|
|
0 |
|
|
|
|
|
#endif |
|
|
|
|
|
); |
|
|
|
|
|
analogWrite(CASE_LIGHT_PIN, |
|
|
|
|
|
#if ENABLED(CASE_LIGHT_DEFAULT_ON) |
|
|
|
|
|
255 |
|
|
|
|
|
#else |
|
|
|
|
|
0 |
|
|
|
|
|
#endif |
|
|
|
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
#endif |
|
|
#endif |
|
@ -7183,33 +7192,30 @@ inline void gcode_M907() { |
|
|
#endif // HAS_MICROSTEPS
|
|
|
#endif // HAS_MICROSTEPS
|
|
|
|
|
|
|
|
|
#if HAS_CASE_LIGHT |
|
|
#if HAS_CASE_LIGHT |
|
|
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* M355: Turn case lights on/off |
|
|
* M355: Turn case lights on/off and set brightness |
|
|
* |
|
|
|
|
|
* S<int> change state on/off or sets PWM |
|
|
|
|
|
* |
|
|
* |
|
|
|
|
|
* S<bool> Turn case light on or off |
|
|
|
|
|
* P<byte> Set case light brightness (PWM pin required) |
|
|
*/ |
|
|
*/ |
|
|
inline void gcode_M355() { |
|
|
inline void gcode_M355() { |
|
|
|
|
|
static bool case_light_on |
|
|
|
|
|
#if ENABLED(CASE_LIGHT_DEFAULT_ON) |
|
|
|
|
|
= true |
|
|
|
|
|
#else |
|
|
|
|
|
; |
|
|
|
|
|
#endif |
|
|
|
|
|
static uint8_t case_light_brightness = 255; |
|
|
|
|
|
if (code_seen('P')) case_light_brightness = code_value_byte(); |
|
|
if (code_seen('S')) { |
|
|
if (code_seen('S')) { |
|
|
SERIAL_ECHO_START; |
|
|
case_light_on = code_value_bool(); |
|
|
SERIAL_ECHOPGM("Case lights "); |
|
|
digitalWrite(CASE_LIGHT_PIN, case_light_on ? HIGH : LOW); |
|
|
byte light_pwm = code_value_byte(); |
|
|
analogWrite(CASE_LIGHT_PIN, case_light_on ? case_light_brightness : 0); |
|
|
switch (light_pwm) { |
|
|
|
|
|
case 0: // Disable lights
|
|
|
|
|
|
SERIAL_ECHOPGM("off"); |
|
|
|
|
|
break; |
|
|
|
|
|
case 1: // Enable lights
|
|
|
|
|
|
light_pwm = 255; |
|
|
|
|
|
SERIAL_ECHOPGM("on"); |
|
|
|
|
|
break; |
|
|
|
|
|
default: // Enable lights PWM
|
|
|
|
|
|
SERIAL_ECHOPAIR("set to: ", (int)map(light_pwm, 0, 255, 0, 100)); |
|
|
|
|
|
SERIAL_CHAR('%'); |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
analogWrite(CASE_LIGHT_PIN, light_pwm); |
|
|
|
|
|
SERIAL_EOL; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
SERIAL_ECHO_START; |
|
|
|
|
|
SERIAL_ECHOPGM("Case lights "); |
|
|
|
|
|
case_light_on ? SERIAL_ECHOLNPGM("on") : SERIAL_ECHOLNPGM("off"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
#endif // HAS_CASE_LIGHT
|
|
|
#endif // HAS_CASE_LIGHT
|
|
|