Kaleidoscope
LED-Stalker.h
Go to the documentation of this file.
1 /* -*- mode: c++ -*-
2  * Kaleidoscope-LED-Stalker -- Stalk keys pressed by lighting up and fading back the LED under them
3  * Copyright (C) 2017 Gergely Nagy
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #pragma once
20 
21 #include <Kaleidoscope.h>
23 
24 #define STALKER(v, ...) ({static kaleidoscope::stalker::v _effect __VA_ARGS__; &_effect;})
25 
26 namespace kaleidoscope {
27 class StalkerEffect : public LEDMode {
28  public:
29  class ColorComputer {
30  public:
31  virtual cRGB compute(uint8_t *step) = 0;
32  };
33 
34  StalkerEffect(void);
35 
36  void begin(void) final;
37  void init(void) final;
38  void update(void) final;
39 
41  static uint16_t step_length;
42 
43  private:
44  static uint32_t step_end_time_;
45  static uint8_t map_[ROWS][COLS];
46 
47  static Key eventHandlerHook(Key mapped_key, byte row, byte col, uint8_t key_state);
48 };
49 
50 namespace stalker {
51 
53  public:
54  explicit Haunt(const cRGB highlight_color);
55  Haunt(void) : Haunt(CRGB(0x40, 0x80, 0x80)) {}
56 
57  cRGB compute(uint8_t *step) final;
58  private:
59  static cRGB highlight_color_;
60 };
61 
63  public:
64  BlazingTrail(void);
65 
66  cRGB compute(uint8_t *step) final;
67 };
68 
69 }
70 }
71 
#define ROWS
Definition: Kaleidoscope-Hardware-Model01.h:9
void init(void) final
Definition: LED-Stalker.cpp:37
void update(void) final
Definition: LED-Stalker.cpp:52
Definition: LED-Stalker.h:29
Definition: hid.cpp:4
Definition: LED-Stalker.h:52
Definition: LED-Stalker.h:62
byte byte col
Definition: TapDance.cpp:229
Definition: LED-Stalker.h:27
Definition: key_defs.h:13
static uint16_t step_length
Definition: LED-Stalker.h:41
Definition: Kaleidoscope-LEDControl.h:11
static ColorComputer * variant
Definition: LED-Stalker.h:40
virtual cRGB compute(uint8_t *step)=0
Definition: Kaleidoscope-Hardware-Shortcut.h:29
#define COLS
Definition: Kaleidoscope-Hardware-Model01.h:8
void begin(void) final
Definition: LED-Stalker.cpp:32
StalkerEffect(void)
Definition: LED-Stalker.cpp:29
byte row
Definition: TapDance.cpp:229
#define CRGB(r, g, b)
Definition: Kaleidoscope-Hardware-Model01.h:11
Haunt(void)
Definition: LED-Stalker.h:55