Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed long-deprecated FocusLEDCommand functionality #1380

Merged
merged 1 commit into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -1073,6 +1073,12 @@ The following headers and names have changed:

# Removed APIs

### Removed on 2023-11-13

#### FocusLEDCommand

The brightness functionality of this API lives on in the LEDBrightnessConfig plugin.

### Removed on 2022-03-03

#### Pre-`KeyEvent` event handler hooks
Expand Down
121 changes: 0 additions & 121 deletions src/kaleidoscope/plugin/LEDControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,129 +212,8 @@ EventHandlerResult LEDControl::afterEachCycle() {
return EventHandlerResult::OK;
}

EventHandlerResult FocusLEDCommand::onFocusEvent(const char *input) {
enum {
SETALL,
MODE,
AT,
THEME,
BRIGHTNESS,
} subCommand;

if (!Runtime.has_leds)
return EventHandlerResult::OK;

const char *cmd_at = PSTR("led.at");
const char *cmd_setAll = PSTR("led.setAll");
const char *cmd_mode = PSTR("led.mode");
const char *cmd_brightness = PSTR("led.brightness");
const char *cmd_theme = PSTR("led.theme");

if (::Focus.inputMatchesHelp(input))
return ::Focus.printHelp(cmd_at,
cmd_setAll,
cmd_mode,
cmd_brightness,
cmd_theme);

if (::Focus.inputMatchesCommand(input, cmd_at))
subCommand = AT;
else if (::Focus.inputMatchesCommand(input, cmd_setAll))
subCommand = SETALL;
else if (::Focus.inputMatchesCommand(input, cmd_mode))
subCommand = MODE;
else if (::Focus.inputMatchesCommand(input, cmd_theme))
subCommand = THEME;
else if (::Focus.inputMatchesCommand(input, cmd_brightness))
subCommand = BRIGHTNESS;
else
return EventHandlerResult::OK;

switch (subCommand) {
case AT: {
uint8_t idx;

::Focus.read(idx);

if (::Focus.isEOL()) {
cRGB c = ::LEDControl.getCrgbAt(idx);

::Focus.send(c);
} else {
cRGB c;

::Focus.read(c);

::LEDControl.setCrgbAt(idx, c);
}
break;
}
case BRIGHTNESS: {
if (::Focus.isEOL()) {
::Focus.send(::LEDControl.getBrightness());
} else {
uint8_t brightness;

::Focus.read(brightness);
::LEDControl.setBrightness(brightness);
}
break;
}
case SETALL: {
cRGB c;

::Focus.read(c);

::LEDControl.set_all_leds_to(c);

break;
}
case MODE: {
char peek = ::Focus.peek();
if (peek == '\n') {
::Focus.send(::LEDControl.get_mode_index());
} else if (peek == 'n') {
::LEDControl.next_mode();
} else if (peek == 'p') {
::LEDControl.prev_mode();
} else {
uint8_t mode_id_;

::Focus.read(mode_id_);
::LEDControl.set_mode(mode_id_);
}
break;
}
case THEME: {
if (::Focus.isEOL()) {
for (auto led_index : Runtime.device().LEDs().all()) {
cRGB c = ::LEDControl.getCrgbAt(led_index.offset());

::Focus.send(c);
}
break;
}

for (auto led_index : Runtime.device().LEDs().all()) {
if (::Focus.isEOL()) {
break;
}

cRGB color;

::Focus.read(color);

::LEDControl.setCrgbAt(led_index.offset(), color);
}
break;
}
}

return EventHandlerResult::EVENT_CONSUMED;
}

} // namespace plugin
} // namespace kaleidoscope

kaleidoscope::plugin::LEDControl LEDControl;
kaleidoscope::plugin::FocusLEDCommand FocusLEDCommand;
18 changes: 0 additions & 18 deletions src/kaleidoscope/plugin/LEDControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,6 @@
#include "kaleidoscope/plugin.h" // for Plugin
#include "kaleidoscope/plugin/LEDMode.h" // for LEDMode
#include "kaleidoscope/plugin/LEDModeInterface.h" // for LEDModeInterface
// -----------------------------------------------------------------------------
// Deprecation warning messages
#include "kaleidoscope_internal/deprecations.h" // for DEPRECATED

#define _DEPRECATED_MESSAGE_FOCUSLEDCOMMAND \
"The `FocusLEDCommand` plugin is deprecated. For its most useful\n" \
"functionality - led.brightness -, please see the `LEDBrightnessConfig`\n" \
"plugin.\n" \
"This plugin will be removed after 2023-01-01."
// -----------------------------------------------------------------------------

constexpr uint8_t LED_TOGGLE = 0b00000001; // Synthetic, internal

Expand Down Expand Up @@ -138,17 +128,9 @@ class LEDControl : public kaleidoscope::Plugin {
static bool enabled_;
};

DEPRECATED(FOCUSLEDCOMMAND)
class FocusLEDCommand : public Plugin {
public:
FocusLEDCommand() {}

EventHandlerResult onFocusEvent(const char *input);
};

} // namespace plugin

} // namespace kaleidoscope

extern kaleidoscope::plugin::LEDControl LEDControl;
extern kaleidoscope::plugin::FocusLEDCommand FocusLEDCommand;
Loading