aboutsummaryrefslogtreecommitdiff
path: root/quantum/rgb_matrix.c
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/rgb_matrix.c')
-rw-r--r--quantum/rgb_matrix.c45
1 files changed, 19 insertions, 26 deletions
diff --git a/quantum/rgb_matrix.c b/quantum/rgb_matrix.c
index 5ca9b87a6..8c16c7790 100644
--- a/quantum/rgb_matrix.c
+++ b/quantum/rgb_matrix.c
@@ -162,28 +162,11 @@ void rgb_matrix_update_pwm_buffers(void) {
162} 162}
163 163
164void rgb_matrix_set_color( int index, uint8_t red, uint8_t green, uint8_t blue ) { 164void rgb_matrix_set_color( int index, uint8_t red, uint8_t green, uint8_t blue ) {
165#ifdef RGB_MATRIX_EXTRA_TOG
166 const bool is_key = g_rgb_leds[index].matrix_co.raw != 0xff;
167 if (
168 (rgb_matrix_config.enable == RGB_ZONE_KEYS && !is_key) ||
169 (rgb_matrix_config.enable == RGB_ZONE_UNDER && is_key)
170 ) {
171 rgb_matrix_driver.set_color(index, 0, 0, 0);
172 return;
173 }
174#endif
175
176 rgb_matrix_driver.set_color(index, red, green, blue); 165 rgb_matrix_driver.set_color(index, red, green, blue);
177} 166}
178 167
179void rgb_matrix_set_color_all( uint8_t red, uint8_t green, uint8_t blue ) { 168void rgb_matrix_set_color_all( uint8_t red, uint8_t green, uint8_t blue ) {
180#ifdef RGB_MATRIX_EXTRA_TOG
181 for (int i = 0; i < DRIVER_LED_TOTAL; i++) {
182 rgb_matrix_set_color(i, red, green, blue);
183 }
184#else
185 rgb_matrix_driver.set_color_all(red, green, blue); 169 rgb_matrix_driver.set_color_all(red, green, blue);
186#endif
187} 170}
188 171
189bool process_rgb_matrix(uint16_t keycode, keyrecord_t *record) { 172bool process_rgb_matrix(uint16_t keycode, keyrecord_t *record) {
@@ -262,7 +245,7 @@ static bool rgb_matrix_none(effect_params_t* params) {
262 245
263static uint8_t rgb_last_enable = UINT8_MAX; 246static uint8_t rgb_last_enable = UINT8_MAX;
264static uint8_t rgb_last_effect = UINT8_MAX; 247static uint8_t rgb_last_effect = UINT8_MAX;
265static effect_params_t rgb_effect_params = { 0, 0 }; 248static effect_params_t rgb_effect_params = { 0, 0xFF };
266static rgb_task_states rgb_task_state = SYNCING; 249static rgb_task_states rgb_task_state = SYNCING;
267 250
268static void rgb_task_timers(void) { 251static void rgb_task_timers(void) {
@@ -575,29 +558,31 @@ void rgb_matrix_set_suspend_state(bool state) {
575} 558}
576 559
577void rgb_matrix_toggle(void) { 560void rgb_matrix_toggle(void) {
578 rgb_matrix_config.enable++; 561 rgb_matrix_config.enable ^= 1;
579 if (!rgb_matrix_config.enable) { 562 rgb_task_state = STARTING;
580 rgb_task_state = STARTING;
581 }
582 eeconfig_update_rgb_matrix(rgb_matrix_config.raw); 563 eeconfig_update_rgb_matrix(rgb_matrix_config.raw);
583} 564}
584 565
585void rgb_matrix_enable(void) { 566void rgb_matrix_enable(void) {
586 rgb_matrix_config.enable = 1; 567 rgb_matrix_enable_noeeprom();
587 eeconfig_update_rgb_matrix(rgb_matrix_config.raw); 568 eeconfig_update_rgb_matrix(rgb_matrix_config.raw);
588} 569}
589 570
590void rgb_matrix_enable_noeeprom(void) { 571void rgb_matrix_enable_noeeprom(void) {
591 rgb_matrix_config.enable = 1; 572 if (!rgb_matrix_config.enable)
573 rgb_task_state = STARTING;
574 rgb_matrix_config.enable = 1;
592} 575}
593 576
594void rgb_matrix_disable(void) { 577void rgb_matrix_disable(void) {
595 rgb_matrix_config.enable = 0; 578 rgb_matrix_disable_noeeprom();
596 eeconfig_update_rgb_matrix(rgb_matrix_config.raw); 579 eeconfig_update_rgb_matrix(rgb_matrix_config.raw);
597} 580}
598 581
599void rgb_matrix_disable_noeeprom(void) { 582void rgb_matrix_disable_noeeprom(void) {
600 rgb_matrix_config.enable = 0; 583 if (rgb_matrix_config.enable)
584 rgb_task_state = STARTING;
585 rgb_matrix_config.enable = 0;
601} 586}
602 587
603void rgb_matrix_step(void) { 588void rgb_matrix_step(void) {
@@ -658,6 +643,14 @@ void rgb_matrix_decrease_speed(void) {
658 eeconfig_update_rgb_matrix(rgb_matrix_config.raw);//EECONFIG needs to be increased to support this 643 eeconfig_update_rgb_matrix(rgb_matrix_config.raw);//EECONFIG needs to be increased to support this
659} 644}
660 645
646led_flags_t rgb_matrix_get_flags(void) {
647 return rgb_effect_params.flags;
648}
649
650void rgb_matrix_set_flags(led_flags_t flags) {
651 rgb_effect_params.flags = flags;
652}
653
661void rgb_matrix_mode(uint8_t mode) { 654void rgb_matrix_mode(uint8_t mode) {
662 rgb_matrix_config.mode = mode; 655 rgb_matrix_config.mode = mode;
663 rgb_task_state = STARTING; 656 rgb_task_state = STARTING;