LEDControl: Expose brightness settings via Focus

When using the `FocusLEDCommand` plugin, expose brightness control too.

Signed-off-by: Gergely Nagy <algernon@keyboard.io>
pull/792/head
Gergely Nagy 5 years ago
parent 947851150d
commit 5c49efcd79
No known key found for this signature in database
GPG Key ID: AC1E90BAC433F68F

@ -189,6 +189,7 @@ EventHandlerResult FocusLEDCommand::onFocusEvent(const char *command) {
MODE, MODE,
AT, AT,
THEME, THEME,
BRIGHTNESS,
} subCommand; } subCommand;
if (!Runtime.has_leds) if (!Runtime.has_leds)
@ -197,6 +198,7 @@ EventHandlerResult FocusLEDCommand::onFocusEvent(const char *command) {
if (::Focus.handleHelp(command, PSTR("led.at\n" if (::Focus.handleHelp(command, PSTR("led.at\n"
"led.setAll\n" "led.setAll\n"
"led.mode\n" "led.mode\n"
"led.brightness\n"
"led.theme"))) "led.theme")))
return EventHandlerResult::OK; return EventHandlerResult::OK;
@ -210,6 +212,8 @@ EventHandlerResult FocusLEDCommand::onFocusEvent(const char *command) {
subCommand = MODE; subCommand = MODE;
else if (strcmp_P(command + 4, PSTR("theme")) == 0) else if (strcmp_P(command + 4, PSTR("theme")) == 0)
subCommand = THEME; subCommand = THEME;
else if (strcmp_P(command + 4, PSTR("brightness")) == 0)
subCommand = BRIGHTNESS;
else else
return EventHandlerResult::OK; return EventHandlerResult::OK;
@ -232,6 +236,16 @@ EventHandlerResult FocusLEDCommand::onFocusEvent(const char *command) {
} }
break; break;
} }
case BRIGHTNESS: {
if (::Focus.isEOL()) {
::Focus.send(::LEDControl.getBrightness());
} else {
uint8_t brightness;
::Focus.read(brightness);
::LEDControl.setBrightness(brightness);
}
}
case SETALL: { case SETALL: {
cRGB c; cRGB c;

Loading…
Cancel
Save