diff options
| author | XScorpion2 <rcalt2vt@gmail.com> | 2019-04-30 00:18:50 +0200 |
|---|---|---|
| committer | MechMerlin <30334081+mechmerlin@users.noreply.github.com> | 2019-04-29 15:18:50 -0700 |
| commit | a7113c8ed090d0ac647f30ee9b8ef41252e568ed (patch) | |
| tree | 24d33db679b4d1357efef2784e69fea48e98d0ed /quantum/rgb_matrix.c | |
| parent | 1d784f0f9575b70e35c9c8338b0ff80dc7316d7e (diff) | |
| download | qmk_firmware-a7113c8ed090d0ac647f30ee9b8ef41252e568ed.tar.gz qmk_firmware-a7113c8ed090d0ac647f30ee9b8ef41252e568ed.zip | |
Updated rgb_led struct field modifier to flags (#5619)
Updated effects to test led flags
Updated massdrop to use new flags field for led toggle
Diffstat (limited to 'quantum/rgb_matrix.c')
| -rw-r--r-- | quantum/rgb_matrix.c | 45 |
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 | ||
| 164 | void rgb_matrix_set_color( int index, uint8_t red, uint8_t green, uint8_t blue ) { | 164 | void 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 | ||
| 179 | void rgb_matrix_set_color_all( uint8_t red, uint8_t green, uint8_t blue ) { | 168 | void 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 | ||
| 189 | bool process_rgb_matrix(uint16_t keycode, keyrecord_t *record) { | 172 | bool process_rgb_matrix(uint16_t keycode, keyrecord_t *record) { |
| @@ -262,7 +245,7 @@ static bool rgb_matrix_none(effect_params_t* params) { | |||
| 262 | 245 | ||
| 263 | static uint8_t rgb_last_enable = UINT8_MAX; | 246 | static uint8_t rgb_last_enable = UINT8_MAX; |
| 264 | static uint8_t rgb_last_effect = UINT8_MAX; | 247 | static uint8_t rgb_last_effect = UINT8_MAX; |
| 265 | static effect_params_t rgb_effect_params = { 0, 0 }; | 248 | static effect_params_t rgb_effect_params = { 0, 0xFF }; |
| 266 | static rgb_task_states rgb_task_state = SYNCING; | 249 | static rgb_task_states rgb_task_state = SYNCING; |
| 267 | 250 | ||
| 268 | static void rgb_task_timers(void) { | 251 | static void rgb_task_timers(void) { |
| @@ -575,29 +558,31 @@ void rgb_matrix_set_suspend_state(bool state) { | |||
| 575 | } | 558 | } |
| 576 | 559 | ||
| 577 | void rgb_matrix_toggle(void) { | 560 | void 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 | ||
| 585 | void rgb_matrix_enable(void) { | 566 | void 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 | ||
| 590 | void rgb_matrix_enable_noeeprom(void) { | 571 | void 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 | ||
| 594 | void rgb_matrix_disable(void) { | 577 | void 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 | ||
| 599 | void rgb_matrix_disable_noeeprom(void) { | 582 | void 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 | ||
| 603 | void rgb_matrix_step(void) { | 588 | void 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 | ||
| 646 | led_flags_t rgb_matrix_get_flags(void) { | ||
| 647 | return rgb_effect_params.flags; | ||
| 648 | } | ||
| 649 | |||
| 650 | void rgb_matrix_set_flags(led_flags_t flags) { | ||
| 651 | rgb_effect_params.flags = flags; | ||
| 652 | } | ||
| 653 | |||
| 661 | void rgb_matrix_mode(uint8_t mode) { | 654 | void 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; |
