aboutsummaryrefslogtreecommitdiff
path: root/quantum/rgb_matrix.c
diff options
context:
space:
mode:
authorErez Zukerman <bulk@ezuk.org>2018-07-03 14:06:36 -0400
committerGitHub <noreply@github.com>2018-07-03 14:06:36 -0400
commit9c2dde98e2b963704eb7cb87f6c53c52599fba53 (patch)
treeced26f98b401d83aee69a6ee3b17bf9fbc6ad556 /quantum/rgb_matrix.c
parenta7df902734b6aa8975e3a62a07ddb5544fd4ae85 (diff)
parent08283f61244479743c4ff5ecba39bd0264979d77 (diff)
downloadqmk_firmware-9c2dde98e2b963704eb7cb87f6c53c52599fba53.tar.gz
qmk_firmware-9c2dde98e2b963704eb7cb87f6c53c52599fba53.zip
Merge pull request #3229 from qmk/hf/shinydox
Adds I2C timeout and return values, adds support for future RGB Ergodox EZ
Diffstat (limited to 'quantum/rgb_matrix.c')
-rw-r--r--quantum/rgb_matrix.c78
1 files changed, 40 insertions, 38 deletions
diff --git a/quantum/rgb_matrix.c b/quantum/rgb_matrix.c
index b7424d637..b4bbc3dc0 100644
--- a/quantum/rgb_matrix.c
+++ b/quantum/rgb_matrix.c
@@ -105,7 +105,6 @@ void map_row_column_to_led( uint8_t row, uint8_t column, uint8_t *led_i, uint8_t
105 } 105 }
106} 106}
107 107
108
109void rgb_matrix_update_pwm_buffers(void) { 108void rgb_matrix_update_pwm_buffers(void) {
110 IS31FL3731_update_pwm_buffers( DRIVER_ADDR_1, DRIVER_ADDR_2 ); 109 IS31FL3731_update_pwm_buffers( DRIVER_ADDR_1, DRIVER_ADDR_2 );
111 IS31FL3731_update_led_control_registers( DRIVER_ADDR_1, DRIVER_ADDR_2 ); 110 IS31FL3731_update_led_control_registers( DRIVER_ADDR_1, DRIVER_ADDR_2 );
@@ -119,7 +118,6 @@ void rgb_matrix_set_color_all( uint8_t red, uint8_t green, uint8_t blue ) {
119 IS31FL3731_set_color_all( red, green, blue ); 118 IS31FL3731_set_color_all( red, green, blue );
120} 119}
121 120
122
123bool process_rgb_matrix(uint16_t keycode, keyrecord_t *record) { 121bool process_rgb_matrix(uint16_t keycode, keyrecord_t *record) {
124 if ( record->event.pressed ) { 122 if ( record->event.pressed ) {
125 uint8_t led[8], led_count; 123 uint8_t led[8], led_count;
@@ -222,7 +220,7 @@ void rgb_matrix_single_LED_test(void) {
222} 220}
223 221
224// All LEDs off 222// All LEDs off
225void rgb_matrix_all_off(void) { 223void rgb_matrix_all_off(void) {
226 rgb_matrix_set_color_all( 0, 0, 0 ); 224 rgb_matrix_set_color_all( 0, 0, 0 );
227} 225}
228 226
@@ -248,7 +246,7 @@ void rgb_matrix_solid_reactive(void) {
248 246
249// alphas = color1, mods = color2 247// alphas = color1, mods = color2
250void rgb_matrix_alphas_mods(void) { 248void rgb_matrix_alphas_mods(void) {
251 249
252 RGB rgb1 = hsv_to_rgb( (HSV){ .h = rgb_matrix_config.hue, .s = rgb_matrix_config.sat, .v = rgb_matrix_config.val } ); 250 RGB rgb1 = hsv_to_rgb( (HSV){ .h = rgb_matrix_config.hue, .s = rgb_matrix_config.sat, .v = rgb_matrix_config.val } );
253 RGB rgb2 = hsv_to_rgb( (HSV){ .h = (rgb_matrix_config.hue + 180) % 360, .s = rgb_matrix_config.sat, .v = rgb_matrix_config.val } ); 251 RGB rgb2 = hsv_to_rgb( (HSV){ .h = (rgb_matrix_config.hue + 180) % 360, .s = rgb_matrix_config.sat, .v = rgb_matrix_config.val } );
254 252
@@ -726,40 +724,44 @@ void rgb_matrix_indicators_user(void) {}
726// } 724// }
727// } 725// }
728 726
729void rgb_matrix_init_drivers(void) { 727void rgb_matrix_init(void) {
730 // Initialize TWI 728 rgb_matrix_setup_drivers();
731 i2c_init(); 729
732 IS31FL3731_init( DRIVER_ADDR_1 ); 730 // TODO: put the 1 second startup delay here?
733 IS31FL3731_init( DRIVER_ADDR_2 ); 731
734 732 // clear the key hits
735 for ( int index = 0; index < DRIVER_LED_TOTAL; index++ ) { 733 for ( int led=0; led<DRIVER_LED_TOTAL; led++ ) {
736 bool enabled = true; 734 g_key_hit[led] = 255;
737 // This only caches it for later 735 }
738 IS31FL3731_set_led_control_register( index, enabled, enabled, enabled ); 736
739 } 737
740 // This actually updates the LED drivers 738 if (!eeconfig_is_enabled()) {
741 IS31FL3731_update_led_control_registers( DRIVER_ADDR_1, DRIVER_ADDR_2 ); 739 dprintf("rgb_matrix_init_drivers eeconfig is not enabled.\n");
742 740 eeconfig_init();
743 // TODO: put the 1 second startup delay here? 741 eeconfig_update_rgb_matrix_default();
744 742 }
745 // clear the key hits 743 rgb_matrix_config.raw = eeconfig_read_rgb_matrix();
746 for ( int led=0; led<DRIVER_LED_TOTAL; led++ ) { 744 if (!rgb_matrix_config.mode) {
747 g_key_hit[led] = 255; 745 dprintf("rgb_matrix_init_drivers rgb_matrix_config.mode = 0. Write default values to EEPROM.\n");
748 } 746 eeconfig_update_rgb_matrix_default();
749 747 rgb_matrix_config.raw = eeconfig_read_rgb_matrix();
750 748 }
751 if (!eeconfig_is_enabled()) { 749 eeconfig_debug_rgb_matrix(); // display current eeprom values
752 dprintf("rgb_matrix_init_drivers eeconfig is not enabled.\n"); 750}
753 eeconfig_init(); 751
754 eeconfig_update_rgb_matrix_default(); 752void rgb_matrix_setup_drivers(void) {
755 } 753 // Initialize TWI
756 rgb_matrix_config.raw = eeconfig_read_rgb_matrix(); 754 i2c_init();
757 if (!rgb_matrix_config.mode) { 755 IS31FL3731_init( DRIVER_ADDR_1 );
758 dprintf("rgb_matrix_init_drivers rgb_matrix_config.mode = 0. Write default values to EEPROM.\n"); 756 IS31FL3731_init( DRIVER_ADDR_2 );
759 eeconfig_update_rgb_matrix_default(); 757
760 rgb_matrix_config.raw = eeconfig_read_rgb_matrix(); 758 for ( int index = 0; index < DRIVER_LED_TOTAL; index++ ) {
761 } 759 bool enabled = true;
762 eeconfig_debug_rgb_matrix(); // display current eeprom values 760 // This only caches it for later
761 IS31FL3731_set_led_control_register( index, enabled, enabled, enabled );
762 }
763 // This actually updates the LED drivers
764 IS31FL3731_update_led_control_registers( DRIVER_ADDR_1, DRIVER_ADDR_2 );
763} 765}
764 766
765// Deals with the messy details of incrementing an integer 767// Deals with the messy details of incrementing an integer