diff options
Diffstat (limited to 'quantum/rgb_matrix.c')
-rw-r--r-- | quantum/rgb_matrix.c | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/quantum/rgb_matrix.c b/quantum/rgb_matrix.c index ec17b4d72..8aae48603 100644 --- a/quantum/rgb_matrix.c +++ b/quantum/rgb_matrix.c | |||
@@ -131,7 +131,7 @@ last_hit_t g_last_hit_tracker; | |||
131 | // internals | 131 | // internals |
132 | static uint8_t rgb_last_enable = UINT8_MAX; | 132 | static uint8_t rgb_last_enable = UINT8_MAX; |
133 | static uint8_t rgb_last_effect = UINT8_MAX; | 133 | static uint8_t rgb_last_effect = UINT8_MAX; |
134 | static effect_params_t rgb_effect_params = {0, 0xFF}; | 134 | static effect_params_t rgb_effect_params = {0, LED_FLAG_ALL, false}; |
135 | static rgb_task_states rgb_task_state = SYNCING; | 135 | static rgb_task_states rgb_task_state = SYNCING; |
136 | #if RGB_DISABLE_TIMEOUT > 0 | 136 | #if RGB_DISABLE_TIMEOUT > 0 |
137 | static uint32_t rgb_anykey_timer; | 137 | static uint32_t rgb_anykey_timer; |
@@ -143,6 +143,11 @@ static uint32_t rgb_timer_buffer; | |||
143 | static last_hit_t last_hit_buffer; | 143 | static last_hit_t last_hit_buffer; |
144 | #endif // RGB_MATRIX_KEYREACTIVE_ENABLED | 144 | #endif // RGB_MATRIX_KEYREACTIVE_ENABLED |
145 | 145 | ||
146 | // split rgb matrix | ||
147 | #if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) | ||
148 | const uint8_t k_rgb_matrix_split[2] = RGB_MATRIX_SPLIT; | ||
149 | #endif | ||
150 | |||
146 | void eeconfig_read_rgb_matrix(void) { eeprom_read_block(&rgb_matrix_config, EECONFIG_RGB_MATRIX, sizeof(rgb_matrix_config)); } | 151 | void eeconfig_read_rgb_matrix(void) { eeprom_read_block(&rgb_matrix_config, EECONFIG_RGB_MATRIX, sizeof(rgb_matrix_config)); } |
147 | 152 | ||
148 | void eeconfig_update_rgb_matrix(void) { eeprom_update_block(&rgb_matrix_config, EECONFIG_RGB_MATRIX, sizeof(rgb_matrix_config)); } | 153 | void eeconfig_update_rgb_matrix(void) { eeprom_update_block(&rgb_matrix_config, EECONFIG_RGB_MATRIX, sizeof(rgb_matrix_config)); } |
@@ -153,6 +158,7 @@ void eeconfig_update_rgb_matrix_default(void) { | |||
153 | rgb_matrix_config.mode = RGB_MATRIX_STARTUP_MODE; | 158 | rgb_matrix_config.mode = RGB_MATRIX_STARTUP_MODE; |
154 | rgb_matrix_config.hsv = (HSV){RGB_MATRIX_STARTUP_HUE, RGB_MATRIX_STARTUP_SAT, RGB_MATRIX_STARTUP_VAL}; | 159 | rgb_matrix_config.hsv = (HSV){RGB_MATRIX_STARTUP_HUE, RGB_MATRIX_STARTUP_SAT, RGB_MATRIX_STARTUP_VAL}; |
155 | rgb_matrix_config.speed = RGB_MATRIX_STARTUP_SPD; | 160 | rgb_matrix_config.speed = RGB_MATRIX_STARTUP_SPD; |
161 | rgb_matrix_config.flags = LED_FLAG_ALL; | ||
156 | eeconfig_update_rgb_matrix(); | 162 | eeconfig_update_rgb_matrix(); |
157 | } | 163 | } |
158 | 164 | ||
@@ -164,6 +170,7 @@ void eeconfig_debug_rgb_matrix(void) { | |||
164 | dprintf("rgb_matrix_config.hsv.s = %d\n", rgb_matrix_config.hsv.s); | 170 | dprintf("rgb_matrix_config.hsv.s = %d\n", rgb_matrix_config.hsv.s); |
165 | dprintf("rgb_matrix_config.hsv.v = %d\n", rgb_matrix_config.hsv.v); | 171 | dprintf("rgb_matrix_config.hsv.v = %d\n", rgb_matrix_config.hsv.v); |
166 | dprintf("rgb_matrix_config.speed = %d\n", rgb_matrix_config.speed); | 172 | dprintf("rgb_matrix_config.speed = %d\n", rgb_matrix_config.speed); |
173 | dprintf("rgb_matrix_config.flags = %d\n", rgb_matrix_config.flags); | ||
167 | } | 174 | } |
168 | 175 | ||
169 | __attribute__((weak)) uint8_t rgb_matrix_map_row_column_to_led_kb(uint8_t row, uint8_t column, uint8_t *led_i) { return 0; } | 176 | __attribute__((weak)) uint8_t rgb_matrix_map_row_column_to_led_kb(uint8_t row, uint8_t column, uint8_t *led_i) { return 0; } |
@@ -180,9 +187,22 @@ uint8_t rgb_matrix_map_row_column_to_led(uint8_t row, uint8_t column, uint8_t *l | |||
180 | 187 | ||
181 | void rgb_matrix_update_pwm_buffers(void) { rgb_matrix_driver.flush(); } | 188 | void rgb_matrix_update_pwm_buffers(void) { rgb_matrix_driver.flush(); } |
182 | 189 | ||
183 | void rgb_matrix_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) { rgb_matrix_driver.set_color(index, red, green, blue); } | 190 | void rgb_matrix_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) { |
191 | #if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) | ||
192 | if (!is_keyboard_left() && index >= k_rgb_matrix_split[0]) | ||
193 | rgb_matrix_driver.set_color(index - k_rgb_matrix_split[0], red, green, blue); | ||
194 | else if (is_keyboard_left() && index < k_rgb_matrix_split[0]) | ||
195 | #endif | ||
196 | rgb_matrix_driver.set_color(index, red, green, blue); | ||
197 | } | ||
184 | 198 | ||
185 | void rgb_matrix_set_color_all(uint8_t red, uint8_t green, uint8_t blue) { rgb_matrix_driver.set_color_all(red, green, blue); } | 199 | void rgb_matrix_set_color_all(uint8_t red, uint8_t green, uint8_t blue) { |
200 | #if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) | ||
201 | for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) rgb_matrix_set_color(i, red, green, blue); | ||
202 | #else | ||
203 | rgb_matrix_driver.set_color_all(red, green, blue); | ||
204 | #endif | ||
205 | } | ||
186 | 206 | ||
187 | void process_rgb_matrix(uint8_t row, uint8_t col, bool pressed) { | 207 | void process_rgb_matrix(uint8_t row, uint8_t col, bool pressed) { |
188 | #ifndef RGB_MATRIX_SPLIT | 208 | #ifndef RGB_MATRIX_SPLIT |
@@ -315,6 +335,10 @@ static void rgb_task_start(void) { | |||
315 | static void rgb_task_render(uint8_t effect) { | 335 | static void rgb_task_render(uint8_t effect) { |
316 | bool rendering = false; | 336 | bool rendering = false; |
317 | rgb_effect_params.init = (effect != rgb_last_effect) || (rgb_matrix_config.enable != rgb_last_enable); | 337 | rgb_effect_params.init = (effect != rgb_last_effect) || (rgb_matrix_config.enable != rgb_last_enable); |
338 | if (rgb_effect_params.flags != rgb_matrix_config.flags) { | ||
339 | rgb_effect_params.flags = rgb_matrix_config.flags; | ||
340 | rgb_matrix_set_color_all(0, 0, 0); | ||
341 | } | ||
318 | 342 | ||
319 | // each effect can opt to do calculations | 343 | // each effect can opt to do calculations |
320 | // and/or request PWM buffer updates. | 344 | // and/or request PWM buffer updates. |
@@ -618,6 +642,6 @@ void rgb_matrix_decrease_speed_helper(bool write_to_eeprom) { rgb_matrix_set_spe | |||
618 | void rgb_matrix_decrease_speed_noeeprom(void) { rgb_matrix_decrease_speed_helper(false); } | 642 | void rgb_matrix_decrease_speed_noeeprom(void) { rgb_matrix_decrease_speed_helper(false); } |
619 | void rgb_matrix_decrease_speed(void) { rgb_matrix_decrease_speed_helper(true); } | 643 | void rgb_matrix_decrease_speed(void) { rgb_matrix_decrease_speed_helper(true); } |
620 | 644 | ||
621 | led_flags_t rgb_matrix_get_flags(void) { return rgb_effect_params.flags; } | 645 | led_flags_t rgb_matrix_get_flags(void) { return rgb_matrix_config.flags; } |
622 | 646 | ||
623 | void rgb_matrix_set_flags(led_flags_t flags) { rgb_effect_params.flags = flags; } | 647 | void rgb_matrix_set_flags(led_flags_t flags) { rgb_matrix_config.flags = flags; } |