Kaleidoscope
Kaleidoscope-LEDControl.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <Kaleidoscope.h>
4 
5 #define LED_MAX_MODES 24
6 
7 #define LED_TOGGLE B00000001 // Synthetic, internal
8 
9 #define Key_LEDEffectNext (Key) { 0, KEY_FLAGS | SYNTHETIC | IS_INTERNAL | LED_TOGGLE }
10 
11 class LEDMode : public KaleidoscopePlugin {
12  public:
13  virtual void begin(void);
14  virtual void setup(void) {}
15  virtual void init(void) {}
16  virtual void update(void) {}
17  virtual void activate(void);
18 };
19 
21  public:
22  LEDControl_(void);
23 
24  void begin(void) final;
25 
26  static void next_mode(void);
27  static void setup(void);
28  static void update(void);
29  static void set_mode(uint8_t mode);
30  static uint8_t get_mode();
31  static void init_mode(void);
32 
33  static int8_t mode_add(LEDMode *mode);
34 
35  static void setCrgbAt(uint8_t i, cRGB crgb);
36  static void setCrgbAt(byte row, byte col, cRGB color);
37  static cRGB getCrgbAt(uint8_t i);
38  static void syncLeds(void);
39 
40  static void set_all_leds_to(uint8_t r, uint8_t g, uint8_t b);
41  static void set_all_leds_to(cRGB color);
42 
43  static void activate(LEDMode *mode);
44 
45  static uint16_t syncDelay;
46 
47  static bool focusHook(const char *command);
48 
49  private:
50  static uint32_t syncTimer;
51  static LEDMode *modes[LED_MAX_MODES];
52  static uint8_t previousMode, mode;
53 
54  static Key eventHandler(Key mappedKey, byte row, byte col, uint8_t keyState);
55  static void loopHook(bool postClear);
56 };
57 
58 extern LEDControl_ LEDControl;
59 
60 #define FOCUS_HOOK_LEDCONTROL FOCUS_HOOK (LEDControl.focusHook, \
61  "led.at\n" \
62  "led.setAll\n" \
63  "led.theme\n" \
64  "led.mode")
virtual void setup(void)
Definition: Kaleidoscope-LEDControl.h:14
LEDControl_ LEDControl
Definition: Kaleidoscope-LEDControl.cpp:265
Definition: Kaleidoscope-LEDControl.h:20
#define LED_MAX_MODES
Definition: Kaleidoscope-LEDControl.h:5
byte byte col
Definition: TapDance.cpp:229
Definition: key_defs.h:13
Definition: Kaleidoscope-LEDControl.h:11
virtual void activate(void)
Definition: Kaleidoscope-LEDControl.cpp:10
virtual void update(void)
Definition: Kaleidoscope-LEDControl.h:16
Definition: Kaleidoscope-Hardware-Shortcut.h:29
Definition: Kaleidoscope.h:40
virtual void begin(void)
Definition: Kaleidoscope-LEDControl.cpp:15
byte row
Definition: TapDance.cpp:229
static uint16_t syncDelay
Definition: Kaleidoscope-LEDControl.h:45
virtual void init(void)
Definition: Kaleidoscope-LEDControl.h:15
uint8_t keyState
Definition: Kaleidoscope-Macros.cpp:5