Rearrange the file layout in preparation of becoming a monorepo

Move the documentation to `doc/plugin/NumPad.md`, sources under
`src/kaleidoscope/plugin/` (appropriately namespaced). This is in preparation of
merging plugins into a single monorepo.

Signed-off-by: Gergely Nagy <algernon@keyboard.io>
pull/365/head
Gergely Nagy 6 years ago
parent f2c65cb175
commit 09c48b8da2
No known key found for this signature in database
GPG Key ID: AC1E90BAC433F68F

@ -1,39 +1,8 @@
# Kaleidoscope-NumPad
This is a plugin for [Kaleidoscope][fw], that adds a NumPad-specific LED
effect, along with a way to toggle to a numpad layer, and apply the effect.
[![Build Status][travis:image]][travis:status]
## Using the extension
[travis:image]: https://travis-ci.org/keyboardio/Kaleidoscope-NumPad.svg?branch=master
[travis:status]: https://travis-ci.org/keyboardio/Kaleidoscope-NumPad
To use the plugin, include the header, and tell the firmware to use it:
```c++
#include "Kaleidoscope-NumPad.h"
KALEIDOSCOPE_INIT_PLUGINS(NumPad);
void setup() {
Kaleidoscope.setup();
NumPad.color = CRGB(0, 0, 160); // a blue color
NumPad.lock_hue = 85; // green
}
```
## Plugin methods
The plugin provides the `NumPad` object, with the following properties:
### `.color`
> This property sets the color that the NumPad keys are highlighted in.
>
> The default is `CRGB(160, 0, 0)`, a red color.
### `.lock_hue`
> This property sets the color hue that the NumLock LED breathes in.
>
> The default is `170`, a blue hue.
[fw]: https://github.com/keyboardio/Kaleidoscope
See [doc/plugin/NumPad.md](doc/plugin/NumPad.md) for documentation.

@ -0,0 +1,39 @@
# Kaleidoscope-NumPad
This is a plugin for [Kaleidoscope][fw], that adds a NumPad-specific LED
effect, along with a way to toggle to a numpad layer, and apply the effect.
## Using the extension
To use the plugin, include the header, and tell the firmware to use it:
```c++
#include "Kaleidoscope-NumPad.h"
KALEIDOSCOPE_INIT_PLUGINS(NumPad);
void setup() {
Kaleidoscope.setup();
NumPad.color = CRGB(0, 0, 160); // a blue color
NumPad.lock_hue = 85; // green
}
```
## Plugin methods
The plugin provides the `NumPad` object, with the following properties:
### `.color`
> This property sets the color that the NumPad keys are highlighted in.
>
> The default is `CRGB(160, 0, 0)`, a red color.
### `.lock_hue`
> This property sets the color hue that the NumLock LED breathes in.
>
> The default is `170`, a blue hue.
[fw]: https://github.com/keyboardio/Kaleidoscope

@ -16,32 +16,4 @@
#pragma once
#include "Kaleidoscope-LEDControl.h"
#include "Kaleidoscope-Macros.h"
#include "LEDUtils.h"
class NumPad_ : public kaleidoscope::Plugin {
public:
NumPad_(void) {}
static uint8_t numPadLayer;
static cRGB color;
static uint8_t lock_hue;
kaleidoscope::EventHandlerResult onSetup(void);
kaleidoscope::EventHandlerResult afterEachCycle();
private:
void cleanupNumlockState(void);
void setKeyboardLEDColors(void);
bool getNumlockState(void);
void syncNumlockState(bool);
static uint8_t numpadLayerToggleKeyRow;
static uint8_t numpadLayerToggleKeyCol;
static bool numlockUnsynced;
static bool originalNumLockState;
};
extern NumPad_ NumPad;
#include "kaleidoscope/plugin/NumPad.h"

