Browse Source

Fixed docs. Added g_is31_leds

pull/12998/head
Electro707 1 year ago
parent
commit
fca7e229b9
No known key found for this signature in database GPG Key ID: 926141A472DD67F
3 changed files with 105 additions and 37 deletions
  1. +46
    -31
      docs/feature_rgb_matrix.md
  2. +12
    -6
      drivers/led/issi/is31fl3236.c
  3. +47
    -0
      drivers/led/issi/is31fl3236.h

+ 46
- 31
docs/feature_rgb_matrix.md View File

@ -5,37 +5,6 @@ This feature allows you to use RGB LED matrices driven by external drivers. It h
If you want to use single color LED's you should use the [LED Matrix Subsystem](feature_led_matrix.md) instead.
## Driver configuration :id=driver-configuration
---
# IS31FL3236 :id=is31fl3236
There is basic support for addressable RGB matrix lighting with the I2C IS31FL3236 RGB controller. To enable it, add this to your `rules.mk`:
```makefile
RGB_MATRIX_ENABLE = yes
RGB_MATRIX_DRIVER = IS31FL3236
```
Configure the hardware via your `config.h`:
```c
// This is a 7-bit address, that gets left-shifted and bit 0
// set to 0 for write, 1 for read (as per I2C protocol)
// The address will vary depending on your wiring:
// 00 <-> GND
// 01 <-> SCL
// 10 <-> SDA
// 11 <-> VCC
// ADDR1 represents A1:A0 of the 7-bit address.
// The result is: 0b01111(ADDR1)
#define DRIVER_ADDR_1 0b01111000
#define DRIVER_LED_TOTAL 36
```
Currently only a single drivers is supported, but it would be trivial to support all 4 combinations.
The RGB LEDs are assumed to be connected in an _RGB,RGB,RGB,..._ fashion sequentially from OUT1 to OUTx (where x is the total number of LEDs, 3 per RGB LED)
---
### IS31FL3731 :id=is31fl3731
@ -264,6 +233,52 @@ const is31_led PROGMEM g_is31_leds[DRIVER_LED_TOTAL] = {
Where `X_Y` is the location of the LED in the matrix defined by [the datasheet](https://www.issi.com/WW/pdf/31FL3737.pdf) and the header file `drivers/led/issi/is31fl3737.h`. The `driver` is the index of the driver you defined in your `config.h` (Only `0`, `1` for now).
---
### IS31FL3236 :id=is31fl3236
There is basic support for addressable RGB matrix lighting with the I2C IS31FL3236 RGB controller. To enable it, add this to your `rules.mk`:
```makefile
RGB_MATRIX_ENABLE = yes
RGB_MATRIX_DRIVER = IS31FL3236
```
Configure the hardware via your `config.h`:
```c
// This is a 7-bit address, that gets left-shifted and bit 0
// set to 0 for write, 1 for read (as per I2C protocol)
// The address will vary depending on your wiring:
// 00 <-> GND
// 01 <-> SCL
// 10 <-> SDA
// 11 <-> VCC
// ADDR1 represents A1:A0 of the 7-bit address.
// The result is: 0b01111(ADDR1)
#define DRIVER_ADDR_1 0b01111000
#define DRIVER_LED_TOTAL 12
```
Currently only a single drivers is supported, but it would be trivial to support all 4 combinations.
Define these arrays listing all the LEDs in your `<keyboard>.c`:
```c
const is31_led PROGMEM g_is31_leds[DRIVER_LED_TOTAL] = {
/* Refer to IS31 manual for these locations
* driver
* | R location
* | | G location
* | | | B location
* | | | | */
{0, OUT_1, OUT_2, OUT_3},
....
}
```
Where `OUT_X` is pin of the LED defined by [the datasheet](https://www.issi.com/WW/pdf/31FL3236.pdf) and the header file `drivers/led/issi/is31fl3236.h`. The `driver` is the index of the driver you defined in your `config.h` (Only `0` for now).
---
### IS31FLCOMMON :id=is31flcommon


+ 12
- 6
drivers/led/issi/is31fl3236.c View File

@ -91,9 +91,12 @@ void IS31FL3236_init(uint8_t addr) {
}
void IS31FL3236_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
g_pwm_buffer[index * 3 + 0] = red;
g_pwm_buffer[index * 3 + 1] = green;
g_pwm_buffer[index * 3 + 2] = blue;
is31_led led;
memcpy_P(&led, (&g_is31_leds[index]), sizeof(led));
g_pwm_buffer[led.r] = red;
g_pwm_buffer[led.g] = green;
g_pwm_buffer[led.b] = blue;
g_pwm_buffer_update_required = true;
}
@ -104,9 +107,12 @@ void IS31FL3236_set_color_all(uint8_t red, uint8_t green, uint8_t blue) {
}
void IS31FL3236_set_led_control_register(uint8_t index, bool red, bool green, bool blue) {
g_led_control_registers[index * 3 + 0] = red;
g_led_control_registers[index * 3 + 1] = green;
g_led_control_registers[index * 3 + 2] = blue;
is31_led led;
memcpy_P(&led, (&g_is31_leds[index]), sizeof(led));
g_led_control_registers[led.r] = red;
g_led_control_registers[led.g] = green;
g_led_control_registers[led.b] = blue;
g_led_control_update_required = true;
}


+ 47
- 0
drivers/led/issi/is31fl3236.h View File

@ -19,6 +19,16 @@
#include <stdint.h>
#include <stdbool.h>
#include "progmem.h"
typedef struct is31_led {
uint8_t driver : 2;
uint8_t r;
uint8_t g;
uint8_t b;
} __attribute__((packed)) is31_led;
extern const is31_led PROGMEM g_is31_leds[DRIVER_LED_TOTAL];
void IS31FL3236_init(uint8_t addr);
void IS31FL3236_set_color(int index, uint8_t red, uint8_t green, uint8_t blue);
@ -27,3 +37,40 @@ void IS31FL3236_update_pwm_buffers(uint8_t addr);
void IS31FL3236_set_led_control_register(uint8_t index, bool red, bool green, bool blue);
void IS31FL3236_update_led_control_registers(uint8_t addr);
#define OUT_1 0
#define OUT_2 1
#define OUT_3 2
#define OUT_4 3
#define OUT_5 4
#define OUT_6 5
#define OUT_7 6
#define OUT_8 7
#define OUT_9 8
#define OUT_10 9
#define OUT_11 10
#define OUT_12 11
#define OUT_13 12
#define OUT_14 13
#define OUT_15 14
#define OUT_16 15
#define OUT_17 16
#define OUT_18 17
#define OUT_19 18
#define OUT_20 19
#define OUT_21 20
#define OUT_22 21
#define OUT_23 22
#define OUT_24 23
#define OUT_25 24
#define OUT_26 25
#define OUT_27 26
#define OUT_28 27
#define OUT_29 28
#define OUT_30 29
#define OUT_31 30
#define OUT_32 31
#define OUT_33 32
#define OUT_34 33
#define OUT_35 34
#define OUT_36 35

Loading…
Cancel
Save