X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=quantum%2Frgb_matrix.c;h=d71283f7c24c29bfc95034ea6a5d41fc5bd2f225;hb=bad56a4f2b91fc8591f6d33a1710ea0050abcfbf;hp=6cb0478f71efd872c4bccd28531e89a08e6b02f8;hpb=14b7602a65dedaf51db1c9288144765d43a83a15;p=qmk_firmware.git diff --git a/quantum/rgb_matrix.c b/quantum/rgb_matrix.c index 6cb0478f7..d71283f7c 100644 --- a/quantum/rgb_matrix.c +++ b/quantum/rgb_matrix.c @@ -18,7 +18,7 @@ #include "rgb_matrix.h" #include -#include "TWIlib.h" +#include "i2c_master.h" #include #include #include "progmem.h" @@ -69,6 +69,7 @@ void eeconfig_update_rgb_matrix_default(void) { rgb_matrix_config.hue = 0; rgb_matrix_config.sat = 255; rgb_matrix_config.val = 255; + rgb_matrix_config.speed = 0; eeconfig_update_rgb_matrix(rgb_matrix_config.raw); } void eeconfig_debug_rgb_matrix(void) { @@ -78,6 +79,7 @@ void eeconfig_debug_rgb_matrix(void) { dprintf("rgb_matrix_config.hue = %d\n", rgb_matrix_config.hue); dprintf("rgb_matrix_config.sat = %d\n", rgb_matrix_config.sat); dprintf("rgb_matrix_config.val = %d\n", rgb_matrix_config.val); + dprintf("rgb_matrix_config.speed = %d\n", rgb_matrix_config.speed); } // Last led hit @@ -99,10 +101,14 @@ void map_row_column_to_led( uint8_t row, uint8_t column, uint8_t *led_i, uint8_t } } - void rgb_matrix_update_pwm_buffers(void) { - IS31FL3731_update_pwm_buffers( DRIVER_ADDR_1, DRIVER_ADDR_2 ); - IS31FL3731_update_led_control_registers( DRIVER_ADDR_1, DRIVER_ADDR_2 ); + uint8_t ret = IS31FL3731_update_pwm_buffers( DRIVER_ADDR_1, DRIVER_ADDR_2 ); + ret |= IS31FL3731_update_led_control_registers( DRIVER_ADDR_1, DRIVER_ADDR_2 ); + if (ret == 2) { + wait_ms(1000); + i2c_stop(); + rgb_matrix_setup_drivers(); + } } void rgb_matrix_set_color( int index, uint8_t red, uint8_t green, uint8_t blue ) { @@ -113,7 +119,6 @@ void rgb_matrix_set_color_all( uint8_t red, uint8_t green, uint8_t blue ) { IS31FL3731_set_color_all( red, green, blue ); } - bool process_rgb_matrix(uint16_t keycode, keyrecord_t *record) { if ( record->event.pressed ) { uint8_t led[8], led_count; @@ -147,8 +152,9 @@ void rgb_matrix_set_suspend_state(bool state) { void rgb_matrix_test(void) { // Mask out bits 4 and 5 - // This 2-bit value will stay the same for 16 ticks. - switch ( (g_tick & 0x30) >> 4 ) + // Increase the factor to make the test animation slower (and reduce to make it faster) + uint8_t factor = 10; + switch ( (g_tick & (0b11 << factor)) >> factor ) { case 0: { @@ -215,7 +221,7 @@ void rgb_matrix_single_LED_test(void) { } // All LEDs off -void rgb_matrix_all_off(void) { +void rgb_matrix_all_off(void) { rgb_matrix_set_color_all( 0, 0, 0 ); } @@ -241,7 +247,7 @@ void rgb_matrix_solid_reactive(void) { // alphas = color1, mods = color2 void rgb_matrix_alphas_mods(void) { - + RGB rgb1 = hsv_to_rgb( (HSV){ .h = rgb_matrix_config.hue, .s = rgb_matrix_config.sat, .v = rgb_matrix_config.val } ); RGB rgb2 = hsv_to_rgb( (HSV){ .h = (rgb_matrix_config.hue + 180) % 360, .s = rgb_matrix_config.sat, .v = rgb_matrix_config.val } ); @@ -322,8 +328,8 @@ void rgb_matrix_raindrops(bool initialize) { HSV hsv; RGB rgb; - // Change one LED every tick - uint8_t led_to_change = ( g_tick & 0x000 ) == 0 ? rand() % DRIVER_LED_TOTAL : 255; + // Change one LED every tick, make sure speed is not 0 + uint8_t led_to_change = ( g_tick & ( 0x0A / (rgb_matrix_config.speed == 0 ? 1 : rgb_matrix_config.speed) ) ) == 0 ? rand() % (DRIVER_LED_TOTAL) : 255; for ( int i=0; i