Kaleidoscope
KeyboardioScanner.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <Arduino.h>
5 
6 struct cRGB {
7  uint8_t b;
8  uint8_t g;
9  uint8_t r;
10 };
11 
12 #define LED_BANKS 4
13 
14 #define LEDS_PER_HAND 32
15 #define LED_BYTES_PER_BANK sizeof(cRGB) * LEDS_PER_HAND/LED_BANKS
16 
17 typedef union {
20 } LEDData_t;
21 
22 
23 // Same datastructure as on the other side
24 typedef union {
25  struct {
26  uint8_t row: 2,
27  col: 3,
28  keyState: 1,
29  keyEventsWaiting: 1,
30  eventReported: 1;
31  };
32  uint8_t val;
33 } key_t;
34 
35 
36 typedef union {
37  uint8_t rows[4];
38  uint32_t all;
39 } keydata_t;
40 
41 // config options
42 
43 // used to configure interrupts, configuration for a particular controller
45  public:
46  KeyboardioScanner(byte setAd01);
48 
49  int readVersion();
50 
51  byte setKeyscanInterval(byte delay);
52  int readKeyscanInterval();
53 
54  byte setLEDSPIFrequency(byte frequency);
55  int readLEDSPIFrequency();
56 
57  bool moreKeysWaiting();
58  void sendLEDData();
59  void setOneLEDTo(byte led, cRGB color);
60  void setAllLEDsTo(cRGB color);
61  keydata_t getKeyData();
62  bool readKeys();
64  uint8_t controllerAddress();
65 
66  private:
67  int addr;
68  int ad01;
69  keydata_t keyData;
70  bool keyReady = false;
71  byte nextLEDBank = 0;
72  void sendLEDBank(byte bank);
73  int readRegister(uint8_t cmd);
74 };
75 
uint8_t val
Definition: KeyboardioScanner.h:32
Definition: KeyboardioScanner.h:36
uint8_t row
Definition: KeyboardioScanner.h:26
#define LED_BANKS
Definition: KeyboardioScanner.h:12
Definition: KeyboardioScanner.h:24
byte byte col
Definition: TapDance.cpp:229
uint8_t r
Definition: Kaleidoscope-Hardware-Shortcut.h:31
LEDData_t ledData
Definition: KeyboardioScanner.h:63
uint8_t g
Definition: Kaleidoscope-Hardware-Shortcut.h:30
Definition: Kaleidoscope-Hardware-Shortcut.h:29
Definition: KeyboardioScanner.h:44
uint8_t b
Definition: Kaleidoscope-Hardware-Shortcut.h:32
#define LED_BYTES_PER_BANK
Definition: KeyboardioScanner.h:15
uint32_t all
Definition: KeyboardioScanner.h:38
Definition: KeyboardioScanner.h:17
uint8_t keyState
Definition: Kaleidoscope-Macros.cpp:5
#define LEDS_PER_HAND
Definition: KeyboardioScanner.h:14