diff options
author | yiancar <yiangosyiangou@cytanet.com.cy> | 2018-08-28 16:03:11 +0300 |
---|---|---|
committer | Jack Humbert <jack.humb@gmail.com> | 2018-08-28 09:03:11 -0400 |
commit | fdd0f915271f79b104aa5d216566bcc3fd134e85 (patch) | |
tree | 42656e9ebd132461b99d7b037563374e575053ae /quantum/rgb_matrix.c | |
parent | 2410f023598af65a551b42f569a2703a5621bdca (diff) | |
download | qmk_firmware-fdd0f915271f79b104aa5d216566bcc3fd134e85.tar.gz qmk_firmware-fdd0f915271f79b104aa5d216566bcc3fd134e85.zip |
ISSI31FL3733 driver (#3679)
* ISSI31FL3733 driver
- Addapted IS31 driver for the above driver
* fix my branch
* ISSI31FL3733 driver
- Inclusion of above ISSI led driver
* IS31fl3733 driver
- Added correct function for control registers
* Finalized support for ISSI31fl3733 led driver
- Finalized and tested driver.
- Modified i2c_master for arm due to declaration mistake.
- Fixed spaces/tabs in quantum.h file.
- Fixed spaces/tabs in common_features.mk file.
- Removed unnecessary includes from rgb_matrix.c file.
- Added local definitions for MIN and MAX macros in rgb_matrix.c file.
- Adjusted chevron effect.
- Added necessary define (RGB_3733_MATRIX_ENABLE) for makefile.
- Added necessary C define (ISSI3733) to aid with inclusion of the correct header file.
- Added documentation for the new driver.
* Driver structure update
- Changed rule includes to be more condensed (RGB_MATRIX_ENABLE = IS31FL3731) and (RGB_MATRIX_ENABLE = IS31FL3733)
- Updated documentation
- Reverted to the use of differently named functions for each driver and selecting the needed ones within rgb_matrix.c
* ISSI Drivers refractoring
- Moved issi drivers in a dedicated folder
- Updated documentation
* I2C library fix
I released the special pins incorrectly before. It is now fixed.
Diffstat (limited to 'quantum/rgb_matrix.c')
-rw-r--r-- | quantum/rgb_matrix.c | 68 |
1 files changed, 53 insertions, 15 deletions
diff --git a/quantum/rgb_matrix.c b/quantum/rgb_matrix.c index 70ad1a178..197bc1ac5 100644 --- a/quantum/rgb_matrix.c +++ b/quantum/rgb_matrix.c | |||
@@ -1,5 +1,6 @@ | |||
1 | /* Copyright 2017 Jason Williams | 1 | /* Copyright 2017 Jason Williams |
2 | * Copyright 2017 Jack Humbert | 2 | * Copyright 2017 Jack Humbert |
3 | * Copyright 2018 Yiancar | ||
3 | * | 4 | * |
4 | * This program is free software: you can redistribute it and/or modify | 5 | * This program is free software: you can redistribute it and/or modify |
5 | * it under the terms of the GNU General Public License as published by | 6 | * it under the terms of the GNU General Public License as published by |
@@ -17,18 +18,22 @@ | |||
17 | 18 | ||
18 | 19 | ||
19 | #include "rgb_matrix.h" | 20 | #include "rgb_matrix.h" |
20 | #include <avr/io.h> | ||
21 | #include "i2c_master.h" | 21 | #include "i2c_master.h" |
22 | #include <util/delay.h> | ||
23 | #include <avr/interrupt.h> | ||
24 | #include "progmem.h" | 22 | #include "progmem.h" |
25 | #include "config.h" | 23 | #include "config.h" |
26 | #include "eeprom.h" | 24 | #include "eeprom.h" |
27 | #include "lufa.h" | ||
28 | #include <math.h> | 25 | #include <math.h> |
29 | 26 | ||
30 | rgb_config_t rgb_matrix_config; | 27 | rgb_config_t rgb_matrix_config; |
31 | 28 | ||
29 | #ifndef MAX | ||
30 | #define MAX(X, Y) ((X) > (Y) ? (X) : (Y)) | ||
31 | #endif | ||
32 | |||
33 | #ifndef MIN | ||
34 | #define MIN(a,b) ((a) < (b)? (a): (b)) | ||
35 | #endif | ||
36 | |||
32 | #ifndef RGB_DISABLE_AFTER_TIMEOUT | 37 | #ifndef RGB_DISABLE_AFTER_TIMEOUT |
33 | #define RGB_DISABLE_AFTER_TIMEOUT 0 | 38 | #define RGB_DISABLE_AFTER_TIMEOUT 0 |
34 | #endif | 39 | #endif |
@@ -106,16 +111,29 @@ void map_row_column_to_led( uint8_t row, uint8_t column, uint8_t *led_i, uint8_t | |||
106 | } | 111 | } |
107 | 112 | ||
108 | void rgb_matrix_update_pwm_buffers(void) { | 113 | void rgb_matrix_update_pwm_buffers(void) { |
109 | IS31_update_pwm_buffers( DRIVER_ADDR_1, DRIVER_ADDR_2 ); | 114 | #ifdef IS31FL3731 |
110 | IS31_update_led_control_registers( DRIVER_ADDR_1, DRIVER_ADDR_2 ); | 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 | ||
111 | } | 121 | } |
112 | 122 | ||
113 | void rgb_matrix_set_color( int index, uint8_t red, uint8_t green, uint8_t blue ) { | 123 | void rgb_matrix_set_color( int index, uint8_t red, uint8_t green, uint8_t blue ) { |
114 | IS31_set_color( index, red, green, blue ); | 124 | #ifdef IS31FL3731 |
125 | IS31FL3731_set_color( index, red, green, blue ); | ||
126 | #elif defined(IS31FL3733) | ||
127 | IS31FL3733_set_color( index, red, green, blue ); | ||
128 | #endif | ||
115 | } | 129 | } |
116 | 130 | ||
117 | void rgb_matrix_set_color_all( uint8_t red, uint8_t green, uint8_t blue ) { | 131 | void rgb_matrix_set_color_all( uint8_t red, uint8_t green, uint8_t blue ) { |
118 | IS31_set_color_all( red, green, blue ); | 132 | #ifdef IS31FL3731 |
133 | IS31FL3731_set_color_all( red, green, blue ); | ||
134 | #elif defined(IS31FL3733) | ||
135 | IS31FL3733_set_color_all( red, green, blue ); | ||
136 | #endif | ||
119 | } | 137 | } |
120 | 138 | ||
121 | bool process_rgb_matrix(uint16_t keycode, keyrecord_t *record) { | 139 | bool process_rgb_matrix(uint16_t keycode, keyrecord_t *record) { |
@@ -460,7 +478,7 @@ void rgb_matrix_rainbow_moving_chevron(void) { | |||
460 | for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) { | 478 | for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) { |
461 | led = g_rgb_leds[i]; | 479 | led = g_rgb_leds[i]; |
462 | // uint8_t r = g_tick; | 480 | // uint8_t r = g_tick; |
463 | uint8_t r = 32; | 481 | uint8_t r = 128; |
464 | hsv.h = (1.5 * (rgb_matrix_config.speed == 0 ? 1 : rgb_matrix_config.speed)) * abs(led.point.y - 32.0)* sin(r * PI / 128) + (1.5 * (rgb_matrix_config.speed == 0 ? 1 : rgb_matrix_config.speed)) * (led.point.x - (g_tick / 256.0 * 224)) * cos(r * PI / 128) + rgb_matrix_config.hue; | 482 | hsv.h = (1.5 * (rgb_matrix_config.speed == 0 ? 1 : rgb_matrix_config.speed)) * abs(led.point.y - 32.0)* sin(r * PI / 128) + (1.5 * (rgb_matrix_config.speed == 0 ? 1 : rgb_matrix_config.speed)) * (led.point.x - (g_tick / 256.0 * 224)) * cos(r * PI / 128) + rgb_matrix_config.hue; |
465 | rgb = hsv_to_rgb( hsv ); | 483 | rgb = hsv_to_rgb( hsv ); |
466 | rgb_matrix_set_color( i, rgb.r, rgb.g, rgb.b ); | 484 | rgb_matrix_set_color( i, rgb.r, rgb.g, rgb.b ); |
@@ -752,16 +770,28 @@ void rgb_matrix_init(void) { | |||
752 | void rgb_matrix_setup_drivers(void) { | 770 | void rgb_matrix_setup_drivers(void) { |
753 | // Initialize TWI | 771 | // Initialize TWI |
754 | i2c_init(); | 772 | i2c_init(); |
755 | IS31_init( DRIVER_ADDR_1 ); | 773 | #ifdef IS31FL3731 |
756 | IS31_init( DRIVER_ADDR_2 ); | 774 | IS31FL3731_init( DRIVER_ADDR_1 ); |
775 | IS31FL3731_init( DRIVER_ADDR_2 ); | ||
776 | #elif defined (IS31FL3733) | ||
777 | IS31FL3733_init( DRIVER_ADDR_1 ); | ||
778 | #endif | ||
757 | 779 | ||
758 | for ( int index = 0; index < DRIVER_LED_TOTAL; index++ ) { | 780 | for ( int index = 0; index < DRIVER_LED_TOTAL; index++ ) { |
759 | bool enabled = true; | 781 | bool enabled = true; |
760 | // This only caches it for later | 782 | // This only caches it for later |
761 | IS31_set_led_control_register( index, enabled, enabled, enabled ); | 783 | #ifdef IS31FL3731 |
784 | IS31FL3731_set_led_control_register( index, enabled, enabled, enabled ); | ||
785 | #elif defined (IS31FL3733) | ||
786 | IS31FL3733_set_led_control_register( index, enabled, enabled, enabled ); | ||
787 | #endif | ||
762 | } | 788 | } |
763 | // This actually updates the LED drivers | 789 | // This actually updates the LED drivers |
764 | IS31_update_led_control_registers( DRIVER_ADDR_1, DRIVER_ADDR_2 ); | 790 | #ifdef IS31FL3731 |
791 | IS31FL3731_update_led_control_registers( DRIVER_ADDR_1, DRIVER_ADDR_2 ); | ||
792 | #elif defined (IS31FL3733) | ||
793 | IS31FL3733_update_led_control_registers( DRIVER_ADDR_1, DRIVER_ADDR_2 ); | ||
794 | #endif | ||
765 | } | 795 | } |
766 | 796 | ||
767 | // Deals with the messy details of incrementing an integer | 797 | // Deals with the messy details of incrementing an integer |
@@ -811,11 +841,19 @@ void rgb_matrix_test_led( uint8_t index, bool red, bool green, bool blue ) { | |||
811 | { | 841 | { |
812 | if ( i == index ) | 842 | if ( i == index ) |
813 | { | 843 | { |
814 | IS31_set_led_control_register( i, red, green, blue ); | 844 | #ifdef IS31FL3731 |
845 | IS31FL3731_set_led_control_register( i, red, green, blue ); | ||
846 | #elif defined (IS31FL3733) | ||
847 | IS31FL3733_set_led_control_register( i, red, green, blue ); | ||
848 | #endif | ||
815 | } | 849 | } |
816 | else | 850 | else |
817 | { | 851 | { |
818 | IS31_set_led_control_register( i, false, false, false ); | 852 | #ifdef IS31FL3731 |
853 | IS31FL3731_set_led_control_register( i, false, false, false ); | ||
854 | #elif defined (IS31FL3733) | ||
855 | IS31FL3733_set_led_control_register( i, false, false, false ); | ||
856 | #endif | ||
819 | } | 857 | } |
820 | } | 858 | } |
821 | } | 859 | } |