diff options
Diffstat (limited to 'quantum/rgb_matrix.c')
| -rw-r--r-- | quantum/rgb_matrix.c | 113 |
1 files changed, 4 insertions, 109 deletions
diff --git a/quantum/rgb_matrix.c b/quantum/rgb_matrix.c index 5fb59af8c..807e4d62d 100644 --- a/quantum/rgb_matrix.c +++ b/quantum/rgb_matrix.c | |||
| @@ -18,7 +18,6 @@ | |||
| 18 | 18 | ||
| 19 | 19 | ||
| 20 | #include "rgb_matrix.h" | 20 | #include "rgb_matrix.h" |
| 21 | #include "i2c_master.h" | ||
| 22 | #include "progmem.h" | 21 | #include "progmem.h" |
| 23 | #include "config.h" | 22 | #include "config.h" |
| 24 | #include "eeprom.h" | 23 | #include "eeprom.h" |
| @@ -111,29 +110,15 @@ void map_row_column_to_led( uint8_t row, uint8_t column, uint8_t *led_i, uint8_t | |||
| 111 | } | 110 | } |
| 112 | 111 | ||
| 113 | void rgb_matrix_update_pwm_buffers(void) { | 112 | void rgb_matrix_update_pwm_buffers(void) { |
| 114 | #ifdef IS31FL3731 | 113 | rgb_matrix_driver.flush(); |
| 115 | IS31FL3731_update_pwm_buffers( DRIVER_ADDR_1, DRIVER_ADDR_2 ); | ||
| 116 | IS31FL3731_update_led_control_registers( DRIVER_ADDR_1, DRIVER_ADDR_2 ); | ||
| 117 | #elif defined(IS31FL3733) | ||
| 118 | IS31FL3733_update_pwm_buffers( DRIVER_ADDR_1, DRIVER_ADDR_2 ); | ||
| 119 | IS31FL3733_update_led_control_registers( DRIVER_ADDR_1, DRIVER_ADDR_2 ); | ||
| 120 | #endif | ||
| 121 | } | 114 | } |
| 122 | 115 | ||
| 123 | void rgb_matrix_set_color( int index, uint8_t red, uint8_t green, uint8_t blue ) { | 116 | void rgb_matrix_set_color( int index, uint8_t red, uint8_t green, uint8_t blue ) { |
| 124 | #ifdef IS31FL3731 | 117 | rgb_matrix_driver.set_color(index, red, green, blue); |
| 125 | IS31FL3731_set_color( index, red, green, blue ); | ||
| 126 | #elif defined(IS31FL3733) | ||
| 127 | IS31FL3733_set_color( index, red, green, blue ); | ||
| 128 | #endif | ||
| 129 | } | 118 | } |
| 130 | 119 | ||
| 131 | void rgb_matrix_set_color_all( uint8_t red, uint8_t green, uint8_t blue ) { | 120 | void rgb_matrix_set_color_all( uint8_t red, uint8_t green, uint8_t blue ) { |
| 132 | #ifdef IS31FL3731 | 121 | rgb_matrix_driver.set_color_all(red, green, blue); |
| 133 | IS31FL3731_set_color_all( red, green, blue ); | ||
| 134 | #elif defined(IS31FL3733) | ||
| 135 | IS31FL3733_set_color_all( red, green, blue ); | ||
| 136 | #endif | ||
| 137 | } | 122 | } |
| 138 | 123 | ||
| 139 | bool process_rgb_matrix(uint16_t keycode, keyrecord_t *record) { | 124 | bool process_rgb_matrix(uint16_t keycode, keyrecord_t *record) { |
| @@ -196,47 +181,6 @@ void rgb_matrix_test(void) { | |||
| 196 | } | 181 | } |
| 197 | } | 182 | } |
| 198 | 183 | ||
| 199 | // This tests the LEDs | ||
| 200 | // Note that it will change the LED control registers | ||
| 201 | // in the LED drivers, and leave them in an invalid | ||
| 202 | // state for other backlight effects. | ||
| 203 | // ONLY USE THIS FOR TESTING LEDS! | ||
| 204 | void rgb_matrix_single_LED_test(void) { | ||
| 205 | static uint8_t color = 0; // 0,1,2 for R,G,B | ||
| 206 | static uint8_t row = 0; | ||
| 207 | static uint8_t column = 0; | ||
| 208 | |||
| 209 | static uint8_t tick = 0; | ||
| 210 | tick++; | ||
| 211 | |||
| 212 | if ( tick > 2 ) | ||
| 213 | { | ||
| 214 | tick = 0; | ||
| 215 | column++; | ||
| 216 | } | ||
| 217 | if ( column > MATRIX_COLS ) | ||
| 218 | { | ||
| 219 | column = 0; | ||
| 220 | row++; | ||
| 221 | } | ||
| 222 | if ( row > MATRIX_ROWS ) | ||
| 223 | { | ||
| 224 | row = 0; | ||
| 225 | color++; | ||
| 226 | } | ||
| 227 | if ( color > 2 ) | ||
| 228 | { | ||
| 229 | color = 0; | ||
| 230 | } | ||
| 231 | |||
| 232 | uint8_t led[8], led_count; | ||
| 233 | map_row_column_to_led(row,column,led,&led_count); | ||
| 234 | for(uint8_t i = 0; i < led_count; i++) { | ||
| 235 | rgb_matrix_set_color_all( 40, 40, 40 ); | ||
| 236 | rgb_matrix_test_led( led[i], color==0, color==1, color==2 ); | ||
| 237 | } | ||
| 238 | } | ||
| 239 | |||
| 240 | // All LEDs off | 184 | // All LEDs off |
| 241 | void rgb_matrix_all_off(void) { | 185 | void rgb_matrix_all_off(void) { |
| 242 | rgb_matrix_set_color_all( 0, 0, 0 ); | 186 | rgb_matrix_set_color_all( 0, 0, 0 ); |
| @@ -817,7 +761,7 @@ void rgb_matrix_indicators_user(void) {} | |||
| 817 | // } | 761 | // } |
| 818 | 762 | ||
| 819 | void rgb_matrix_init(void) { | 763 | void rgb_matrix_init(void) { |
| 820 | rgb_matrix_setup_drivers(); | 764 | rgb_matrix_driver.init(); |
| 821 | 765 | ||
| 822 | // TODO: put the 1 second startup delay here? | 766 | // TODO: put the 1 second startup delay here? |
| 823 | 767 | ||
| @@ -841,33 +785,6 @@ void rgb_matrix_init(void) { | |||
| 841 | eeconfig_debug_rgb_matrix(); // display current eeprom values | 785 | eeconfig_debug_rgb_matrix(); // display current eeprom values |
| 842 | } | 786 | } |
| 843 | 787 | ||
| 844 | void rgb_matrix_setup_drivers(void) { | ||
| 845 | // Initialize TWI | ||
| 846 | i2c_init(); | ||
| 847 | #ifdef IS31FL3731 | ||
| 848 | IS31FL3731_init( DRIVER_ADDR_1 ); | ||
| 849 | IS31FL3731_init( DRIVER_ADDR_2 ); | ||
| 850 | #elif defined (IS31FL3733) | ||
| 851 | IS31FL3733_init( DRIVER_ADDR_1 ); | ||
| 852 | #endif | ||
| 853 | |||
| 854 | for ( int index = 0; index < DRIVER_LED_TOTAL; index++ ) { | ||
| 855 | bool enabled = true; | ||
| 856 | // This only caches it for later | ||
| 857 | #ifdef IS31FL3731 | ||
| 858 | IS31FL3731_set_led_control_register( index, enabled, enabled, enabled ); | ||
| 859 | #elif defined (IS31FL3733) | ||
| 860 | IS31FL3733_set_led_control_register( index, enabled, enabled, enabled ); | ||
| 861 | #endif | ||
| 862 | } | ||
| 863 | // This actually updates the LED drivers | ||
| 864 | #ifdef IS31FL3731 | ||
| 865 | IS31FL3731_update_led_control_registers( DRIVER_ADDR_1, DRIVER_ADDR_2 ); | ||
| 866 | #elif defined (IS31FL3733) | ||
| 867 | IS31FL3733_update_led_control_registers( DRIVER_ADDR_1, DRIVER_ADDR_2 ); | ||
| 868 | #endif | ||
| 869 | } | ||
| 870 | |||
| 871 | // Deals with the messy details of incrementing an integer | 788 | // Deals with the messy details of incrementing an integer |
| 872 | uint8_t increment( uint8_t value, uint8_t step, uint8_t min, uint8_t max ) { | 789 | uint8_t increment( uint8_t value, uint8_t step, uint8_t min, uint8_t max ) { |
| 873 | int16_t new_value = value; | 790 | int16_t new_value = value; |
| @@ -910,28 +827,6 @@ uint8_t decrement( uint8_t value, uint8_t step, uint8_t min, uint8_t max ) { | |||
| 910 | // } | 827 | // } |
| 911 | // } | 828 | // } |
| 912 | 829 | ||
| 913 | void rgb_matrix_test_led( uint8_t index, bool red, bool green, bool blue ) { | ||
| 914 | for ( int i=0; i<DRIVER_LED_TOTAL; i++ ) | ||
| 915 | { | ||
| 916 | if ( i == index ) | ||
| 917 | { | ||
| 918 | #ifdef IS31FL3731 | ||
| 919 | IS31FL3731_set_led_control_register( i, red, green, blue ); | ||
| 920 | #elif defined (IS31FL3733) | ||
| 921 | IS31FL3733_set_led_control_register( i, red, green, blue ); | ||
| 922 | #endif | ||
| 923 | } | ||
| 924 | else | ||
| 925 | { | ||
| 926 | #ifdef IS31FL3731 | ||
| 927 | IS31FL3731_set_led_control_register( i, false, false, false ); | ||
| 928 | #elif defined (IS31FL3733) | ||
| 929 | IS31FL3733_set_led_control_register( i, false, false, false ); | ||
| 930 | #endif | ||
| 931 | } | ||
| 932 | } | ||
| 933 | } | ||
| 934 | |||
| 935 | uint32_t rgb_matrix_get_tick(void) { | 830 | uint32_t rgb_matrix_get_tick(void) { |
| 936 | return g_tick; | 831 | return g_tick; |
| 937 | } | 832 | } |
