From 5c49efcd7960cd88e01ff6f0f5cc11623d6a29b7 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Tue, 7 Jan 2020 17:59:42 +0100 Subject: [PATCH] LEDControl: Expose brightness settings via Focus When using the `FocusLEDCommand` plugin, expose brightness control too. Signed-off-by: Gergely Nagy --- src/kaleidoscope/plugin/LEDControl.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/kaleidoscope/plugin/LEDControl.cpp b/src/kaleidoscope/plugin/LEDControl.cpp index dbc10cb9..445d3ec6 100644 --- a/src/kaleidoscope/plugin/LEDControl.cpp +++ b/src/kaleidoscope/plugin/LEDControl.cpp @@ -189,6 +189,7 @@ EventHandlerResult FocusLEDCommand::onFocusEvent(const char *command) { MODE, AT, THEME, + BRIGHTNESS, } subCommand; if (!Runtime.has_leds) @@ -197,6 +198,7 @@ EventHandlerResult FocusLEDCommand::onFocusEvent(const char *command) { if (::Focus.handleHelp(command, PSTR("led.at\n" "led.setAll\n" "led.mode\n" + "led.brightness\n" "led.theme"))) return EventHandlerResult::OK; @@ -210,6 +212,8 @@ EventHandlerResult FocusLEDCommand::onFocusEvent(const char *command) { subCommand = MODE; else if (strcmp_P(command + 4, PSTR("theme")) == 0) subCommand = THEME; + else if (strcmp_P(command + 4, PSTR("brightness")) == 0) + subCommand = BRIGHTNESS; else return EventHandlerResult::OK; @@ -232,6 +236,16 @@ EventHandlerResult FocusLEDCommand::onFocusEvent(const char *command) { } break; } + case BRIGHTNESS: { + if (::Focus.isEOL()) { + ::Focus.send(::LEDControl.getBrightness()); + } else { + uint8_t brightness; + + ::Focus.read(brightness); + ::LEDControl.setBrightness(brightness); + } + } case SETALL: { cRGB c;