Commit | Line | Data |
---|---|---|
c98247e3 X |
1 | #pragma once |
2 | ||
3 | #include <stdint.h> | |
4 | #include <stdbool.h> | |
cf215487 | 5 | #include "color.h" |
c98247e3 X |
6 | |
7 | #if defined(__GNUC__) | |
b624f32f | 8 | # define PACKED __attribute__((__packed__)) |
c98247e3 | 9 | #else |
b624f32f | 10 | # define PACKED |
c98247e3 X |
11 | #endif |
12 | ||
13 | #if defined(_MSC_VER) | |
b624f32f | 14 | # pragma pack(push, 1) |
c98247e3 X |
15 | #endif |
16 | ||
17 | #if defined(RGB_MATRIX_KEYPRESSES) || defined(RGB_MATRIX_KEYRELEASES) | |
b624f32f | 18 | # define RGB_MATRIX_KEYREACTIVE_ENABLED |
c98247e3 X |
19 | #endif |
20 | ||
21 | // Last led hit | |
22 | #ifndef LED_HITS_TO_REMEMBER | |
b624f32f | 23 | # define LED_HITS_TO_REMEMBER 8 |
24 | #endif // LED_HITS_TO_REMEMBER | |
c98247e3 X |
25 | |
26 | #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED | |
27 | typedef struct PACKED { | |
b624f32f | 28 | uint8_t count; |
29 | uint8_t x[LED_HITS_TO_REMEMBER]; | |
30 | uint8_t y[LED_HITS_TO_REMEMBER]; | |
31 | uint8_t index[LED_HITS_TO_REMEMBER]; | |
32 | uint16_t tick[LED_HITS_TO_REMEMBER]; | |
c98247e3 | 33 | } last_hit_t; |
b624f32f | 34 | #endif // RGB_MATRIX_KEYREACTIVE_ENABLED |
c98247e3 | 35 | |
b624f32f | 36 | typedef enum rgb_task_states { STARTING, RENDERING, FLUSHING, SYNCING } rgb_task_states; |
c98247e3 X |
37 | |
38 | typedef uint8_t led_flags_t; | |
39 | ||
40 | typedef struct PACKED { | |
b624f32f | 41 | uint8_t iter; |
42 | led_flags_t flags; | |
43 | bool init; | |
c98247e3 X |
44 | } effect_params_t; |
45 | ||
46 | typedef struct PACKED { | |
b624f32f | 47 | // Global tick at 20 Hz |
48 | uint32_t tick; | |
49 | // Ticks since this key was last hit. | |
50 | uint32_t any_key_hit; | |
c98247e3 X |
51 | } rgb_counters_t; |
52 | ||
53 | typedef struct PACKED { | |
b624f32f | 54 | uint8_t x; |
55 | uint8_t y; | |
c98247e3 X |
56 | } point_t; |
57 | ||
a7113c8e X |
58 | #define HAS_FLAGS(bits, flags) ((bits & flags) == flags) |
59 | #define HAS_ANY_FLAGS(bits, flags) ((bits & flags) != 0x00) | |
60 | ||
61 | #define LED_FLAG_ALL 0xFF | |
62 | #define LED_FLAG_NONE 0x00 | |
63 | #define LED_FLAG_MODIFIER 0x01 | |
64 | #define LED_FLAG_UNDERGLOW 0x02 | |
65 | #define LED_FLAG_KEYLIGHT 0x04 | |
66 | ||
af89752b X |
67 | #define NO_LED 255 |
68 | ||
c98247e3 | 69 | typedef struct PACKED { |
b624f32f | 70 | uint8_t matrix_co[MATRIX_ROWS][MATRIX_COLS]; |
71 | point_t point[DRIVER_LED_TOTAL]; | |
72 | uint8_t flags[DRIVER_LED_TOTAL]; | |
af89752b | 73 | } led_config_t; |
c98247e3 X |
74 | |
75 | typedef union { | |
b624f32f | 76 | uint32_t raw; |
77 | struct PACKED { | |
78 | uint8_t enable : 2; | |
79 | uint8_t mode : 6; | |
80 | HSV hsv; | |
81 | uint8_t speed; // EECONFIG needs to be increased to support this | |
82 | }; | |
c98247e3 X |
83 | } rgb_config_t; |
84 | ||
85 | #if defined(_MSC_VER) | |
b624f32f | 86 | # pragma pack(pop) |
c98247e3 | 87 | #endif |