Merge pull request #386 from keyboardio/f/LEDControl/bootAnimation-be-gone

Remove kaleidoscope/plugin/LEDControl/BootAnimation.*
pull/426/head
Jesse Vincent 6 years ago committed by GitHub
commit 87425da10c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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,5 +1,6 @@
/* Kaleidoscope-LEDControl - LED control plugin for Kaleidoscope /* -*- mode: c++ -*-
* Copyright (C) 2017-2018 Keyboard.io, Inc. * 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 * 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 * the terms of the GNU General Public License as published by the Free Software
@ -16,4 +17,4 @@
#pragma once #pragma once
void bootAnimation(void); #include "kaleidoscope/plugin/LEDEffect-BootAnimation.h"

@ -219,72 +219,6 @@ constexpr byte R3C15 = keyIndex(3, 15);
#define LED_COUNT 64 #define LED_COUNT 64
#define LED_PGDN 0
#define LED_PGUP 1
#define LED_BACKTICK 2
#define LED_PROG 3
#define LED_1 4
#define LED_Q 5
#define LED_A 6
#define LED_Z 7
#define LED_X 8
#define LED_S 9
#define LED_W 10
#define LED_2 11
#define LED_3 12
#define LED_E 13
#define LED_D 14
#define LED_C 15
#define LED_V 16
#define LED_F 17
#define LED_R 18
#define LED_4 19
#define LED_5 20
#define LED_T 21
#define LED_G 22
#define LED_B 23
#define LED_ESC 24
#define LED_TAB 25
#define LED_LED 26
#define LED_L_CTRL 27
#define LED_BKSP 28
#define LED_CMD 29
#define LED_L_SHIFT 30
#define LED_L_FN 31
#define LED_R_FN 32
#define LED_R_SHIFT 33
#define LED_ALT 34
#define LED_SPACE 35
#define LED_R_CTRL 36
#define LED_ANY 37
#define LED_RETURN 38
#define LED_BUTTERFLY 39
#define LED_N 40
#define LED_H 41
#define LED_Y 42
#define LED_6 43
#define LED_7 44
#define LED_U 45
#define LED_J 46
#define LED_M 47
#define LED_COMMA 48
#define LED_K 49
#define LED_I 50
#define LED_8 51
#define LED_9 52
#define LED_O 53
#define LED_L 54
#define LED_PERIOD 55
#define LED_SLASH 56
#define LED_SEMICOLON 57
#define LED_P 58
#define LED_0 59
#define LED_NUM 60
#define LED_EQUALS 61
#define LED_APOSTROPHE 62
#define LED_MINUS 63
#endif /* DOXYGEN_SHOULD_SKIP_THIS */ #endif /* DOXYGEN_SHOULD_SKIP_THIS */

@ -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…
Cancel
Save