You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Kaleidoscope/plugins/Kaleidoscope-DefaultLEDMode...
Gergely Nagy db7b0af730
DefaultLEDModeConfig: Fix a typo in the documentation
2 years ago
..
src New plugin: DefaultLEDModeConfig 3 years ago
README.md DefaultLEDModeConfig: Fix a typo in the documentation 2 years ago
library.properties New plugin: DefaultLEDModeConfig 3 years ago

README.md

DefaultLEDModeConfig

The DefaultLEDModeConfig plugin provides a way to set a default LED mode, the LED mode the device starts up with active, via Focus.

By default the first LED mode enabled will be the active one, unless set otherwise in setup(). To make this configurable, without having to reorder the LED modes, this plugin provides the necessary tools to accomplish that.

Using the plugin

The example below shows how to use the plugin, including setting up a LED mode other than the first to use as a default in case EEPROM is uninitialized.

#include <Kaleidoscope.h>
#include <Kaleidoscope-EEPROM-Settings.h>
#include <Kaleidoscope-LEDControl.h>
#include <Kaleidoscope-DefaultLEDModeConfig.h>
#include <Kaleidoscope-LEDEffect-Rainbow.h>
#include <Kaleidoscope-FocusSerial.h>

KALEIDOSCOPE_INIT_PLUGINS(EEPROMSettings,
                          LEDControl,
                          LEDOff,
                          LEDRainbowEffect,
                          LEDRainbowWaveEffect,
                          Focus,
                          DefaultLEDModeConfig);

void setup() {
  Kaleidoscope.setup();

  DefaultLEDModeConfig.activateLEDModeIfUnconfigured(
    &LEDRainbowWaveEffect
  );
}

Plugin methods

The plugin provides a singleton object called DefaultLEDModeConfig, with a single method:

.activateLEDModeIfUnconfigured(&LEDModePlugin)

Activates the LED mode pointed to by &LEDModePlugin if and only if the EEPROM slice of the plugin is unconfigured. This lets us set a default LED mode without persisting it into storage, or hard-coding it.

Focus commands

led_mode.default

Without arguments, prints the default LED mode's index.

If an argument is given, it must be the index of the LED mode we wish to set as the default.

Dependencies