Case light brightness cleanup (#19856)

Co-authored-by: Chris <chris@chrisnovoa.com>
This commit is contained in:
Scott Lahteine
2020-10-22 22:31:48 -05:00
committed by GitHub
parent c75e98dc84
commit 0ffee29a11
7 changed files with 56 additions and 33 deletions

View File

@ -41,10 +41,12 @@
*/
void GcodeSuite::M355() {
bool didset = false;
if (parser.seenval('P')) {
didset = true;
caselight.brightness = parser.value_byte();
}
#if CASELIGHT_USES_BRIGHTNESS
if (parser.seenval('P')) {
didset = true;
caselight.brightness = parser.value_byte();
}
#endif
const bool sflag = parser.seenval('S');
if (sflag) {
didset = true;
@ -58,8 +60,13 @@ void GcodeSuite::M355() {
if (!caselight.on)
SERIAL_ECHOLNPGM(STR_OFF);
else {
if (!PWM_PIN(CASE_LIGHT_PIN)) SERIAL_ECHOLNPGM(STR_ON);
else SERIAL_ECHOLN(int(caselight.brightness));
#if CASELIGHT_USES_BRIGHTNESS
if (PWM_PIN(CASE_LIGHT_PIN)) {
SERIAL_ECHOLN(int(caselight.brightness));
return;
}
#endif
SERIAL_ECHOLNPGM(STR_ON);
}
}

View File

@ -27,6 +27,10 @@
#include "../../module/motion.h"
#endif
#if ENABLED(CASE_LIGHT_ENABLE)
#include "../../feature/caselight.h"
#endif
#if ENABLED(EXTENDED_CAPABILITIES_REPORT)
static void cap_line(PGM_P const name, bool ena=false) {
SERIAL_ECHOPGM("Cap:");
@ -102,7 +106,7 @@ void GcodeSuite::M115() {
// TOGGLE_LIGHTS (M355)
cap_line(PSTR("TOGGLE_LIGHTS"), ENABLED(CASE_LIGHT_ENABLE));
cap_line(PSTR("CASE_LIGHT_BRIGHTNESS"), TERN0(CASE_LIGHT_ENABLE, PWM_PIN(CASE_LIGHT_PIN)));
cap_line(PSTR("CASE_LIGHT_BRIGHTNESS"), TERN0(CASE_LIGHT_ENABLE, TERN0(CASELIGHT_USES_BRIGHTNESS, TERN(CASE_LIGHT_USE_NEOPIXEL, true, PWM_PIN(CASE_LIGHT_PIN)))));
// EMERGENCY_PARSER (M108, M112, M410, M876)
cap_line(PSTR("EMERGENCY_PARSER"), ENABLED(EMERGENCY_PARSER));