pull/365/head
commit
7d5154b7ce
@ -0,0 +1,146 @@
|
||||
# Kaleidoscope-LEDEffect-BootGreeting
|
||||
|
||||
If you want to have your keyboard signal when it turns on, but you don't want to
|
||||
use any more complicated LED modes, this plugin is for you. It will make the
|
||||
`LEDEffectNext` key on your keymap slowly breathe for about ten seconds after
|
||||
plugging the keyboard in (without blocking the normal functionality of the
|
||||
keyboard, of course).
|
||||
|
||||
## Using the plugin
|
||||
|
||||
To use the plugin, include the header, and tell `Kaleidoscope` to use the plugin:
|
||||
|
||||
```c++
|
||||
#include <Kaleidoscope.h>
|
||||
#include <Kaleidoscope-LEDControl.h>
|
||||
#include <Kaleidoscope-LEDEffect-BootGreeting.h>
|
||||
|
||||
KALEIDOSCOPE_INIT_PLUGINS(LEDControl,
|
||||
BootGreetingEffect
|
||||
LEDOff);
|
||||
|
||||
void setup() {
|
||||
Kaleidoscope.setup();
|
||||
}
|
||||
```
|
||||
|
||||
You may also set optional parameters.
|
||||
|
||||
### Specify by search key
|
||||
```c++
|
||||
#include <Kaleidoscope.h>
|
||||
#include <Kaleidoscope-LEDControl.h>
|
||||
#include <Kaleidoscope-LEDEffect-BootGreeting.h>
|
||||
|
||||
KALEIDOSCOPE_INIT_PLUGINS(LEDControl,
|
||||
BootGreetingEffect
|
||||
LEDOff);
|
||||
|
||||
void setup() {
|
||||
Kaleidoscope.setup();
|
||||
|
||||
BootGreetingEffect.search_key = Key_M;
|
||||
}
|
||||
```
|
||||
|
||||
### Specify by position
|
||||
```c++
|
||||
#include <Kaleidoscope.h>
|
||||
#include <Kaleidoscope-LEDControl.h>
|
||||
#include <Kaleidoscope-LEDEffect-BootGreeting.h>
|
||||
|
||||
KALEIDOSCOPE_INIT_PLUGINS(LEDControl,
|
||||
BootGreetingEffect
|
||||
LEDOff);
|
||||
|
||||
void setup() {
|
||||
Kaleidoscope.setup();
|
||||
|
||||
//Butterfly key
|
||||
BootGreetingEffect.key_col = 7;
|
||||
BootGreetingEffect.key_row = 3;
|
||||
}
|
||||
```
|
||||
|
||||
### Specify longer timeout
|
||||
```c++
|
||||
#include <Kaleidoscope.h>
|
||||
#include <Kaleidoscope-LEDControl.h>
|
||||
#include <Kaleidoscope-LEDEffect-BootGreeting.h>
|
||||
|
||||
KALEIDOSCOPE_INIT_PLUGINS(LEDControl,
|
||||
BootGreetingEffect
|
||||
LEDOff);
|
||||
|
||||
void setup() {
|
||||
Kaleidoscope.setup();
|
||||
|
||||
//Butterfly key
|
||||
BootGreetingEffect.timeout = 15000;
|
||||
}
|
||||
```
|
||||
|
||||
### Specify different color
|
||||
```c++
|
||||
#include <Kaleidoscope.h>
|
||||
#include <Kaleidoscope-LEDControl.h>
|
||||
#include <Kaleidoscope-LEDEffect-BootGreeting.h>
|
||||
|
||||
KALEIDOSCOPE_INIT_PLUGINS(LEDControl,
|
||||
BootGreetingEffect
|
||||
LEDOff);
|
||||
|
||||
void setup() {
|
||||
Kaleidoscope.setup();
|
||||
|
||||
//Butterfly key
|
||||
BootGreetingEffect.hue = 90;
|
||||
|
||||
Kaleidoscope.setup();
|
||||
}
|
||||
```
|
||||
|
||||
## Plugin methods
|
||||
|
||||
The plugin provides the `BootGreetingEffect` object, with the following methods and
|
||||
properties:
|
||||
|
||||
### `.search_key`
|
||||
|
||||
> Set the key in the current keymap that should be activated with the pulsing
|
||||
> LED on startup. The plugin will search from the top left to the bottom right
|
||||
> of the keyboard, row by row, to find this key. The first matching key will
|
||||
> be selected.
|
||||
>
|
||||
> Defaults to `Key_LEDEffectNext`
|
||||
|
||||
### `.key_row`
|
||||
|
||||
> This is an optional override to explicitly set the selected key by exact row
|
||||
> and column. This number is 0-indexed, so the top row is 0, the second row is
|
||||
> 1, etc. Must set `.key_col` property for this feature to be enabled.
|
||||
|
||||
### `.key_col`
|
||||
|
||||
> This is an optional override to explicitly set the selected key by exact row
|
||||
> and column. This number is 0-indexed, so the left-most column is 0, the
|
||||
> second column is 1, etc. Must set `.key_row` property for this feature to
|
||||
> be enabled.
|
||||
|
||||
### `.timeout`
|
||||
|
||||
> This property specifies the timeout (in milliseconds) for the effect to last.
|
||||
> When the keyboard is first connected, the pulsing LED effect will last for
|
||||
> this duration before turning off.
|
||||
>
|
||||
> Defaults to `9200` ms.
|
||||
|
||||
### `.hue`
|
||||
|
||||
> This property sets the color hue that the LED pulsing effect.
|
||||
>
|
||||
> The default is `170`, which is a blue color.
|
||||
|
||||
## Dependencies
|
||||
|
||||
* [Kaleidoscope-LEDControl](LEDControl.md)
|
@ -0,0 +1,54 @@
|
||||
/* -*- mode: c++ -*-
|
||||
* Kaleidoscope-LEDEffect-BootGreeting -- Small greeting at boot time
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#include <Kaleidoscope.h>
|
||||
#include <Kaleidoscope-LEDControl.h>
|
||||
#include <Kaleidoscope-LEDEffect-BootGreeting.h>
|
||||
|
||||
// *INDENT-OFF*
|
||||
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_NoKey,
|
||||
|
||||
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_NoKey),
|
||||
};
|
||||
// *INDENT-ON*
|
||||
|
||||
KALEIDOSCOPE_INIT_PLUGINS(LEDControl,
|
||||
BootGreetingEffect,
|
||||
LEDOff);
|
||||
|
||||
void setup() {
|
||||
Kaleidoscope.setup();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Kaleidoscope.loop();
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
/* -*- mode: c++ -*-
|
||||
* Kaleidoscope-LEDEffect-BootGreeting -- Small greeting at boot time
|
||||
* 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/plugin/LEDEffect-BootGreeting.h"
|
@ -0,0 +1,94 @@
|
||||
/* -*- mode: c++ -*-
|
||||
* Kaleidoscope-LEDEffect-BootGreeting -- Small greeting at boot time
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#include "Kaleidoscope-LEDEffect-BootGreeting.h"
|
||||
|
||||
namespace kaleidoscope {
|
||||
namespace plugin {
|
||||
|
||||
bool BootGreetingEffect::done_ = false;
|
||||
byte BootGreetingEffect::row_;
|
||||
byte BootGreetingEffect::col_;
|
||||
byte BootGreetingEffect::key_row = 255;
|
||||
byte BootGreetingEffect::key_col = 255;
|
||||
Key BootGreetingEffect::search_key = Key_LEDEffectNext;
|
||||
uint8_t BootGreetingEffect::hue = 170;
|
||||
uint16_t BootGreetingEffect::start_time = 0;
|
||||
uint16_t BootGreetingEffect::timeout = 9200;
|
||||
|
||||
BootGreetingEffect::BootGreetingEffect(byte pos_row, byte pos_col) {
|
||||
key_row = pos_row;
|
||||
key_col = pos_col;
|
||||
}
|
||||
|
||||
void BootGreetingEffect::findLed(void) {
|
||||
if (key_col != 255 && key_row != 255) {
|
||||
row_ = key_row;
|
||||
col_ = key_col;
|
||||
done_ = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// Find the LED key.
|
||||
for (uint8_t r = 0; r < ROWS; r++) {
|
||||
for (uint8_t c = 0; c < COLS; c++) {
|
||||
Key k = Layer.lookupOnActiveLayer(r, c);
|
||||
|
||||
if (k.raw == search_key.raw) {
|
||||
row_ = r;
|
||||
col_ = c;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// We didn't find the LED key. Let's just pretend we're "done".
|
||||
done_ = true;
|
||||
}
|
||||
|
||||
EventHandlerResult BootGreetingEffect::afterEachCycle() {
|
||||
//If already done or we're not in a ready state, bail
|
||||
if (done_) {
|
||||
return EventHandlerResult::OK;
|
||||
}
|
||||
|
||||
//If the start time isn't set, set the start time and
|
||||
//find the LEDs.
|
||||
if (start_time == 0) {
|
||||
start_time = millis();
|
||||
findLed();
|
||||
//the first time, don't do anything.
|
||||
return EventHandlerResult::OK;
|
||||
}
|
||||
|
||||
//Only run for 'timeout' milliseconds
|
||||
if ((millis() - start_time) > timeout) {
|
||||
done_ = true;
|
||||
::LEDControl.refreshAt(row_, col_);
|
||||
return EventHandlerResult::OK;
|
||||
}
|
||||
|
||||
cRGB color = breath_compute(hue);
|
||||
::LEDControl.setCrgbAt(row_, col_, color);
|
||||
|
||||
return EventHandlerResult::OK;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
kaleidoscope::plugin::BootGreetingEffect BootGreetingEffect;
|
@ -0,0 +1,47 @@
|
||||
/* -*- mode: c++ -*-
|
||||
* Kaleidoscope-LEDEffect-BootGreeting -- Small greeting at boot time
|
||||
* 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 BootGreetingEffect : public kaleidoscope::Plugin {
|
||||
public:
|
||||
BootGreetingEffect(void) {}
|
||||
BootGreetingEffect(byte, byte);
|
||||
|
||||
static byte key_row;
|
||||
static byte key_col;
|
||||
static Key search_key;
|
||||
static uint8_t hue;
|
||||
static uint16_t timeout;
|
||||
|
||||
EventHandlerResult afterEachCycle();
|
||||
|
||||
private:
|
||||
static void findLed(void);
|
||||
static bool done_;
|
||||
static byte row_;
|
||||
static byte col_;
|
||||
static uint16_t start_time;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
extern kaleidoscope::plugin::BootGreetingEffect BootGreetingEffect;
|
Loading…
Reference in new issue