Merge remote-tracking branch 'plugin/LED-ActiveModColor/f/monorepo' into f/monorepo-stage2

pull/389/head
Gergely Nagy 6 years ago
commit 07e389d729
No known key found for this signature in database
GPG Key ID: AC1E90BAC433F68F

@ -0,0 +1,56 @@
# Kaleidoscope-LED-ActiveModColor
With this plugin, any active modifier on the keyboard will have the LED under it
highlighted. No matter how the modifier got activated (a key press, a macro,
anything else), the coloring will apply. Layer keys, be them layer toggles,
momentary switches, or one-shot layer keys count as modifiers as far as the
plugin is concerned.
## Using the plugin
To use the plugin, one needs to include the header, and activate the effect. It
is also possible to use a custom color instead of the white default.
```c++
#include <Kaleidoscope.h>
#include <Kaleidoscope-LEDControl.h>
#include <Kaleidoscope-LED-ActiveModColor.h>
KALEIDOSCOPE_INIT_PLUGINS(LEDControl,
ActiveModColorEffect);
void setup () {
Kaleidoscope.setup ();
ActiveModColorEffect.highlight_color = CRGB(0x00, 0xff, 0xff);
}
```
It is recommended to place the activation (the `KALEIDOSCOPE_INIT_PLUGINS` parameter) of the
plugin last, so that it can reliably override any other plugins that may work
with the LEDs, and apply the highlight over those.
## Plugin properties
The plugin provides the `ActiveModColorEffect` object, which has the following
properties:
### `.highlight_color`
> The color to use for highlighting the modifiers. Defaults to a white color.
### `.sticky_color`
> The color to use for highlighting one-shot modifiers when they are sticky. Defaults to a red color.
## Dependencies
* [Kaleidoscope-LEDControl](LEDControl.md)
* [Kaleidoscope-OneShot](OneShot.md)
## Further reading
Starting from the [example][plugin:example] is the recommended way of getting
started with the plugin.
[plugin:example]: ../../examples/LED-ActiveModColor/LED-ActiveModColor.ino

@ -0,0 +1,53 @@
/* -*- mode: c++ -*-
* Kaleidoscope-LED-ActiveModColor -- Light up the LEDs under the active modifiers
* Copyright (C) 2016, 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/>.
*/
#include <Kaleidoscope.h>
#include <Kaleidoscope-LEDControl.h>
#include <Kaleidoscope-LED-ActiveModColor.h>
const Key keymaps[][ROWS][COLS] PROGMEM = {
[0] = KEYMAP_STACKED
(
Key_LEDEffectNext, Key_1, Key_2, Key_3, Key_4, Key_5, Key_LEDEffectNext,
Key_Backtick, Key_Q, Key_W, Key_E, Key_R, Key_T, Key_Tab,
Key_PageUp, Key_A, Key_S, Key_D, Key_F, Key_G,
Key_PageDown, Key_Z, Key_X, Key_C, Key_V, Key_B, Key_Escape,
Key_LeftControl, Key_Backspace, Key_LeftGui, Key_LeftShift,
Key_skip,
Key_skip, Key_6, Key_7, Key_8, Key_9, Key_0, Key_skip,
Key_Enter, Key_Y, Key_U, Key_I, Key_O, Key_P, Key_Equals,
Key_H, Key_J, Key_K, Key_L, Key_Semicolon, Key_Quote,
Key_skip, Key_N, Key_M, Key_Comma, Key_Period, Key_Slash, Key_Minus,
Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl,
Key_skip),
};
KALEIDOSCOPE_INIT_PLUGINS(LEDControl,
ActiveModColorEffect);
void setup() {
Kaleidoscope.setup();
ActiveModColorEffect.highlight_color = CRGB(0x00, 0xff, 0xff);
}
void loop() {
Kaleidoscope.loop();
}

@ -0,0 +1,20 @@
/* -*- mode: c++ -*-
* Kaleidoscope-LED-ActiveModColor -- Light up the LEDs under the active modifiers
* Copyright (C) 2016, 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 <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <kaleidoscope/plugin/LED-ActiveModColor.h>

@ -0,0 +1,67 @@
/* -*- mode: c++ -*-
* Kaleidoscope-LED-ActiveModColor -- Light up the LEDs under the active modifiers
* Copyright (C) 2016, 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/>.
*/
#include <Kaleidoscope-LED-ActiveModColor.h>
#include <Kaleidoscope-OneShot.h>
#include <kaleidoscope/hid.h>
namespace kaleidoscope {
namespace plugin {
cRGB ActiveModColorEffect::highlight_color = (cRGB) {
0xff, 0xff, 0xff
};
cRGB ActiveModColorEffect::sticky_color = CRGB(0xff, 0x00, 0x00);
EventHandlerResult ActiveModColorEffect::beforeReportingState() {
for (byte r = 0; r < ROWS; r++) {
for (byte c = 0; c < COLS; c++) {
Key k = Layer.lookupOnActiveLayer(r, c);
if (::OneShot.isOneShotKey(k)) {
if (::OneShot.isSticky(k))
::LEDControl.setCrgbAt(r, c, sticky_color);
else if (::OneShot.isActive(k))
::LEDControl.setCrgbAt(r, c, highlight_color);
else
::LEDControl.refreshAt(r, c);
} else if (k.raw >= Key_LeftControl.raw && k.raw <= Key_RightGui.raw) {
if (hid::isModifierKeyActive(k))
::LEDControl.setCrgbAt(r, c, highlight_color);
else
::LEDControl.refreshAt(r, c);
} else if (k.flags == (SYNTHETIC | SWITCH_TO_KEYMAP)) {
uint8_t layer = k.keyCode;
if (layer >= LAYER_SHIFT_OFFSET)
layer -= LAYER_SHIFT_OFFSET;
if (Layer.isOn(layer))
::LEDControl.setCrgbAt(r, c, highlight_color);
else
::LEDControl.refreshAt(r, c);
}
}
}
return EventHandlerResult::OK;
}
}
}
kaleidoscope::plugin::ActiveModColorEffect ActiveModColorEffect;

@ -0,0 +1,37 @@
/* -*- mode: c++ -*-
* Kaleidoscope-LED-ActiveModColor -- Light up the LEDs under the active modifiers
* Copyright (C) 2016, 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.h>
#include <Kaleidoscope-LEDControl.h>
namespace kaleidoscope {
namespace plugin {
class ActiveModColorEffect : public kaleidoscope::Plugin {
public:
ActiveModColorEffect(void) {}
static cRGB highlight_color;
static cRGB sticky_color;
EventHandlerResult beforeReportingState();
};
}
}
extern kaleidoscope::plugin::ActiveModColorEffect ActiveModColorEffect;
Loading…
Cancel
Save