diff options
| author | Ryan <fauxpark@gmail.com> | 2023-09-17 22:11:16 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-09-17 22:11:16 +1000 |
| commit | 1ea54a2d8da9e64e5a2c1fd882a13058523b50bc (patch) | |
| tree | f76a5092995ae9a3440729135765625f50684f09 | |
| parent | 32126dc4f01142dbc61f52c9d225bb53faf2d12c (diff) | |
Complete RGB Matrix support for IS31FL3218 (#22004)
| -rw-r--r-- | builddefs/common_features.mk | 9 | ||||
| -rw-r--r-- | docs/reference_info_json.md | 2 | ||||
| -rw-r--r-- | drivers/led/issi/is31fl3218.c | 96 | ||||
| -rw-r--r-- | drivers/led/issi/is31fl3218.h | 38 | ||||
| -rw-r--r-- | keyboards/wilba_tech/rama_works_m60_a/keymaps/zyber/config.h | 4 | ||||
| -rw-r--r-- | keyboards/wilba_tech/rama_works_m6_b/config.h | 2 | ||||
| -rw-r--r-- | keyboards/wilba_tech/wt_rgb_backlight.c | 20 | ||||
| -rw-r--r-- | quantum/rgb_matrix/rgb_matrix.h | 4 | ||||
| -rw-r--r-- | quantum/rgb_matrix/rgb_matrix_drivers.c | 36 |
9 files changed, 178 insertions, 33 deletions
diff --git a/builddefs/common_features.mk b/builddefs/common_features.mk index 18f8b0bbfc..1597022d63 100644 --- a/builddefs/common_features.mk +++ b/builddefs/common_features.mk | |||
| @@ -416,7 +416,7 @@ endif | |||
| 416 | 416 | ||
| 417 | RGB_MATRIX_ENABLE ?= no | 417 | RGB_MATRIX_ENABLE ?= no |
| 418 | 418 | ||
| 419 | VALID_RGB_MATRIX_TYPES := aw20216s is31fl3731 is31fl3733 is31fl3736 is31fl3737 is31fl3741 is31fl3742a is31fl3743a is31fl3745 is31fl3746a ckled2001 ws2812 custom | 419 | VALID_RGB_MATRIX_TYPES := aw20216s is31fl3218 is31fl3731 is31fl3733 is31fl3736 is31fl3737 is31fl3741 is31fl3742a is31fl3743a is31fl3745 is31fl3746a ckled2001 ws2812 custom |
| 420 | ifeq ($(strip $(RGB_MATRIX_ENABLE)), yes) | 420 | ifeq ($(strip $(RGB_MATRIX_ENABLE)), yes) |
| 421 | ifeq ($(filter $(RGB_MATRIX_DRIVER),$(VALID_RGB_MATRIX_TYPES)),) | 421 | ifeq ($(filter $(RGB_MATRIX_DRIVER),$(VALID_RGB_MATRIX_TYPES)),) |
| 422 | $(call CATASTROPHIC_ERROR,Invalid RGB_MATRIX_DRIVER,RGB_MATRIX_DRIVER="$(RGB_MATRIX_DRIVER)" is not a valid matrix type) | 422 | $(call CATASTROPHIC_ERROR,Invalid RGB_MATRIX_DRIVER,RGB_MATRIX_DRIVER="$(RGB_MATRIX_DRIVER)" is not a valid matrix type) |
| @@ -444,6 +444,13 @@ endif | |||
| 444 | QUANTUM_LIB_SRC += spi_master.c | 444 | QUANTUM_LIB_SRC += spi_master.c |
| 445 | endif | 445 | endif |
| 446 | 446 | ||
| 447 | ifeq ($(strip $(RGB_MATRIX_DRIVER)), is31fl3218) | ||
| 448 | OPT_DEFS += -DIS31FL3218 -DSTM32_I2C -DHAL_USE_I2C=TRUE | ||
| 449 | COMMON_VPATH += $(DRIVER_PATH)/led/issi | ||
| 450 | SRC += is31fl3218.c | ||
| 451 | QUANTUM_LIB_SRC += i2c_master.c | ||
| 452 | endif | ||
| 453 | |||
| 447 | ifeq ($(strip $(RGB_MATRIX_DRIVER)), is31fl3731) | 454 | ifeq ($(strip $(RGB_MATRIX_DRIVER)), is31fl3731) |
| 448 | OPT_DEFS += -DIS31FL3731 -DSTM32_I2C -DHAL_USE_I2C=TRUE | 455 | OPT_DEFS += -DIS31FL3731 -DSTM32_I2C -DHAL_USE_I2C=TRUE |
| 449 | COMMON_VPATH += $(DRIVER_PATH)/led/issi | 456 | COMMON_VPATH += $(DRIVER_PATH)/led/issi |
diff --git a/docs/reference_info_json.md b/docs/reference_info_json.md index 9030c99aa6..c8cb72101e 100644 --- a/docs/reference_info_json.md +++ b/docs/reference_info_json.md | |||
| @@ -530,7 +530,7 @@ Configures the [RGB Matrix](feature_rgb_matrix.md) feature. | |||
| 530 | * The centroid (geometric center) of the LEDs. Used for certain effects. | 530 | * The centroid (geometric center) of the LEDs. Used for certain effects. |
| 531 | * Default: `[112, 32]` | 531 | * Default: `[112, 32]` |
| 532 | * `driver` (Required) | 532 | * `driver` (Required) |
| 533 | * The driver to use. Must be one of `aw20216s`, `ckled2001`, `custom`, `is31fl3731`, `is31fl3733`, `is31fl3736`, `is31fl3737`, `is31fl3741`, `is31fl3742a`, `is31fl3743a`, `is31fl3745`, `is31fl3746a`, `ws2812`. | 533 | * The driver to use. Must be one of `aw20216s`, `ckled2001`, `custom`, `is31fl3218`, `is31fl3731`, `is31fl3733`, `is31fl3736`, `is31fl3737`, `is31fl3741`, `is31fl3742a`, `is31fl3743a`, `is31fl3745`, `is31fl3746a`, `ws2812`. |
| 534 | * `hue_steps` | 534 | * `hue_steps` |
| 535 | * The number of hue adjustment steps. | 535 | * The number of hue adjustment steps. |
| 536 | * Default: `8` | 536 | * Default: `8` |
diff --git a/drivers/led/issi/is31fl3218.c b/drivers/led/issi/is31fl3218.c index 6072f6cecd..87a0acfc08 100644 --- a/drivers/led/issi/is31fl3218.c +++ b/drivers/led/issi/is31fl3218.c | |||
| @@ -14,11 +14,9 @@ | |||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 | */ | 15 | */ |
| 16 | #include "is31fl3218.h" | 16 | #include "is31fl3218.h" |
| 17 | #include <string.h> | ||
| 17 | #include "i2c_master.h" | 18 | #include "i2c_master.h" |
| 18 | 19 | ||
| 19 | // This is the full 8-bit address | ||
| 20 | #define IS31FL3218_I2C_ADDRESS 0xA8 | ||
| 21 | |||
| 22 | // These are the register addresses | 20 | // These are the register addresses |
| 23 | #define IS31FL3218_REG_SHUTDOWN 0x00 | 21 | #define IS31FL3218_REG_SHUTDOWN 0x00 |
| 24 | #define IS31FL3218_REG_PWM 0x01 | 22 | #define IS31FL3218_REG_PWM 0x01 |
| @@ -26,28 +24,47 @@ | |||
| 26 | #define IS31FL3218_REG_UPDATE 0x16 | 24 | #define IS31FL3218_REG_UPDATE 0x16 |
| 27 | #define IS31FL3218_REG_RESET 0x17 | 25 | #define IS31FL3218_REG_RESET 0x17 |
| 28 | 26 | ||
| 29 | // Default timeout if no I2C response | 27 | #ifndef IS31FL3218_I2C_TIMEOUT |
| 30 | #define IS31FL3218_I2C_TIMEOUT 100 | 28 | # define IS31FL3218_I2C_TIMEOUT 100 |
| 29 | #endif | ||
| 30 | |||
| 31 | #ifndef IS31FL3218_I2C_PERSISTENCE | ||
| 32 | # define IS31FL3218_I2C_PERSISTENCE 0 | ||
| 33 | #endif | ||
| 31 | 34 | ||
| 32 | // Reusable buffer for transfers | 35 | // Reusable buffer for transfers |
| 33 | uint8_t g_twi_transfer_buffer[20]; | 36 | uint8_t g_twi_transfer_buffer[20]; |
| 34 | 37 | ||
| 35 | // IS31FL3218 has 18 PWM outputs and a fixed I2C address, so no chaining. | 38 | // IS31FL3218 has 18 PWM outputs and a fixed I2C address, so no chaining. |
| 36 | // If used as RGB LED driver, LEDs are assigned RGB,RGB,RGB,RGB,RGB,RGB | ||
| 37 | uint8_t g_pwm_buffer[18]; | 39 | uint8_t g_pwm_buffer[18]; |
| 38 | bool g_pwm_buffer_update_required = false; | 40 | bool g_pwm_buffer_update_required = false; |
| 39 | 41 | ||
| 42 | uint8_t g_led_control_registers[3] = {0}; | ||
| 43 | bool g_led_control_registers_update_required = false; | ||
| 44 | |||
| 40 | void is31fl3218_write_register(uint8_t reg, uint8_t data) { | 45 | void is31fl3218_write_register(uint8_t reg, uint8_t data) { |
| 41 | g_twi_transfer_buffer[0] = reg; | 46 | g_twi_transfer_buffer[0] = reg; |
| 42 | g_twi_transfer_buffer[1] = data; | 47 | g_twi_transfer_buffer[1] = data; |
| 43 | i2c_transmit(IS31FL3218_I2C_ADDRESS, g_twi_transfer_buffer, 2, IS31FL3218_I2C_TIMEOUT); | 48 | #if IS31FL3218_I2C_PERSISTENCE > 0 |
| 49 | for (uint8_t i = 0; i < IS31FL3218_I2C_PERSISTENCE; i++) { | ||
| 50 | if (i2c_transmit(IS31FL3218_I2C_ADDRESS << 1, g_twi_transfer_buffer, 2, IS31FL3218_I2C_TIMEOUT) == 0) break; | ||
| 51 | } | ||
| 52 | #else | ||
| 53 | i2c_transmit(IS31FL3218_I2C_ADDRESS << 1, g_twi_transfer_buffer, 2, IS31FL3218_I2C_TIMEOUT); | ||
| 54 | #endif | ||
| 44 | } | 55 | } |
| 45 | 56 | ||
| 46 | void is31fl3218_write_pwm_buffer(uint8_t *pwm_buffer) { | 57 | void is31fl3218_write_pwm_buffer(uint8_t *pwm_buffer) { |
| 47 | g_twi_transfer_buffer[0] = IS31FL3218_REG_PWM; | 58 | g_twi_transfer_buffer[0] = IS31FL3218_REG_PWM; |
| 48 | memcpy(g_twi_transfer_buffer + 1, pwm_buffer, 18); | 59 | memcpy(g_twi_transfer_buffer + 1, pwm_buffer, 18); |
| 49 | 60 | ||
| 50 | i2c_transmit(IS31FL3218_I2C_ADDRESS, g_twi_transfer_buffer, 19, IS31FL3218_I2C_TIMEOUT); | 61 | #if IS31FL3218_I2C_PERSISTENCE > 0 |
| 62 | for (uint8_t i = 0; i < IS31FL3218_I2C_PERSISTENCE; i++) { | ||
| 63 | i2c_transmit(IS31FL3218_I2C_ADDRESS << 1, g_twi_transfer_buffer, 19, IS31FL3218_I2C_TIMEOUT); | ||
| 64 | } | ||
| 65 | #else | ||
| 66 | i2c_transmit(IS31FL3218_I2C_ADDRESS << 1, g_twi_transfer_buffer, 19, IS31FL3218_I2C_TIMEOUT); | ||
| 67 | #endif | ||
| 51 | } | 68 | } |
| 52 | 69 | ||
| 53 | void is31fl3218_init(void) { | 70 | void is31fl3218_init(void) { |
| @@ -62,9 +79,9 @@ void is31fl3218_init(void) { | |||
| 62 | is31fl3218_write_register(IS31FL3218_REG_PWM + i, 0x00); | 79 | is31fl3218_write_register(IS31FL3218_REG_PWM + i, 0x00); |
| 63 | } | 80 | } |
| 64 | 81 | ||
| 65 | // Enable all channels | 82 | // turn off all LEDs in the LED control register |
| 66 | for (uint8_t i = 0; i < 3; i++) { | 83 | for (uint8_t i = 0; i < 3; i++) { |
| 67 | is31fl3218_write_register(IS31FL3218_REG_CONTROL + i, 0b00111111); | 84 | is31fl3218_write_register(IS31FL3218_REG_CONTROL + i, 0x00); |
| 68 | } | 85 | } |
| 69 | 86 | ||
| 70 | // Load PWM registers and LED Control register data | 87 | // Load PWM registers and LED Control register data |
| @@ -72,26 +89,71 @@ void is31fl3218_init(void) { | |||
| 72 | } | 89 | } |
| 73 | 90 | ||
| 74 | void is31fl3218_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) { | 91 | void is31fl3218_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) { |
| 75 | if (g_pwm_buffer[index * 3 + 0] == red && g_pwm_buffer[index * 3 + 1] == green && g_pwm_buffer[index * 3 + 2] == blue) { | 92 | is31fl3218_led_t led; |
| 93 | if (index >= 0 && index < RGB_MATRIX_LED_COUNT) { | ||
| 94 | memcpy_P(&led, (&g_is31fl3218_leds[index]), sizeof(led)); | ||
| 95 | } | ||
| 96 | if (g_pwm_buffer[led.r - IS31FL3218_REG_PWM] == red && g_pwm_buffer[led.g - IS31FL3218_REG_PWM] == green && g_pwm_buffer[led.b - IS31FL3218_REG_PWM] == blue) { | ||
| 76 | return; | 97 | return; |
| 77 | } | 98 | } |
| 78 | g_pwm_buffer[index * 3 + 0] = red; | 99 | g_pwm_buffer[led.r - IS31FL3218_REG_PWM] = red; |
| 79 | g_pwm_buffer[index * 3 + 1] = green; | 100 | g_pwm_buffer[led.g - IS31FL3218_REG_PWM] = green; |
| 80 | g_pwm_buffer[index * 3 + 2] = blue; | 101 | g_pwm_buffer[led.b - IS31FL3218_REG_PWM] = blue; |
| 81 | g_pwm_buffer_update_required = true; | 102 | g_pwm_buffer_update_required = true; |
| 82 | } | 103 | } |
| 83 | 104 | ||
| 84 | void is31fl3218_set_color_all(uint8_t red, uint8_t green, uint8_t blue) { | 105 | void is31fl3218_set_color_all(uint8_t red, uint8_t green, uint8_t blue) { |
| 85 | for (int i = 0; i < 6; i++) { | 106 | for (int i = 0; i < RGB_MATRIX_LED_COUNT; i++) { |
| 86 | is31fl3218_set_color(i, red, green, blue); | 107 | is31fl3218_set_color(i, red, green, blue); |
| 87 | } | 108 | } |
| 88 | } | 109 | } |
| 89 | 110 | ||
| 111 | void is31fl3218_set_led_control_register(uint8_t index, bool red, bool green, bool blue) { | ||
| 112 | is31fl3218_led_t led; | ||
| 113 | memcpy_P(&led, (&g_is31fl3218_leds[index]), sizeof(led)); | ||
| 114 | |||
| 115 | uint8_t control_register_r = (led.r - IS31FL3218_REG_PWM) / 6; | ||
| 116 | uint8_t control_register_g = (led.g - IS31FL3218_REG_PWM) / 6; | ||
| 117 | uint8_t control_register_b = (led.b - IS31FL3218_REG_PWM) / 6; | ||
| 118 | uint8_t bit_r = (led.r - IS31FL3218_REG_PWM) % 6; | ||
| 119 | uint8_t bit_g = (led.g - IS31FL3218_REG_PWM) % 6; | ||
| 120 | uint8_t bit_b = (led.b - IS31FL3218_REG_PWM) % 6; | ||
| 121 | |||
| 122 | if (red) { | ||
| 123 | g_led_control_registers[control_register_r] |= (1 << bit_r); | ||
| 124 | } else { | ||
| 125 | g_led_control_registers[control_register_r] &= ~(1 << bit_r); | ||
| 126 | } | ||
| 127 | if (green) { | ||
| 128 | g_led_control_registers[control_register_g] |= (1 << bit_g); | ||
| 129 | } else { | ||
| 130 | g_led_control_registers[control_register_g] &= ~(1 << bit_g); | ||
| 131 | } | ||
| 132 | if (blue) { | ||
| 133 | g_led_control_registers[control_register_b] |= (1 << bit_b); | ||
| 134 | } else { | ||
| 135 | g_led_control_registers[control_register_b] &= ~(1 << bit_b); | ||
| 136 | } | ||
| 137 | |||
| 138 | g_led_control_registers_update_required = true; | ||
| 139 | } | ||
| 140 | |||
| 90 | void is31fl3218_update_pwm_buffers(void) { | 141 | void is31fl3218_update_pwm_buffers(void) { |
| 91 | if (g_pwm_buffer_update_required) { | 142 | if (g_pwm_buffer_update_required) { |
| 92 | is31fl3218_write_pwm_buffer(g_pwm_buffer); | 143 | is31fl3218_write_pwm_buffer(g_pwm_buffer); |
| 93 | // Load PWM registers and LED Control register data | 144 | // Load PWM registers and LED Control register data |
| 94 | is31fl3218_write_register(IS31FL3218_REG_UPDATE, 0x01); | 145 | is31fl3218_write_register(IS31FL3218_REG_UPDATE, 0x01); |
| 146 | |||
| 147 | g_pwm_buffer_update_required = false; | ||
| 148 | } | ||
| 149 | } | ||
| 150 | |||
| 151 | void is31fl3218_update_led_control_registers(void) { | ||
| 152 | if (g_led_control_registers_update_required) { | ||
| 153 | for (int i = 0; i < 3; i++) { | ||
| 154 | is31fl3218_write_register(IS31FL3218_REG_CONTROL + i, g_led_control_registers[i]); | ||
| 155 | } | ||
| 156 | |||
| 157 | g_led_control_registers_update_required = false; | ||
| 95 | } | 158 | } |
| 96 | g_pwm_buffer_update_required = false; | ||
| 97 | } | 159 | } |
diff --git a/drivers/led/issi/is31fl3218.h b/drivers/led/issi/is31fl3218.h index 2fe3768432..a5ac44fd1d 100644 --- a/drivers/led/issi/is31fl3218.h +++ b/drivers/led/issi/is31fl3218.h | |||
| @@ -18,9 +18,45 @@ | |||
| 18 | 18 | ||
| 19 | #include <stdint.h> | 19 | #include <stdint.h> |
| 20 | #include <stdbool.h> | 20 | #include <stdbool.h> |
| 21 | #include <string.h> | 21 | #include "progmem.h" |
| 22 | |||
| 23 | #define IS31FL3218_I2C_ADDRESS 0x54 | ||
| 24 | |||
| 25 | typedef struct is31fl3218_led_t { | ||
| 26 | uint8_t r; | ||
| 27 | uint8_t g; | ||
| 28 | uint8_t b; | ||
| 29 | } __attribute__((packed)) is31fl3218_led_t; | ||
| 30 | |||
| 31 | extern const is31fl3218_led_t PROGMEM g_is31fl3218_leds[RGB_MATRIX_LED_COUNT]; | ||
| 22 | 32 | ||
| 23 | void is31fl3218_init(void); | 33 | void is31fl3218_init(void); |
| 34 | |||
| 24 | void is31fl3218_set_color(int index, uint8_t red, uint8_t green, uint8_t blue); | 35 | void is31fl3218_set_color(int index, uint8_t red, uint8_t green, uint8_t blue); |
| 36 | |||
| 25 | void is31fl3218_set_color_all(uint8_t red, uint8_t green, uint8_t blue); | 37 | void is31fl3218_set_color_all(uint8_t red, uint8_t green, uint8_t blue); |
| 38 | |||
| 39 | void is31fl3218_set_led_control_register(uint8_t index, bool red, bool green, bool blue); | ||
| 40 | |||
| 26 | void is31fl3218_update_pwm_buffers(void); | 41 | void is31fl3218_update_pwm_buffers(void); |
| 42 | |||
| 43 | void is31fl3218_update_led_control_registers(void); | ||
| 44 | |||
| 45 | #define OUT1 0x01 | ||
| 46 | #define OUT2 0x02 | ||
| 47 | #define OUT3 0x03 | ||
| 48 | #define OUT4 0x04 | ||
| 49 | #define OUT5 0x05 | ||
| 50 | #define OUT6 0x06 | ||
| 51 | #define OUT7 0x07 | ||
| 52 | #define OUT8 0x08 | ||
| 53 | #define OUT9 0x09 | ||
| 54 | #define OUT10 0x0A | ||
| 55 | #define OUT11 0x0B | ||
| 56 | #define OUT12 0x0C | ||
| 57 | #define OUT13 0x0D | ||
| 58 | #define OUT14 0x0E | ||
| 59 | #define OUT15 0x0F | ||
| 60 | #define OUT16 0x10 | ||
| 61 | #define OUT17 0x11 | ||
| 62 | #define OUT18 0x12 | ||
diff --git a/keyboards/wilba_tech/rama_works_m60_a/keymaps/zyber/config.h b/keyboards/wilba_tech/rama_works_m60_a/keymaps/zyber/config.h index 9ad052aab4..d34eafbaeb 100644 --- a/keyboards/wilba_tech/rama_works_m60_a/keymaps/zyber/config.h +++ b/keyboards/wilba_tech/rama_works_m60_a/keymaps/zyber/config.h | |||
| @@ -3,6 +3,4 @@ | |||
| 3 | 3 | ||
| 4 | #pragma once | 4 | #pragma once |
| 5 | #undef PRODUCT | 5 | #undef PRODUCT |
| 6 | #define PRODUCT RAMA WORKS M60-A Seq2 | 6 | #define PRODUCT "RAMA WORKS M60-A Seq2" |
| 7 | #undef DESCRIPTION | ||
| 8 | #define DESCRIPTION RAMA WORKS M60-A Seq2 | ||
diff --git a/keyboards/wilba_tech/rama_works_m6_b/config.h b/keyboards/wilba_tech/rama_works_m6_b/config.h index a117bcc2a8..27a5e72c04 100644 --- a/keyboards/wilba_tech/rama_works_m6_b/config.h +++ b/keyboards/wilba_tech/rama_works_m6_b/config.h | |||
| @@ -20,6 +20,8 @@ | |||
| 20 | /* Locking resynchronize hack */ | 20 | /* Locking resynchronize hack */ |
| 21 | #define LOCKING_RESYNC_ENABLE | 21 | #define LOCKING_RESYNC_ENABLE |
| 22 | 22 | ||
| 23 | #define RGB_MATRIX_LED_COUNT 6 | ||
| 24 | |||
| 23 | #define RGB_BACKLIGHT_ENABLED 1 | 25 | #define RGB_BACKLIGHT_ENABLED 1 |
| 24 | 26 | ||
| 25 | // This conditionally compiles the backlight code for M6-B specifics | 27 | // This conditionally compiles the backlight code for M6-B specifics |
diff --git a/keyboards/wilba_tech/wt_rgb_backlight.c b/keyboards/wilba_tech/wt_rgb_backlight.c index d2ec610df8..8a0f3b7f91 100644 --- a/keyboards/wilba_tech/wt_rgb_backlight.c +++ b/keyboards/wilba_tech/wt_rgb_backlight.c | |||
| @@ -834,7 +834,14 @@ const is31_led PROGMEM g_is31_leds[RGB_MATRIX_LED_COUNT] = { | |||
| 834 | }; | 834 | }; |
| 835 | 835 | ||
| 836 | #elif defined(RGB_BACKLIGHT_M6_B) | 836 | #elif defined(RGB_BACKLIGHT_M6_B) |
| 837 | // Driver has fixed mapping of index to the red, green and blue LEDs | 837 | const is31fl3218_led_t PROGMEM g_is31fl3218_leds[RGB_MATRIX_LED_COUNT] = { |
| 838 | {OUT1, OUT2, OUT3}, | ||
| 839 | {OUT4, OUT5, OUT6}, | ||
| 840 | {OUT7, OUT8, OUT9}, | ||
| 841 | {OUT10, OUT11, OUT12}, | ||
| 842 | {OUT13, OUT14, OUT15}, | ||
| 843 | {OUT16, OUT17, OUT18} | ||
| 844 | }; | ||
| 838 | #elif defined(RGB_BACKLIGHT_M10_C) | 845 | #elif defined(RGB_BACKLIGHT_M10_C) |
| 839 | // This is a 7-bit address, that gets left-shifted and bit 0 | 846 | // This is a 7-bit address, that gets left-shifted and bit 0 |
| 840 | // set to 0 for write, 1 for read (as per I2C protocol) | 847 | // set to 0 for write, 1 for read (as per I2C protocol) |
| @@ -2915,6 +2922,17 @@ void backlight_init_drivers(void) | |||
| 2915 | 2922 | ||
| 2916 | #if defined(RGB_BACKLIGHT_M6_B) | 2923 | #if defined(RGB_BACKLIGHT_M6_B) |
| 2917 | is31fl3218_init(); | 2924 | is31fl3218_init(); |
| 2925 | |||
| 2926 | for ( int index = 0; index < RGB_MATRIX_LED_COUNT; index++ ) | ||
| 2927 | { | ||
| 2928 | bool enabled = true; | ||
| 2929 | |||
| 2930 | // This only caches it for later | ||
| 2931 | is31fl3218_set_led_control_register( index, enabled, enabled, enabled ); | ||
| 2932 | } | ||
| 2933 | |||
| 2934 | // This actually updates the LED drivers | ||
| 2935 | is31fl3218_update_led_control_registers(); | ||
| 2918 | #elif defined(RGB_BACKLIGHT_HS60) | 2936 | #elif defined(RGB_BACKLIGHT_HS60) |
| 2919 | is31fl3733_init( ISSI_ADDR_1, 0 ); | 2937 | is31fl3733_init( ISSI_ADDR_1, 0 ); |
| 2920 | 2938 | ||
diff --git a/quantum/rgb_matrix/rgb_matrix.h b/quantum/rgb_matrix/rgb_matrix.h index ab5184fe18..377f6658bb 100644 --- a/quantum/rgb_matrix/rgb_matrix.h +++ b/quantum/rgb_matrix/rgb_matrix.h | |||
| @@ -24,7 +24,9 @@ | |||
| 24 | #include "color.h" | 24 | #include "color.h" |
| 25 | #include "keyboard.h" | 25 | #include "keyboard.h" |
| 26 | 26 | ||
| 27 | #ifdef IS31FL3731 | 27 | #if defined(IS31FL3218) |
| 28 | # include "is31fl3218.h" | ||
| 29 | #elif defined(IS31FL3731) | ||
| 28 | # include "is31fl3731.h" | 30 | # include "is31fl3731.h" |
| 29 | #elif defined(IS31FL3733) | 31 | #elif defined(IS31FL3733) |
| 30 | # include "is31fl3733.h" | 32 | # include "is31fl3733.h" |
diff --git a/quantum/rgb_matrix/rgb_matrix_drivers.c b/quantum/rgb_matrix/rgb_matrix_drivers.c index 67330434ed..a81edce180 100644 --- a/quantum/rgb_matrix/rgb_matrix_drivers.c +++ b/quantum/rgb_matrix/rgb_matrix_drivers.c | |||
| @@ -24,7 +24,7 @@ | |||
| 24 | * be here if shared between boards. | 24 | * be here if shared between boards. |
| 25 | */ | 25 | */ |
| 26 | 26 | ||
| 27 | #if defined(IS31FL3731) || defined(IS31FL3733) || defined(IS31FL3736) || defined(IS31FL3737) || defined(IS31FL3741) || defined(IS31FLCOMMON) || defined(CKLED2001) | 27 | #if defined(IS31FL3218) || defined(IS31FL3731) || defined(IS31FL3733) || defined(IS31FL3736) || defined(IS31FL3737) || defined(IS31FL3741) || defined(IS31FLCOMMON) || defined(CKLED2001) |
| 28 | # include "i2c_master.h" | 28 | # include "i2c_master.h" |
| 29 | 29 | ||
| 30 | // TODO: Remove this at some later date | 30 | // TODO: Remove this at some later date |
| @@ -37,7 +37,10 @@ | |||
| 37 | static void init(void) { | 37 | static void init(void) { |
| 38 | i2c_init(); | 38 | i2c_init(); |
| 39 | 39 | ||
| 40 | # if defined(IS31FL3731) | 40 | # if defined(IS31FL3218) |
| 41 | is31fl3218_init(); | ||
| 42 | |||
| 43 | # elif defined(IS31FL3731) | ||
| 41 | is31fl3731_init(DRIVER_ADDR_1); | 44 | is31fl3731_init(DRIVER_ADDR_1); |
| 42 | # if defined(DRIVER_ADDR_2) | 45 | # if defined(DRIVER_ADDR_2) |
| 43 | is31fl3731_init(DRIVER_ADDR_2); | 46 | is31fl3731_init(DRIVER_ADDR_2); |
| @@ -138,7 +141,9 @@ static void init(void) { | |||
| 138 | bool enabled = true; | 141 | bool enabled = true; |
| 139 | 142 | ||
| 140 | // This only caches it for later | 143 | // This only caches it for later |
| 141 | # if defined(IS31FL3731) | 144 | # if defined(IS31FL3218) |
| 145 | is31fl3218_set_led_control_register(index, enabled, enabled, enabled); | ||
| 146 | # elif defined(IS31FL3731) | ||
| 142 | is31fl3731_set_led_control_register(index, enabled, enabled, enabled); | 147 | is31fl3731_set_led_control_register(index, enabled, enabled, enabled); |
| 143 | # elif defined(IS31FL3733) | 148 | # elif defined(IS31FL3733) |
| 144 | is31fl3733_set_led_control_register(index, enabled, enabled, enabled); | 149 | is31fl3733_set_led_control_register(index, enabled, enabled, enabled); |
| @@ -156,7 +161,10 @@ static void init(void) { | |||
| 156 | } | 161 | } |
| 157 | 162 | ||
| 158 | // This actually updates the LED drivers | 163 | // This actually updates the LED drivers |
| 159 | # if defined(IS31FL3731) | 164 | # if defined(IS31FL3218) |
| 165 | is31fl3218_update_led_control_registers(); | ||
| 166 | |||
| 167 | # elif defined(IS31FL3731) | ||
| 160 | is31fl3731_update_led_control_registers(DRIVER_ADDR_1, 0); | 168 | is31fl3731_update_led_control_registers(DRIVER_ADDR_1, 0); |
| 161 | # if defined(DRIVER_ADDR_2) | 169 | # if defined(DRIVER_ADDR_2) |
| 162 | is31fl3731_update_led_control_registers(DRIVER_ADDR_2, 1); | 170 | is31fl3731_update_led_control_registers(DRIVER_ADDR_2, 1); |
| @@ -245,7 +253,19 @@ static void init(void) { | |||
| 245 | # endif | 253 | # endif |
| 246 | } | 254 | } |
| 247 | 255 | ||
| 248 | # if defined(IS31FL3731) | 256 | # if defined(IS31FL3218) |
| 257 | static void flush(void) { | ||
| 258 | is31fl3218_update_pwm_buffers(); | ||
| 259 | } | ||
| 260 | |||
| 261 | const rgb_matrix_driver_t rgb_matrix_driver = { | ||
| 262 | .init = init, | ||
| 263 | .flush = flush, | ||
| 264 | .set_color = is31fl3218_set_color, | ||
| 265 | .set_color_all = is31fl3218_set_color_all, | ||
| 266 | }; | ||
| 267 | |||
| 268 | # elif defined(IS31FL3731) | ||
| 249 | static void flush(void) { | 269 | static void flush(void) { |
| 250 | is31fl3731_update_pwm_buffers(DRIVER_ADDR_1, 0); | 270 | is31fl3731_update_pwm_buffers(DRIVER_ADDR_1, 0); |
| 251 | # if defined(DRIVER_ADDR_2) | 271 | # if defined(DRIVER_ADDR_2) |
| @@ -260,9 +280,9 @@ static void flush(void) { | |||
| 260 | } | 280 | } |
| 261 | 281 | ||
| 262 | const rgb_matrix_driver_t rgb_matrix_driver = { | 282 | const rgb_matrix_driver_t rgb_matrix_driver = { |
| 263 | .init = init, | 283 | .init = init, |
| 264 | .flush = flush, | 284 | .flush = flush, |
| 265 | .set_color = is31fl3731_set_color, | 285 | .set_color = is31fl3731_set_color, |
| 266 | .set_color_all = is31fl3731_set_color_all, | 286 | .set_color_all = is31fl3731_set_color_all, |
| 267 | }; | 287 | }; |
| 268 | 288 | ||
