aboutsummaryrefslogtreecommitdiff
path: root/quantum/rgb_matrix_drivers.c
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/rgb_matrix_drivers.c')
-rw-r--r--quantum/rgb_matrix_drivers.c82
1 files changed, 82 insertions, 0 deletions
diff --git a/quantum/rgb_matrix_drivers.c b/quantum/rgb_matrix_drivers.c
new file mode 100644
index 000000000..70b80293d
--- /dev/null
+++ b/quantum/rgb_matrix_drivers.c
@@ -0,0 +1,82 @@
1/* Copyright 2018 James Laird-Wah
2 *
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.
7 *
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.
12 *
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/>.
15 */
16
17#include "rgb_matrix.h"
18
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.
24 */
25
26#if defined(IS31FL3731) || defined(IS31FL3733)
27
28#include "i2c_master.h"
29
30static void init( void )
31{
32 i2c_init();
33#ifdef IS31FL3731
34 IS31FL3731_init( DRIVER_ADDR_1 );
35 IS31FL3731_init( DRIVER_ADDR_2 );
36#else
37 IS31FL3733_init( DRIVER_ADDR_1 );
38#endif
39 for ( int index = 0; index < DRIVER_LED_TOTAL; index++ ) {
40 bool enabled = true;
41 // This only caches it for later
42#ifdef IS31FL3731
43 IS31FL3731_set_led_control_register( index, enabled, enabled, enabled );
44#else
45 IS31FL3733_set_led_control_register( index, enabled, enabled, enabled );
46#endif
47 }
48 // This actually updates the LED drivers
49#ifdef IS31FL3731
50 IS31FL3731_update_led_control_registers( DRIVER_ADDR_1, DRIVER_ADDR_2 );
51#else
52 IS31FL3733_update_led_control_registers( DRIVER_ADDR_1, DRIVER_ADDR_2 );
53#endif
54}
55
56#ifdef IS31FL3731
57static void flush( void )
58{
59 IS31FL3731_update_pwm_buffers( DRIVER_ADDR_1, DRIVER_ADDR_2 );
60}
61
62const rgb_matrix_driver_t rgb_matrix_driver = {
63 .init = init,
64 .flush = flush,
65 .set_color = IS31FL3731_set_color,
66 .set_color_all = IS31FL3731_set_color_all,
67};
68#else
69static void flush( void )
70{
71 IS31FL3733_update_pwm_buffers( DRIVER_ADDR_1, DRIVER_ADDR_2 );
72}
73
74const rgb_matrix_driver_t rgb_matrix_driver = {
75 .init = init,
76 .flush = flush,
77 .set_color = IS31FL3733_set_color,
78 .set_color_all = IS31FL3733_set_color_all,
79};
80#endif
81
82#endif