Merge pull request #386 from keyboardio/f/LEDControl/bootAnimation-be-gone
Remove kaleidoscope/plugin/LEDControl/BootAnimation.*pull/426/head
commit
87425da10c
@ -0,0 +1,45 @@
|
||||
# Kaleidoscope-LEDEffect-BootAnimation
|
||||
|
||||
With this plugin enabled, the keyboard will play a little boot animation when
|
||||
starting up (this animation does not inhibit typing, you can still use the
|
||||
keyboard while the animation plays).
|
||||
|
||||
## 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-BootAnimation.h>
|
||||
|
||||
KALEIDOSCOPE_INIT_PLUGINS(LEDControl,
|
||||
BootAnimationEffect
|
||||
LEDOff);
|
||||
|
||||
void setup() {
|
||||
Kaleidoscope.setup();
|
||||
}
|
||||
```
|
||||
|
||||
## Plugin properties
|
||||
|
||||
The plugin provides the `BootAnimationEffect` object, with the following
|
||||
properties:
|
||||
|
||||
### `.timeout`
|
||||
|
||||
> This property specifies the timeout (in milliseconds) each step of the
|
||||
> animation is displayed.
|
||||
>
|
||||
> Defaults to `1000` ms, or one second.
|
||||
|
||||
### `.color`
|
||||
|
||||
> This property sets the color the animation is played with.
|
||||
>
|
||||
> The default is a red color.
|
||||
|
||||
## Dependencies
|
||||
|
||||
* [Kaleidoscope-LEDControl](LEDControl.md)
|
@ -1,51 +0,0 @@
|
||||
/* Kaleidoscope-LEDControl - LED control 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/>.
|
||||
*/
|
||||
|
||||
#include "kaleidoscope/plugin/LEDControl/BootAnimation.h"
|
||||
#include "Kaleidoscope-LEDControl.h"
|
||||
|
||||
#ifdef ARDUINO_AVR_MODEL01
|
||||
static void
|
||||
type_letter(uint8_t letter) {
|
||||
LEDControl.setCrgbAt(letter, {255, 0, 0});
|
||||
LEDControl.syncLeds();
|
||||
delay(250);
|
||||
LEDControl.setCrgbAt(letter, {0, 0, 0});
|
||||
LEDControl.syncLeds();
|
||||
delay(10);
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
bootAnimation(void) {
|
||||
#ifdef ARDUINO_AVR_MODEL01
|
||||
LEDControl.set_all_leds_to(0, 0, 0);
|
||||
type_letter(LED_K);
|
||||
type_letter(LED_E);
|
||||
type_letter(LED_Y);
|
||||
type_letter(LED_B);
|
||||
type_letter(LED_O);
|
||||
type_letter(LED_A);
|
||||
type_letter(LED_R);
|
||||
type_letter(LED_D);
|
||||
type_letter(LED_I);
|
||||
type_letter(LED_O);
|
||||
type_letter(LED_SPACE);
|
||||
type_letter(LED_0);
|
||||
type_letter(LED_PERIOD);
|
||||
type_letter(LED_9);
|
||||
#endif
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
/* -*- mode: c++ -*-
|
||||
* Kaleidoscope-LEDEffect-BootAnimation -- Small greeting at boot time
|
||||
* Copyright (C) 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-BootAnimation.h"
|
||||
|
||||
namespace kaleidoscope {
|
||||
namespace plugin {
|
||||
|
||||
bool BootAnimationEffect::done_ = false;
|
||||
cRGB BootAnimationEffect::color = CRGB(150, 0, 0);
|
||||
uint16_t BootAnimationEffect::start_time_ = 0;
|
||||
uint16_t BootAnimationEffect::timeout = 1000;
|
||||
uint8_t BootAnimationEffect::current_index_ = 0;
|
||||
const uint8_t BootAnimationEffect::greeting_[11] PROGMEM = {
|
||||
Key_K.keyCode,
|
||||
Key_E.keyCode,
|
||||
Key_Y.keyCode,
|
||||
Key_B.keyCode,
|
||||
Key_O.keyCode,
|
||||
Key_A.keyCode,
|
||||
Key_R.keyCode,
|
||||
Key_D.keyCode,
|
||||
Key_Period.keyCode,
|
||||
Key_I.keyCode,
|
||||
Key_O.keyCode
|
||||
};
|
||||
|
||||
EventHandlerResult BootAnimationEffect::onSetup() {
|
||||
start_time_ = Kaleidoscope.millisAtCycleStart();
|
||||
return EventHandlerResult::OK;
|
||||
}
|
||||
|
||||
EventHandlerResult BootAnimationEffect::afterEachCycle() {
|
||||
//If already done or we're not in a ready state, bail
|
||||
if (done_) {
|
||||
return EventHandlerResult::OK;
|
||||
}
|
||||
|
||||
byte row = 255, col = 255;
|
||||
|
||||
for (uint8_t r = 0; r < ROWS; r++) {
|
||||
for (uint8_t c = 0; c < COLS; c++) {
|
||||
Key k = Layer.lookupOnActiveLayer(r, c);
|
||||
Key g;
|
||||
g.flags = 0;
|
||||
g.keyCode = pgm_read_word(&greeting_[current_index_]);
|
||||
|
||||
if (k.raw == g.raw) {
|
||||
row = r;
|
||||
col = c;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((Kaleidoscope.millisAtCycleStart() - start_time_) > timeout) {
|
||||
current_index_++;
|
||||
if (current_index_ == sizeof(greeting_))
|
||||
done_ = true;
|
||||
|
||||
start_time_ = Kaleidoscope.millisAtCycleStart();
|
||||
if (row != 255 && col != 255)
|
||||
::LEDControl.refreshAt(row, col);
|
||||
return EventHandlerResult::OK;
|
||||
}
|
||||
|
||||
if (row != 255 && col != 255) {
|
||||
::LEDControl.setCrgbAt(row, col, color);
|
||||
}
|
||||
|
||||
return EventHandlerResult::OK;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
kaleidoscope::plugin::BootAnimationEffect BootAnimationEffect;
|
@ -0,0 +1,45 @@
|
||||
/* -*- mode: c++ -*-
|
||||
* Kaleidoscope-LEDEffect-BootAnimation -- Small greeting at boot time
|
||||
* Copyright (C) 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 BootAnimationEffect : public kaleidoscope::Plugin {
|
||||
public:
|
||||
BootAnimationEffect(void) {}
|
||||
|
||||
static uint16_t timeout;
|
||||
static cRGB color;
|
||||
|
||||
EventHandlerResult afterEachCycle();
|
||||
EventHandlerResult onSetup();
|
||||
|
||||
private:
|
||||
static const uint8_t greeting_[11];
|
||||
|
||||
static bool done_;
|
||||
static uint16_t start_time_;
|
||||
static uint8_t current_index_;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
extern kaleidoscope::plugin::BootAnimationEffect BootAnimationEffect;
|
Loading…
Reference in new issue