@ -15,26 +15,27 @@
*/
#include "Kaleidoscope-NumPad.h"
#include "LEDUtils.h"
#include "Kaleidoscope.h"
byte NumPad_::numpadLayerToggleKeyRow = 255, NumPad_::numpadLayerToggleKeyCol = 255;
uint8_t NumPad_::numPadLayer;
bool NumPad_::numlockUnsynced = false;
bool NumPad_::originalNumLockState = false;
cRGB NumPad_::color = CRGB(160, 0, 0);
uint8_t NumPad_::lock_hue = 170;
namespace kaleidoscope {
namespace plugin {
kaleidoscope::EventHandlerResult NumPad_::onSetup(void) {
byte NumPad::numpadLayerToggleKeyRow = 255, NumPad::numpadLayerToggleKeyCol = 255;
uint8_t NumPad::numPadLayer;
bool NumPad::numlockUnsynced = false;
bool NumPad::originalNumLockState = false;
cRGB NumPad::color = CRGB(160, 0, 0);
uint8_t NumPad::lock_hue = 170;
EventHandlerResult NumPad::onSetup(void) {
originalNumLockState = getNumlockState();
return kaleidoscope::EventHandlerResult::OK;
return EventHandlerResult::OK;
}
bool NumPad_::getNumlockState() {
bool NumPad::getNumlockState() {
return !!(kaleidoscope::hid::getKeyboardLEDs() & LED_NUM_LOCK);
}
void NumPad_::syncNumlockState(bool state) {
void NumPad::syncNumlockState(bool state) {
bool numLockLEDState = getNumlockState();
if (numLockLEDState != state) {
kaleidoscope::hid::pressKey(Key_KeypadNumLock);
@ -43,10 +44,10 @@ void NumPad_::syncNumlockState(bool state) {
void NumPad_::cleanupNumlockState() {
void NumPad::cleanupNumlockState() {
if (!numlockUnsynced) {
bool numLockLEDState = getNumlockState();
LEDControl.set_mode(LEDControl.get_mode_index());
::LEDControl.set_mode(::LEDControl.get_mode_index());
if (!originalNumLockState) {
syncNumlockState(false);
numLockLEDState = false;
@ -57,8 +58,8 @@ void NumPad_::cleanupNumlockState() {
}
void NumPad_::setKeyboardLEDColors(void) {
LEDControl.set_mode(LEDControl.get_mode_index());
void NumPad::setKeyboardLEDColors(void) {
::LEDControl.set_mode(::LEDControl.get_mode_index());
for (uint8_t r = 0; r < ROWS; r++) {
for (uint8_t c = 0; c < COLS; c++) {
@ -71,22 +72,20 @@ void NumPad_::setKeyboardLEDColors(void) {
}
if ((k != layer_key) || (k == Key_NoKey) || (k.flags != KEY_FLAGS)) {
LEDControl.refreshAt(r, c);
::LEDControl.refreshAt(r, c);
} else {
LEDControl.setCrgbAt(r, c, color);
::LEDControl.setCrgbAt(r, c, color);
}
}
}
if ((numpadLayerToggleKeyRow <= ROWS) && (numpadLayerToggleKeyCol <= COLS)) {
cRGB lock_color = breath_compute(lock_hue);
LEDControl.setCrgbAt(numpadLayerToggleKeyRow, numpadLayerToggleKeyCol, lock_color);
::LEDControl.setCrgbAt(numpadLayerToggleKeyRow, numpadLayerToggleKeyCol, lock_color);
}
}
kaleidoscope::EventHandlerResult NumPad_::afterEachCycle() {
EventHandlerResult NumPad::afterEachCycle() {
if (!Layer.isOn(numPadLayer)) {
cleanupNumlockState();
} else {
@ -97,9 +96,10 @@ kaleidoscope::EventHandlerResult NumPad_::afterEachCycle() {
}
setKeyboardLEDColors();
}
return kaleidoscope::EventHandlerResult::OK;
return EventHandlerResult::OK;
}
}
}
NumPad_ NumPad;
kaleidoscope::plugin::NumPad NumPad;

@ -0,0 +1,50 @@
/* Kaleidoscope-NumPad - A NumPad plugin for Kaleidoscope.
* Copyright (C) 2017-2018 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 <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "Kaleidoscope-LEDControl.h"
namespace kaleidoscope {
namespace plugin {
class NumPad : public kaleidoscope::Plugin {
public:
NumPad(void) {}
static uint8_t numPadLayer;
static cRGB color;
static uint8_t lock_hue;
EventHandlerResult onSetup(void);
EventHandlerResult afterEachCycle();
private:
void cleanupNumlockState(void);
void setKeyboardLEDColors(void);
bool getNumlockState(void);
void syncNumlockState(bool);
static uint8_t numpadLayerToggleKeyRow;
static uint8_t numpadLayerToggleKeyCol;
static bool numlockUnsynced;
static bool originalNumLockState;
};
}
}
extern kaleidoscope::plugin::NumPad NumPad;
Loading…
Cancel
Save