diff options
Diffstat (limited to 'quantum/led_matrix.h')
-rw-r--r-- | quantum/led_matrix.h | 127 |
1 files changed, 89 insertions, 38 deletions
diff --git a/quantum/led_matrix.h b/quantum/led_matrix.h index 85bae43c1..f35bbe209 100644 --- a/quantum/led_matrix.h +++ b/quantum/led_matrix.h | |||
@@ -19,61 +19,104 @@ | |||
19 | 19 | ||
20 | #pragma once | 20 | #pragma once |
21 | 21 | ||
22 | #include <stdint.h> | ||
23 | #include <stdbool.h> | ||
22 | #include "led_matrix_types.h" | 24 | #include "led_matrix_types.h" |
25 | #include "quantum.h" | ||
23 | 26 | ||
24 | #ifndef BACKLIGHT_ENABLE | 27 | #ifdef IS31FL3731 |
25 | # error You must define BACKLIGHT_ENABLE with LED_MATRIX_ENABLE | 28 | # include "is31fl3731-simple.h" |
26 | #endif | 29 | #endif |
27 | 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 | |||
28 | enum led_matrix_effects { | 53 | enum led_matrix_effects { |
29 | LED_MATRIX_UNIFORM_BRIGHTNESS = 1, | 54 | LED_MATRIX_NONE = 0, |
55 | |||
56 | LED_MATRIX_UNIFORM_BRIGHTNESS, | ||
30 | // All new effects go above this line | 57 | // All new effects go above this line |
58 | |||
31 | LED_MATRIX_EFFECT_MAX | 59 | LED_MATRIX_EFFECT_MAX |
32 | }; | 60 | }; |
33 | 61 | ||
34 | void led_matrix_set_index_value(int index, uint8_t value); | 62 | void eeconfig_update_led_matrix_default(void); |
35 | void led_matrix_set_index_value_all(uint8_t value); | 63 | void eeconfig_update_led_matrix(void); |
64 | void eeconfig_debug_led_matrix(void); | ||
65 | |||
66 | uint8_t led_matrix_map_row_column_to_led_kb(uint8_t row, uint8_t column, uint8_t *led_i); | ||
67 | uint8_t led_matrix_map_row_column_to_led(uint8_t row, uint8_t column, uint8_t *led_i); | ||
68 | |||
69 | void led_matrix_set_value(int index, uint8_t value); | ||
70 | void led_matrix_set_value_all(uint8_t value); | ||
71 | |||
72 | void process_led_matrix(uint8_t row, uint8_t col, bool pressed); | ||
73 | |||
74 | void led_matrix_task(void); | ||
36 | 75 | ||
37 | // This runs after another backlight effect and replaces | 76 | // This runs after another backlight effect and replaces |
38 | // colors already set | 77 | // values already set |
39 | void led_matrix_indicators(void); | 78 | void led_matrix_indicators(void); |
40 | void led_matrix_indicators_kb(void); | 79 | void led_matrix_indicators_kb(void); |
41 | void led_matrix_indicators_user(void); | 80 | void led_matrix_indicators_user(void); |
42 | 81 | ||
43 | void led_matrix_init(void); | 82 | void led_matrix_indicators_advanced(effect_params_t *params); |
44 | void led_matrix_setup_drivers(void); | 83 | void led_matrix_indicators_advanced_kb(uint8_t led_min, uint8_t led_max); |
45 | 84 | void led_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max); | |
46 | void led_matrix_set_suspend_state(bool state); | ||
47 | void led_matrix_set_indicator_state(uint8_t state); | ||
48 | 85 | ||
49 | void led_matrix_task(void); | 86 | void led_matrix_init(void); |
50 | 87 | ||
51 | // This should not be called from an interrupt | 88 | void led_matrix_set_suspend_state(bool state); |
52 | // (eg. from a timer interrupt). | 89 | bool led_matrix_get_suspend_state(void); |
53 | // Call this while idle (in between matrix scans). | 90 | void led_matrix_toggle(void); |
54 | // If the buffer is dirty, it will update the driver with the buffer. | 91 | void led_matrix_toggle_noeeprom(void); |
55 | void led_matrix_update_pwm_buffers(void); | 92 | void led_matrix_enable(void); |
56 | 93 | void led_matrix_enable_noeeprom(void); | |
57 | bool process_led_matrix(uint16_t keycode, keyrecord_t *record); | 94 | void led_matrix_disable(void); |
58 | 95 | void led_matrix_disable_noeeprom(void); | |
59 | uint32_t led_matrix_get_tick(void); | 96 | uint8_t led_matrix_is_enabled(void); |
60 | 97 | void led_matrix_mode(uint8_t mode); | |
61 | void led_matrix_toggle(void); | 98 | void led_matrix_mode_noeeprom(uint8_t mode); |
62 | void led_matrix_enable(void); | 99 | uint8_t led_matrix_get_mode(void); |
63 | void led_matrix_enable_noeeprom(void); | 100 | void led_matrix_step(void); |
64 | void led_matrix_disable(void); | 101 | void led_matrix_step_noeeprom(void); |
65 | void led_matrix_disable_noeeprom(void); | 102 | void led_matrix_step_reverse(void); |
66 | void led_matrix_step(void); | 103 | void led_matrix_step_reverse_noeeprom(void); |
67 | void led_matrix_step_reverse(void); | 104 | void led_matrix_set_val(uint8_t val); |
68 | void led_matrix_increase_val(void); | 105 | void led_matrix_set_val_noeeprom(uint8_t val); |
69 | void led_matrix_decrease_val(void); | 106 | uint8_t led_matrix_get_val(void); |
70 | void led_matrix_increase_speed(void); | 107 | void led_matrix_increase_val(void); |
71 | void led_matrix_decrease_speed(void); | 108 | void led_matrix_increase_val_noeeprom(void); |
72 | void led_matrix_mode(uint8_t mode, bool eeprom_write); | 109 | void led_matrix_decrease_val(void); |
73 | void led_matrix_mode_noeeprom(uint8_t mode); | 110 | void led_matrix_decrease_val_noeeprom(void); |
74 | uint8_t led_matrix_get_mode(void); | 111 | void led_matrix_set_speed(uint8_t speed); |
75 | void led_matrix_set_value(uint8_t mode); | 112 | void led_matrix_set_speed_noeeprom(uint8_t speed); |
76 | void led_matrix_set_value_noeeprom(uint8_t mode); | 113 | uint8_t led_matrix_get_speed(void); |
114 | void led_matrix_increase_speed(void); | ||
115 | void led_matrix_increase_speed_noeeprom(void); | ||
116 | void led_matrix_decrease_speed(void); | ||
117 | void led_matrix_decrease_speed_noeeprom(void); | ||
118 | led_flags_t led_matrix_get_flags(void); | ||
119 | void led_matrix_set_flags(led_flags_t flags); | ||
77 | 120 | ||
78 | typedef struct { | 121 | typedef struct { |
79 | /* Perform any initialisation required for the other driver functions to work. */ | 122 | /* Perform any initialisation required for the other driver functions to work. */ |
@@ -91,4 +134,12 @@ extern const led_matrix_driver_t led_matrix_driver; | |||
91 | 134 | ||
92 | extern led_eeconfig_t led_matrix_eeconfig; | 135 | extern led_eeconfig_t led_matrix_eeconfig; |
93 | 136 | ||
137 | extern bool g_suspend_state; | ||
138 | extern uint32_t g_led_timer; | ||
94 | extern led_config_t g_led_config; | 139 | extern led_config_t g_led_config; |
140 | #ifdef LED_MATRIX_KEYREACTIVE_ENABLED | ||
141 | extern last_hit_t g_last_hit_tracker; | ||
142 | #endif | ||
143 | #ifdef LED_MATRIX_FRAMEBUFFER_EFFECTS | ||
144 | extern uint8_t g_led_frame_buffer[MATRIX_ROWS][MATRIX_COLS]; | ||
145 | #endif | ||