diff options
author | Andrew-Fahmy <andrewj.fahmy@gmail.com> | 2021-03-25 06:35:18 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-25 22:35:18 +1100 |
commit | 1fbee7c31681746a268c82c1b99679b3b2a43657 (patch) | |
tree | 045070defa379b1c8a6993ccde9a85b131baf393 /keyboards/k_type/k_type-rgbdriver.c | |
parent | 8b39ae13c783806ab75460ac35621a403e1564b6 (diff) |
(Re)Fixing K-type RGB lighting (#12084)
* initial rgb driver fix
* added underglow LEDs and fixed typo in RGB locations
* removed test code
* added my key maps
* updated rgb keymap to work with changes
* refactored my code to make it more maintainable and updated keymaps.
* added GPL licence
* Turned off matrix scan rate debug info
* added checks if RGB matrix is enabled to fix errors when building keymaps without RGB matrix enabled
* Apply suggestions from code review by fauxpark
Co-authored-by: Ryan <fauxpark@gmail.com>
* Renamed led driver file to be less ambiguous
* Renamed is31fl3733 driver files to is31fl3733-dual
Co-authored-by: Ryan <fauxpark@gmail.com>
Diffstat (limited to 'keyboards/k_type/k_type-rgbdriver.c')
-rw-r--r-- | keyboards/k_type/k_type-rgbdriver.c | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/keyboards/k_type/k_type-rgbdriver.c b/keyboards/k_type/k_type-rgbdriver.c new file mode 100644 index 0000000000..8369aa909e --- /dev/null +++ b/keyboards/k_type/k_type-rgbdriver.c @@ -0,0 +1,57 @@ +/* Copyright 2021 Andrew Fahmy + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifdef RGB_MATRIX_ENABLE + +#include "rgb_matrix.h" +#include "i2c_master.h" +#include "is31fl3733-dual.h" + + + +static void init(void) { + i2c_init(&I2CD1, I2C1_SCL_BANK, I2C1_SDA_BANK, I2C1_SCL, I2C1_SDA); + IS31FL3733_init(0, DRIVER_ADDR_1, 0); +# ifdef USE_I2C2 + i2c_init(&I2CD2, I2C2_SCL_BANK, I2C2_SDA_BANK, I2C2_SCL, I2C2_SDA); + IS31FL3733_init(1, DRIVER_ADDR_2, 0); +# endif + for (int index = 0; index < DRIVER_LED_TOTAL; index++) { + bool enabled = true; + // This only caches it for later + IS31FL3733_set_led_control_register(index, enabled, enabled, enabled); + } + IS31FL3733_update_led_control_registers(DRIVER_ADDR_1, 0); +# ifdef USE_I2C2 + IS31FL3733_update_led_control_registers(DRIVER_ADDR_2, 1); +# endif +} + +static void flush(void) { + IS31FL3733_update_pwm_buffers(DRIVER_ADDR_1, 0); +# ifdef USE_I2C2 + IS31FL3733_update_pwm_buffers(DRIVER_ADDR_2, 1); +# endif +} + +const rgb_matrix_driver_t rgb_matrix_driver = { + .init = init, + .flush = flush, + .set_color = IS31FL3733_set_color, + .set_color_all = IS31FL3733_set_color_all, +}; + +#endif |