diff --git a/doc/plugin/LEDEffect-SolidColor.md b/doc/plugin/LEDEffect-SolidColor.md new file mode 100644 index 00000000..963bf0f2 --- /dev/null +++ b/doc/plugin/LEDEffect-SolidColor.md @@ -0,0 +1,33 @@ +# Kaleidoscope-LEDEffect-SolidColor + +This plugin provides tools to build LED effects that set the entire keyboard to +a single color. For show, and for backlighting purposes. + +## Using the extension + +To use the plugin, include the header, declare an effect using the +`kaleidoscope::plugin::LEDSolidColor` class, and tell the firmware to use the +new effect: + +```c++ +#include + +static kaleidoscope::plugin::LEDSolidColor solidRed(160, 0, 0); + +KALEIDOSCOPE_INIT_PLUGINS(LEDControl, solidRed); + +void setup() { + Kaleidoscope.setup(); +} +``` + +## Dependencies + +* [Kaleidoscope-LEDControl](LEDControl.md) + +## Upgrading + +Previous versions of `LEDEffect-SolidColor` used `kaleidoscope::LEDSolidColor` +as a class for defining solid-color effects. This is called +`kaleidoscope::plugin::LEDSolidColor` now. The old name still works, but is +deprecated, and will be removed by 2019-01-14. diff --git a/src/Kaleidoscope-LEDEffect-SolidColor.h b/src/Kaleidoscope-LEDEffect-SolidColor.h new file mode 100644 index 00000000..1fc4259b --- /dev/null +++ b/src/Kaleidoscope-LEDEffect-SolidColor.h @@ -0,0 +1,19 @@ +/* Kaleidoscope-LEDEffect-SolidColor - Solid color LED effects for Kaleidoscope. + * Copyright (C) 2017 Keyboard.io, Inc. + * + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ + +#pragma once + +#include "kaleidoscope/plugin/LEDEffect-SolidColor.h" diff --git a/src/kaleidoscope/plugin/LEDEffect-SolidColor.cpp b/src/kaleidoscope/plugin/LEDEffect-SolidColor.cpp new file mode 100644 index 00000000..d030e86d --- /dev/null +++ b/src/kaleidoscope/plugin/LEDEffect-SolidColor.cpp @@ -0,0 +1,36 @@ +/* Kaleidoscope-LEDEffect-SolidColor - Solid color LED effects for Kaleidoscope. + * Copyright (C) 2017 Keyboard.io, Inc. + * + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ + +#include "Kaleidoscope-LEDEffect-SolidColor.h" + +namespace kaleidoscope { +namespace plugin { +LEDSolidColor::LEDSolidColor(uint8_t r, uint8_t g, uint8_t b) { + this->r = r; + this->g = g; + this->b = b; +} + +void LEDSolidColor::onActivate(void) { + ::LEDControl.set_all_leds_to(r, g, b); +} + +void LEDSolidColor::refreshAt(byte row, byte col) { + ::LEDControl.setCrgbAt(row, col, CRGB(r, g, b)); +} + +} +} diff --git a/src/kaleidoscope/plugin/LEDEffect-SolidColor.h b/src/kaleidoscope/plugin/LEDEffect-SolidColor.h new file mode 100644 index 00000000..b79bbf72 --- /dev/null +++ b/src/kaleidoscope/plugin/LEDEffect-SolidColor.h @@ -0,0 +1,39 @@ +/* Kaleidoscope-LEDEffect-SolidColor - Solid color LED effects for Kaleidoscope. + * Copyright (C) 2017 Keyboard.io, Inc. + * + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ + +#pragma once + +#include "Kaleidoscope-LEDControl.h" + +namespace kaleidoscope { +namespace plugin { +class LEDSolidColor : public LEDMode { + public: + LEDSolidColor(uint8_t r, uint8_t g, uint8_t b); + + protected: + void onActivate(void) final; + void refreshAt(byte row, byte col) final; + + private: + uint8_t r, g, b; +}; +} + +// Backwards compatibility +typedef plugin::LEDSolidColor LEDSolidColor; + +}