diff options
Diffstat (limited to 'quantum/led_matrix/led_matrix.h')
-rw-r--r-- | quantum/led_matrix/led_matrix.h | 160 |
1 files changed, 160 insertions, 0 deletions
diff --git a/quantum/led_matrix/led_matrix.h b/quantum/led_matrix/led_matrix.h new file mode 100644 index 000000000..6f85854fb --- /dev/null +++ b/quantum/led_matrix/led_matrix.h | |||
@@ -0,0 +1,160 @@ | |||
1 | /* Copyright 2017 Jason Williams | ||
2 | * Copyright 2017 Jack Humbert | ||
3 | * Copyright 2018 Yiancar | ||
4 | * Copyright 2019 Clueboard | ||
5 | * | ||
6 | * This program is free software: you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation, either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
18 | */ | ||
19 | |||
20 | #pragma once | ||
21 | |||
22 | #include <stdint.h> | ||
23 | #include <stdbool.h> | ||
24 | #include "led_matrix_types.h" | ||
25 | #include "quantum.h" | ||
26 | |||
27 | #ifdef IS31FL3731 | ||
28 | # include "is31fl3731-simple.h" | ||
29 | #endif | ||
30 | |||
31 | #ifndef LED_MATRIX_LED_FLUSH_LIMIT | ||
32 | # define LED_MATRIX_LED_FLUSH_LIMIT 16 | ||
33 | #endif | ||
34 | |||
35 | #ifndef LED_MATRIX_LED_PROCESS_LIMIT | ||
36 | # define LED_MATRIX_LED_PROCESS_LIMIT (DRIVER_LED_TOTAL + 4) / 5 | ||
37 | #endif | ||
38 | |||
39 | #if defined(LED_MATRIX_LED_PROCESS_LIMIT) && LED_MATRIX_LED_PROCESS_LIMIT > 0 && LED_MATRIX_LED_PROCESS_LIMIT < DRIVER_LED_TOTAL | ||
40 | # define LED_MATRIX_USE_LIMITS(min, max) \ | ||
41 | uint8_t min = LED_MATRIX_LED_PROCESS_LIMIT * params->iter; \ | ||
42 | uint8_t max = min + LED_MATRIX_LED_PROCESS_LIMIT; \ | ||
43 | if (max > DRIVER_LED_TOTAL) max = DRIVER_LED_TOTAL; | ||
44 | #else | ||
45 | # define LED_MATRIX_USE_LIMITS(min, max) \ | ||
46 | uint8_t min = 0; \ | ||
47 | uint8_t max = DRIVER_LED_TOTAL; | ||
48 | #endif | ||
49 | |||
50 | #define LED_MATRIX_TEST_LED_FLAGS() \ | ||
51 | if (!HAS_ANY_FLAGS(g_led_config.flags[i], params->flags)) continue | ||
52 | |||
53 | enum led_matrix_effects { | ||
54 | LED_MATRIX_NONE = 0, | ||
55 | |||
56 | // -------------------------------------- | ||
57 | // -----Begin led effect enum macros----- | ||
58 | #define LED_MATRIX_EFFECT(name, ...) LED_MATRIX_##name, | ||
59 | #include "led_matrix_effects.inc" | ||
60 | #undef LED_MATRIX_EFFECT | ||
61 | |||
62 | #if defined(LED_MATRIX_CUSTOM_KB) || defined(LED_MATRIX_CUSTOM_USER) | ||
63 | # define LED_MATRIX_EFFECT(name, ...) LED_MATRIX_CUSTOM_##name, | ||
64 | # ifdef LED_MATRIX_CUSTOM_KB | ||
65 | # include "led_matrix_kb.inc" | ||
66 | # endif | ||
67 | # ifdef LED_MATRIX_CUSTOM_USER | ||
68 | # include "led_matrix_user.inc" | ||
69 | # endif | ||
70 | # undef LED_MATRIX_EFFECT | ||
71 | #endif | ||
72 | // -------------------------------------- | ||
73 | // -----End led effect enum macros------- | ||
74 | |||
75 | LED_MATRIX_EFFECT_MAX | ||
76 | }; | ||
77 | |||
78 | void eeconfig_update_led_matrix_default(void); | ||
79 | void eeconfig_update_led_matrix(void); | ||
80 | void eeconfig_debug_led_matrix(void); | ||
81 | |||
82 | uint8_t led_matrix_map_row_column_to_led_kb(uint8_t row, uint8_t column, uint8_t *led_i); | ||
83 | uint8_t led_matrix_map_row_column_to_led(uint8_t row, uint8_t column, uint8_t *led_i); | ||
84 | |||
85 | void led_matrix_set_value(int index, uint8_t value); | ||
86 | void led_matrix_set_value_all(uint8_t value); | ||
87 | |||
88 | void process_led_matrix(uint8_t row, uint8_t col, bool pressed); | ||
89 | |||
90 | void led_matrix_task(void); | ||
91 | |||
92 | // This runs after another backlight effect and replaces | ||
93 | // values already set | ||
94 | void led_matrix_indicators(void); | ||
95 | void led_matrix_indicators_kb(void); | ||
96 | void led_matrix_indicators_user(void); | ||
97 | |||
98 | void led_matrix_indicators_advanced(effect_params_t *params); | ||
99 | void led_matrix_indicators_advanced_kb(uint8_t led_min, uint8_t led_max); | ||
100 | void led_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max); | ||
101 | |||
102 | void led_matrix_init(void); | ||
103 | |||
104 | void led_matrix_set_suspend_state(bool state); | ||
105 | bool led_matrix_get_suspend_state(void); | ||
106 | void led_matrix_toggle(void); | ||
107 | void led_matrix_toggle_noeeprom(void); | ||
108 | void led_matrix_enable(void); | ||
109 | void led_matrix_enable_noeeprom(void); | ||
110 | void led_matrix_disable(void); | ||
111 | void led_matrix_disable_noeeprom(void); | ||
112 | uint8_t led_matrix_is_enabled(void); | ||
113 | void led_matrix_mode(uint8_t mode); | ||
114 | void led_matrix_mode_noeeprom(uint8_t mode); | ||
115 | uint8_t led_matrix_get_mode(void); | ||
116 | void led_matrix_step(void); | ||
117 | void led_matrix_step_noeeprom(void); | ||
118 | void led_matrix_step_reverse(void); | ||
119 | void led_matrix_step_reverse_noeeprom(void); | ||
120 | void led_matrix_set_val(uint8_t val); | ||
121 | void led_matrix_set_val_noeeprom(uint8_t val); | ||
122 | uint8_t led_matrix_get_val(void); | ||
123 | void led_matrix_increase_val(void); | ||
124 | void led_matrix_increase_val_noeeprom(void); | ||
125 | void led_matrix_decrease_val(void); | ||
126 | void led_matrix_decrease_val_noeeprom(void); | ||
127 | void led_matrix_set_speed(uint8_t speed); | ||
128 | void led_matrix_set_speed_noeeprom(uint8_t speed); | ||
129 | uint8_t led_matrix_get_speed(void); | ||
130 | void led_matrix_increase_speed(void); | ||
131 | void led_matrix_increase_speed_noeeprom(void); | ||
132 | void led_matrix_decrease_speed(void); | ||
133 | void led_matrix_decrease_speed_noeeprom(void); | ||
134 | led_flags_t led_matrix_get_flags(void); | ||
135 | void led_matrix_set_flags(led_flags_t flags); | ||
136 | |||
137 | typedef struct { | ||
138 | /* Perform any initialisation required for the other driver functions to work. */ | ||
139 | void (*init)(void); | ||
140 | |||
141 | /* Set the brightness of a single LED in the buffer. */ | ||
142 | void (*set_value)(int index, uint8_t value); | ||
143 | /* Set the brightness of all LEDS on the keyboard in the buffer. */ | ||
144 | void (*set_value_all)(uint8_t value); | ||
145 | /* Flush any buffered changes to the hardware. */ | ||
146 | void (*flush)(void); | ||
147 | } led_matrix_driver_t; | ||
148 | |||
149 | extern const led_matrix_driver_t led_matrix_driver; | ||
150 | |||
151 | extern led_eeconfig_t led_matrix_eeconfig; | ||
152 | |||
153 | extern uint32_t g_led_timer; | ||
154 | extern led_config_t g_led_config; | ||
155 | #ifdef LED_MATRIX_KEYREACTIVE_ENABLED | ||
156 | extern last_hit_t g_last_hit_tracker; | ||
157 | #endif | ||
158 | #ifdef LED_MATRIX_FRAMEBUFFER_EFFECTS | ||
159 | extern uint8_t g_led_frame_buffer[MATRIX_ROWS][MATRIX_COLS]; | ||
160 | #endif | ||