1 /* Copyright 2018 Clueboard
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/>.
20 #include "led_matrix.h"
22 /* Each driver needs to define a struct:
24 * const led_matrix_driver_t led_matrix_driver;
26 * All members must be provided. Keyboard custom drivers must define this
30 #if defined(IS31FL3731) || defined(IS31FL3733)
32 #if defined(IS31FL3731)
33 #include "is31fl3731-simple.h"
36 #include "i2c_master.h"
38 static void init(void) {
41 #ifdef LED_DRIVER_ADDR_1
42 IS31FL3731_init(LED_DRIVER_ADDR_1);
44 #ifdef LED_DRIVER_ADDR_2
45 IS31FL3731_init(LED_DRIVER_ADDR_2);
47 #ifdef LED_DRIVER_ADDR_3
48 IS31FL3731_init(LED_DRIVER_ADDR_3);
50 #ifdef LED_DRIVER_ADDR_4
51 IS31FL3731_init(LED_DRIVER_ADDR_4);
54 #ifdef LED_DRIVER_ADDR_1
55 IS31FL3733_init(LED_DRIVER_ADDR_1);
57 #ifdef LED_DRIVER_ADDR_2
58 IS31FL3733_init(LED_DRIVER_ADDR_2);
60 #ifdef LED_DRIVER_ADDR_3
61 IS31FL3733_init(LED_DRIVER_ADDR_3);
63 #ifdef LED_DRIVER_ADDR_4
64 IS31FL3733_init(LED_DRIVER_ADDR_4);
68 for (int index = 0; index < LED_DRIVER_LED_COUNT; index++) {
70 IS31FL3731_set_led_control_register(index, true);
72 IS31FL3733_set_led_control_register(index, true);
75 // This actually updates the LED drivers
77 #ifdef LED_DRIVER_ADDR_1
78 IS31FL3731_update_led_control_registers(LED_DRIVER_ADDR_1, 0);
80 #ifdef LED_DRIVER_ADDR_2
81 IS31FL3731_update_led_control_registers(LED_DRIVER_ADDR_2, 1);
83 #ifdef LED_DRIVER_ADDR_3
84 IS31FL3731_update_led_control_registers(LED_DRIVER_ADDR_3, 2);
86 #ifdef LED_DRIVER_ADDR_4
87 IS31FL3731_update_led_control_registers(LED_DRIVER_ADDR_4, 3);
90 #ifdef LED_DRIVER_ADDR_1
91 IS31FL3733_update_led_control_registers(LED_DRIVER_ADDR_1, 0);
93 #ifdef LED_DRIVER_ADDR_2
94 IS31FL3733_update_led_control_registers(LED_DRIVER_ADDR_2, 1);
96 #ifdef LED_DRIVER_ADDR_3
97 IS31FL3733_update_led_control_registers(LED_DRIVER_ADDR_3, 2);
99 #ifdef LED_DRIVER_ADDR_4
100 IS31FL3733_update_led_control_registers(LED_DRIVER_ADDR_4, 3);
105 static void flush(void) {
107 #ifdef LED_DRIVER_ADDR_1
108 IS31FL3731_update_pwm_buffers(LED_DRIVER_ADDR_1, 0);
110 #ifdef LED_DRIVER_ADDR_2
111 IS31FL3731_update_pwm_buffers(LED_DRIVER_ADDR_2, 1);
113 #ifdef LED_DRIVER_ADDR_3
114 IS31FL3731_update_pwm_buffers(LED_DRIVER_ADDR_3, 2);
116 #ifdef LED_DRIVER_ADDR_4
117 IS31FL3731_update_pwm_buffers(LED_DRIVER_ADDR_4, 3);
120 #ifdef LED_DRIVER_ADDR_1
121 IS31FL3733_update_pwm_buffers(LED_DRIVER_ADDR_1, 0);
123 #ifdef LED_DRIVER_ADDR_2
124 IS31FL3733_update_pwm_buffers(LED_DRIVER_ADDR_2, 1);
126 #ifdef LED_DRIVER_ADDR_3
127 IS31FL3733_update_pwm_buffers(LED_DRIVER_ADDR_3, 2);
129 #ifdef LED_DRIVER_ADDR_4
130 IS31FL3733_update_pwm_buffers(LED_DRIVER_ADDR_4, 3);
135 const led_matrix_driver_t led_matrix_driver = {
139 .set_value = IS31FL3731_set_value,
140 .set_value_all = IS31FL3731_set_value_all,
142 .set_value = IS31FL3733_set_value,
143 .set_value_all = IS31FL3733_set_value_all,