qmk_firmware

QMK firmware for my keyboards (Corne, Sweep Ferris) and trackball (Ploopy Adept)
Log | Files | Refs | Submodules | LICENSE

is31fl3218.h (2140B)


      1 /* Copyright 2018 Jason Williams (Wilba)
      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 #pragma once
     18 
     19 #include <stdint.h>
     20 #include <stdbool.h>
     21 #include "progmem.h"
     22 #include "util.h"
     23 
     24 #define IS31FL3218_REG_SHUTDOWN 0x00
     25 #define IS31FL3218_REG_PWM 0x01
     26 #define IS31FL3218_REG_LED_CONTROL_1 0x13
     27 #define IS31FL3218_REG_LED_CONTROL_2 0x14
     28 #define IS31FL3218_REG_LED_CONTROL_3 0x15
     29 #define IS31FL3218_REG_UPDATE 0x16
     30 #define IS31FL3218_REG_RESET 0x17
     31 
     32 #define IS31FL3218_I2C_ADDRESS 0x54
     33 
     34 #if defined(RGB_MATRIX_IS31FL3218)
     35 #    define IS31FL3218_LED_COUNT RGB_MATRIX_LED_COUNT
     36 #endif
     37 
     38 typedef struct is31fl3218_led_t {
     39     uint8_t r;
     40     uint8_t g;
     41     uint8_t b;
     42 } PACKED is31fl3218_led_t;
     43 
     44 extern const is31fl3218_led_t PROGMEM g_is31fl3218_leds[IS31FL3218_LED_COUNT];
     45 
     46 void is31fl3218_init(void);
     47 
     48 void is31fl3218_write_register(uint8_t reg, uint8_t data);
     49 
     50 void is31fl3218_set_color(int index, uint8_t red, uint8_t green, uint8_t blue);
     51 
     52 void is31fl3218_set_color_all(uint8_t red, uint8_t green, uint8_t blue);
     53 
     54 void is31fl3218_set_led_control_register(uint8_t index, bool red, bool green, bool blue);
     55 
     56 void is31fl3218_update_pwm_buffers(void);
     57 
     58 void is31fl3218_update_led_control_registers(void);
     59 
     60 #define OUT1 0x00
     61 #define OUT2 0x01
     62 #define OUT3 0x02
     63 #define OUT4 0x03
     64 #define OUT5 0x04
     65 #define OUT6 0x05
     66 #define OUT7 0x06
     67 #define OUT8 0x07
     68 #define OUT9 0x08
     69 #define OUT10 0x09
     70 #define OUT11 0x0A
     71 #define OUT12 0x0B
     72 #define OUT13 0x0C
     73 #define OUT14 0x0D
     74 #define OUT15 0x0E
     75 #define OUT16 0x0F
     76 #define OUT17 0x10
     77 #define OUT18 0x11