1 /* Copyright 2018 James Laird-Wah
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #include "rgb_matrix.h"
19 /* Each driver needs to define the struct
20 * const rgb_matrix_driver_t rgb_matrix_driver;
21 * All members must be provided.
22 * Keyboard custom drivers can define this in their own files, it should only
23 * be here if shared between boards.
26 #if defined(IS31FL3731) || defined(IS31FL3733) || defined(IS31FL3737)
28 #include "i2c_master.h"
30 static void init( void )
34 IS31FL3731_init( DRIVER_ADDR_1 );
35 IS31FL3731_init( DRIVER_ADDR_2 );
36 #elif defined(IS31FL3733)
37 IS31FL3733_init( DRIVER_ADDR_1, 0 );
39 IS31FL3737_init( DRIVER_ADDR_1 );
41 for ( int index = 0; index < DRIVER_LED_TOTAL; index++ ) {
43 // This only caches it for later
45 IS31FL3731_set_led_control_register( index, enabled, enabled, enabled );
46 #elif defined(IS31FL3733)
47 IS31FL3733_set_led_control_register( index, enabled, enabled, enabled );
49 IS31FL3737_set_led_control_register( index, enabled, enabled, enabled );
52 // This actually updates the LED drivers
54 IS31FL3731_update_led_control_registers( DRIVER_ADDR_1, DRIVER_ADDR_2 );
55 #elif defined(IS31FL3733)
56 IS31FL3733_update_led_control_registers( DRIVER_ADDR_1, 0 );
57 IS31FL3733_update_led_control_registers( DRIVER_ADDR_2, 1 );
59 IS31FL3737_update_led_control_registers( DRIVER_ADDR_1, DRIVER_ADDR_2 );
64 static void flush( void )
66 IS31FL3731_update_pwm_buffers( DRIVER_ADDR_1, DRIVER_ADDR_2 );
69 const rgb_matrix_driver_t rgb_matrix_driver = {
72 .set_color = IS31FL3731_set_color,
73 .set_color_all = IS31FL3731_set_color_all,
75 #elif defined(IS31FL3733)
76 static void flush( void )
78 IS31FL3733_update_pwm_buffers( DRIVER_ADDR_1, 0);
79 IS31FL3733_update_pwm_buffers( DRIVER_ADDR_2, 1);
82 const rgb_matrix_driver_t rgb_matrix_driver = {
85 .set_color = IS31FL3733_set_color,
86 .set_color_all = IS31FL3733_set_color_all,
89 static void flush( void )
91 IS31FL3737_update_pwm_buffers( DRIVER_ADDR_1, DRIVER_ADDR_2 );
94 const rgb_matrix_driver_t rgb_matrix_driver = {
97 .set_color = IS31FL3737_set_color,
98 .set_color_all = IS31FL3737_set_color_all,
102 #elif defined(WS2812)
104 extern LED_TYPE led[DRIVER_LED_TOTAL];
106 static void flush( void )
108 // Assumes use of RGB_DI_PIN
109 ws2812_setleds(led, DRIVER_LED_TOTAL);
112 static void init( void )
117 const rgb_matrix_driver_t rgb_matrix_driver = {
120 .set_color = ws2812_setled,
121 .set_color_all = ws2812_setled_all,