]> git.donarmstrong.com Git - qmk_firmware.git/blob - quantum/rgb_matrix_types.h
Updated rgb_led struct field modifier to flags (#5619)
[qmk_firmware.git] / quantum / rgb_matrix_types.h
1 #pragma once
2
3 #include <stdint.h>
4 #include <stdbool.h>
5
6 #if defined(__GNUC__)
7 #define PACKED __attribute__ ((__packed__))
8 #else
9 #define PACKED
10 #endif
11
12 #if defined(_MSC_VER)
13 #pragma pack( push, 1 )
14 #endif
15
16 #if defined(RGB_MATRIX_KEYPRESSES) || defined(RGB_MATRIX_KEYRELEASES)
17   #define RGB_MATRIX_KEYREACTIVE_ENABLED
18 #endif
19
20 // Last led hit
21 #ifndef LED_HITS_TO_REMEMBER
22   #define LED_HITS_TO_REMEMBER 8
23 #endif // LED_HITS_TO_REMEMBER
24
25 #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
26 typedef struct PACKED {
27   uint8_t count;
28   uint8_t x[LED_HITS_TO_REMEMBER];
29   uint8_t y[LED_HITS_TO_REMEMBER];
30   uint8_t index[LED_HITS_TO_REMEMBER];
31   uint16_t tick[LED_HITS_TO_REMEMBER];
32 } last_hit_t;
33 #endif // RGB_MATRIX_KEYREACTIVE_ENABLED
34
35 typedef enum rgb_task_states {
36   STARTING,
37   RENDERING,
38   FLUSHING,
39   SYNCING
40 } rgb_task_states;
41
42 typedef uint8_t led_flags_t;
43
44 typedef struct PACKED {
45   uint8_t iter;
46   led_flags_t flags;
47   bool init;
48 } effect_params_t;
49
50 typedef struct PACKED {
51   // Global tick at 20 Hz
52   uint32_t tick;
53   // Ticks since this key was last hit.
54   uint32_t any_key_hit;
55 } rgb_counters_t;
56
57 typedef struct PACKED {
58         uint8_t x;
59         uint8_t y;
60 } point_t;
61
62 typedef union {
63   uint8_t raw;
64   struct {
65     uint8_t row:4; // 16 max
66     uint8_t col:4; // 16 max
67   };
68 } matrix_co_t;
69
70 #define HAS_FLAGS(bits, flags) ((bits & flags) == flags)
71 #define HAS_ANY_FLAGS(bits, flags) ((bits & flags) != 0x00)
72
73 #define LED_FLAG_ALL 0xFF
74 #define LED_FLAG_NONE 0x00
75 #define LED_FLAG_MODIFIER 0x01
76 #define LED_FLAG_UNDERGLOW 0x02
77 #define LED_FLAG_KEYLIGHT 0x04
78
79 typedef struct PACKED {
80   matrix_co_t matrix_co;
81   point_t point;
82   uint8_t flags;
83 } rgb_led;
84
85 typedef union {
86   uint32_t raw;
87   struct PACKED {
88     uint8_t  enable  :2;
89     uint8_t  mode    :6;
90     uint8_t  hue     :8;
91     uint8_t  sat     :8;
92     uint8_t  val     :8;
93     uint8_t  speed   :8;//EECONFIG needs to be increased to support this
94   };
95 } rgb_config_t;
96
97 #if defined(_MSC_VER)
98 #pragma pack( pop )
99 #endif