@ -24,7 +24,7 @@ full extent, we need to create our own plugin on top of it.
#include < Kaleidoscope.h >
#include < Kaleidoscope.h >
#include < Kaleidoscope-EEPROM-Settings.h >
#include < Kaleidoscope-EEPROM-Settings.h >
#include < Kaleidoscope-LED-Palette-Theme.h >
#include < Kaleidoscope-LED-Palette-Theme.h >
#include < Kaleidoscope-Focus .h>
#include < Kaleidoscope-Focus Serial .h>
namespace example {
namespace example {
@ -36,7 +36,7 @@ class TestLEDMode : public LEDMode {
void setup(void) final;
void setup(void) final;
void update(void) final;
void update(void) final;
static bool focusHook (const char *command);
kaleidoscope::EventHandlerResult onFocusEvent (const char *command);
private:
private:
static uint16_t map_base_;
static uint16_t map_base_;
@ -52,27 +52,26 @@ void TestLEDMode::update(void) {
LEDPaletteTheme.updateHandler(map_base_, 0);
LEDPaletteTheme.updateHandler(map_base_, 0);
}
}
bool
kaleidoscope::EventHandlerResult
TestLEDMode::focusHook (const char *command) {
TestLEDMode::onFocusEvent (const char *command) {
return LEDPaletteTheme.themeFocusHandler (command, PSTR("testLedMode.map"), map_base_, 1);
return LEDPaletteTheme.themeFocusEvent (command, PSTR("testLedMode.map"), map_base_, 1);
}
}
}
}
example::TestLEDMode TestLEDMode;
example::TestLEDMode TestLEDMode;
void setup() {
KALEIDOSCOPE_INIT_PLUGINS(
Serial.begin(9600);
Focus,
LEDPaletteTheme,
Kaleidoscope.use(& Focus, & LEDPaletteTheme, & TestLEDMode, &EEPROMSettings);
TestLEDMode,
EEPROMSettings
);
void setup() {
Kaleidoscope.setup();
Kaleidoscope.setup();
EEPROMSettings.seal();
TestLEDMode.activate();
TestLEDMode.activate();
Focus.addHook(FOCUS_HOOK_LEDPALETTETHEME);
Focus.addHook(FOCUS_HOOK(TestLEDMode.focusHook, "testLEDMode.map"));
}
}
```
```
@ -100,7 +99,7 @@ The plugin provides the `LEDPaletteTheme` object, which has the following method
> The `theme` argument can be any index between zero and `max_themes` . How the
> The `theme` argument can be any index between zero and `max_themes` . How the
> plugin decides which theme to display depends entirely on the plugin.
> plugin decides which theme to display depends entirely on the plugin.
### `.themeFocus Handler (command, expected_command, theme_base, max_themes)`
### `.themeFocus Event (command, expected_command, theme_base, max_themes)`
> To be used in a custom `Focus` handler: handles the `expected_command` Focus
> To be used in a custom `Focus` handler: handles the `expected_command` Focus
> command, and provides a way to query and update the themes supported by the
> command, and provides a way to query and update the themes supported by the
@ -109,14 +108,11 @@ The plugin provides the `LEDPaletteTheme` object, which has the following method
> When queried, it will list the color indexes. When used as a setter, it
> When queried, it will list the color indexes. When used as a setter, it
> expects one index per key.
> expects one index per key.
>
>
> The palette can be set via the `palette` focus command, implement ed by the
> The palette can be set via the `palette` focus command, provid ed by the
> ` FOCUS_HOOK_LEDPALETTETHEME` hook explained below .
> ` LEDPaletteTheme` plugin .
## Focus commands
## Focus commands
The plugin provides a single `Focus` hook, `FOCUS_HOOK_LEDPALETTETHEME` ,
implementing the following command:
### `palette`
### `palette`
> Without arguments, prints the palette: RGB values for all 16 colors.
> Without arguments, prints the palette: RGB values for all 16 colors.
@ -130,7 +126,7 @@ implementing the following command:
## Dependencies
## Dependencies
* [Kaleidoscope-EEPROM-Settings ](https://github.com/keyboardio/Kaleidoscope-EEPROM-Settings )
* [Kaleidoscope-EEPROM-Settings ](https://github.com/keyboardio/Kaleidoscope-EEPROM-Settings )
* [Kaleidoscope-Focus ](https://github.com/keyboardio/Kaleidoscope-Focus )
* [Kaleidoscope-Focus Serial ](https://github.com/keyboardio/Kaleidoscope-Focus Serial )
* [Kaleidoscope-LEDControl ](https://github.com/keyboardio/Kaleidoscope-LEDControl )
* [Kaleidoscope-LEDControl ](https://github.com/keyboardio/Kaleidoscope-LEDControl )
## Further reading
## Further reading