diff options
Diffstat (limited to 'drivers/led/issi/is31fl3736.h')
| -rw-r--r-- | drivers/led/issi/is31fl3736.h | 169 |
1 files changed, 169 insertions, 0 deletions
diff --git a/drivers/led/issi/is31fl3736.h b/drivers/led/issi/is31fl3736.h new file mode 100644 index 000000000..c956c87f7 --- /dev/null +++ b/drivers/led/issi/is31fl3736.h | |||
| @@ -0,0 +1,169 @@ | |||
| 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 | |||
| 23 | // Simple interface option. | ||
| 24 | // If these aren't defined, just define them to make it compile | ||
| 25 | |||
| 26 | #ifndef DRIVER_COUNT | ||
| 27 | # define DRIVER_COUNT 2 | ||
| 28 | #endif | ||
| 29 | |||
| 30 | #ifndef DRIVER_LED_TOTAL | ||
| 31 | # define DRIVER_LED_TOTAL 96 | ||
| 32 | #endif | ||
| 33 | |||
| 34 | typedef struct is31_led { | ||
| 35 | uint8_t driver : 2; | ||
| 36 | uint8_t r; | ||
| 37 | uint8_t g; | ||
| 38 | uint8_t b; | ||
| 39 | } __attribute__((packed)) is31_led; | ||
| 40 | |||
| 41 | extern const is31_led __flash g_is31_leds[DRIVER_LED_TOTAL]; | ||
| 42 | |||
| 43 | void IS31FL3736_init(uint8_t addr); | ||
| 44 | void IS31FL3736_write_register(uint8_t addr, uint8_t reg, uint8_t data); | ||
| 45 | void IS31FL3736_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer); | ||
| 46 | |||
| 47 | void IS31FL3736_set_color(int index, uint8_t red, uint8_t green, uint8_t blue); | ||
| 48 | void IS31FL3736_set_color_all(uint8_t red, uint8_t green, uint8_t blue); | ||
| 49 | |||
| 50 | void IS31FL3736_set_led_control_register(uint8_t index, bool red, bool green, bool blue); | ||
| 51 | |||
| 52 | void IS31FL3736_mono_set_brightness(int index, uint8_t value); | ||
| 53 | void IS31FL3736_mono_set_brightness_all(uint8_t value); | ||
| 54 | void IS31FL3736_mono_set_led_control_register(uint8_t index, bool enabled); | ||
| 55 | |||
| 56 | // This should not be called from an interrupt | ||
| 57 | // (eg. from a timer interrupt). | ||
| 58 | // Call this while idle (in between matrix scans). | ||
| 59 | // If the buffer is dirty, it will update the driver with the buffer. | ||
| 60 | void IS31FL3736_update_pwm_buffers(uint8_t addr1, uint8_t addr2); | ||
| 61 | void IS31FL3736_update_led_control_registers(uint8_t addr1, uint8_t addr2); | ||
| 62 | |||
| 63 | #define A_1 0x00 | ||
| 64 | #define A_2 0x02 | ||
| 65 | #define A_3 0x04 | ||
| 66 | #define A_4 0x06 | ||
| 67 | #define A_5 0x08 | ||
| 68 | #define A_6 0x0A | ||
| 69 | #define A_7 0x0C | ||
| 70 | #define A_8 0x0E | ||
| 71 | |||
| 72 | #define B_1 0x10 | ||
| 73 | #define B_2 0x12 | ||
| 74 | #define B_3 0x14 | ||
| 75 | #define B_4 0x16 | ||
| 76 | #define B_5 0x18 | ||
| 77 | #define B_6 0x1A | ||
| 78 | #define B_7 0x1C | ||
| 79 | #define B_8 0x1E | ||
| 80 | |||
| 81 | #define C_1 0x20 | ||
| 82 | #define C_2 0x22 | ||
| 83 | #define C_3 0x24 | ||
| 84 | #define C_4 0x26 | ||
| 85 | #define C_5 0x28 | ||
| 86 | #define C_6 0x2A | ||
| 87 | #define C_7 0x2C | ||
| 88 | #define C_8 0x2E | ||
| 89 | |||
| 90 | #define D_1 0x30 | ||
| 91 | #define D_2 0x32 | ||
| 92 | #define D_3 0x34 | ||
| 93 | #define D_4 0x36 | ||
| 94 | #define D_5 0x38 | ||
| 95 | #define D_6 0x3A | ||
| 96 | #define D_7 0x3C | ||
| 97 | #define D_8 0x3E | ||
| 98 | |||
| 99 | #define E_1 0x40 | ||
| 100 | #define E_2 0x42 | ||
| 101 | #define E_3 0x44 | ||
| 102 | #define E_4 0x46 | ||
| 103 | #define E_5 0x48 | ||
| 104 | #define E_6 0x4A | ||
| 105 | #define E_7 0x4C | ||
| 106 | #define E_8 0x4E | ||
| 107 | |||
| 108 | #define F_1 0x50 | ||
| 109 | #define F_2 0x52 | ||
| 110 | #define F_3 0x54 | ||
| 111 | #define F_4 0x56 | ||
| 112 | #define F_5 0x58 | ||
| 113 | #define F_6 0x5A | ||
| 114 | #define F_7 0x5C | ||
| 115 | #define F_8 0x5E | ||
| 116 | |||
| 117 | #define G_1 0x60 | ||
| 118 | #define G_2 0x62 | ||
| 119 | #define G_3 0x64 | ||
| 120 | #define G_4 0x66 | ||
| 121 | #define G_5 0x68 | ||
| 122 | #define G_6 0x6A | ||
| 123 | #define G_7 0x6C | ||
| 124 | #define G_8 0x6E | ||
| 125 | |||
| 126 | #define H_1 0x70 | ||
| 127 | #define H_2 0x72 | ||
| 128 | #define H_3 0x74 | ||
| 129 | #define H_4 0x76 | ||
| 130 | #define H_5 0x78 | ||
| 131 | #define H_6 0x7A | ||
| 132 | #define H_7 0x7C | ||
| 133 | #define H_8 0x7E | ||
| 134 | |||
| 135 | #define I_1 0x80 | ||
| 136 | #define I_2 0x82 | ||
| 137 | #define I_3 0x84 | ||
| 138 | #define I_4 0x86 | ||
| 139 | #define I_5 0x88 | ||
| 140 | #define I_6 0x8A | ||
| 141 | #define I_7 0x8C | ||
| 142 | #define I_8 0x8E | ||
| 143 | |||
| 144 | #define J_1 0x90 | ||
| 145 | #define J_2 0x92 | ||
| 146 | #define J_3 0x94 | ||
| 147 | #define J_4 0x96 | ||
| 148 | #define J_5 0x98 | ||
| 149 | #define J_6 0x9A | ||
| 150 | #define J_7 0x9C | ||
| 151 | #define J_8 0x9E | ||
| 152 | |||
| 153 | #define K_1 0xA0 | ||
| 154 | #define K_2 0xA2 | ||
| 155 | #define K_3 0xA4 | ||
| 156 | #define K_4 0xA6 | ||
| 157 | #define K_5 0xA8 | ||
| 158 | #define K_6 0xAA | ||
| 159 | #define K_7 0xAC | ||
| 160 | #define K_8 0xAE | ||
| 161 | |||
| 162 | #define L_1 0xB0 | ||
| 163 | #define L_2 0xB2 | ||
| 164 | #define L_3 0xB4 | ||
| 165 | #define L_4 0xB6 | ||
| 166 | #define L_5 0xB8 | ||
| 167 | #define L_6 0xBA | ||
| 168 | #define L_7 0xBC | ||
| 169 | #define L_8 0xBE | ||
