Skip to content

Commit

Permalink
Update ISSI LED types (qmk#22099)
Browse files Browse the repository at this point in the history
  • Loading branch information
fauxpark authored and Lorenzo Castoldi committed Dec 27, 2023
1 parent bafe0c1 commit da4f935
Show file tree
Hide file tree
Showing 148 changed files with 262 additions and 239 deletions.
4 changes: 2 additions & 2 deletions docs/feature_led_matrix.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ Here is an example using 2 drivers.
!> Note the parentheses, this is so when `LED_MATRIX_LED_COUNT` is used in code and expanded, the values are added together before any additional math is applied to them. As an example, `rand() % (LED_DRIVER_1_LED_TOTAL + LED_DRIVER_2_LED_TOTAL)` will give very different results than `rand() % LED_DRIVER_1_LED_TOTAL + LED_DRIVER_2_LED_TOTAL`.
For split keyboards using `LED_MATRIX_SPLIT` with an LED driver, you can either have the same driver address or different driver addresses. If using different addresses, use `DRIVER_ADDR_1` for one and `DRIVER_ADDR_2` for the other one. Then, in `g_is31_leds`, fill out the correct driver index (0 or 1). If using one address, use `DRIVER_ADDR_1` for both, and use index 0 for `g_is31_leds`.
For split keyboards using `LED_MATRIX_SPLIT` with an LED driver, you can either have the same driver address or different driver addresses. If using different addresses, use `DRIVER_ADDR_1` for one and `DRIVER_ADDR_2` for the other one. Then, in `g_is31fl3731_leds`, fill out the correct driver index (0 or 1). If using one address, use `DRIVER_ADDR_1` for both, and use index 0 for `g_is31fl3731_leds`.
Define these arrays listing all the LEDs in your `<keyboard>.c`:
```c
const is31_led PROGMEM g_is31_leds[LED_MATRIX_LED_COUNT] = {
const is31fl3731_led_t PROGMEM g_is31fl3731_leds[LED_MATRIX_LED_COUNT] = {
/* Refer to IS31 manual for these locations
* driver
* | LED address
Expand Down
10 changes: 5 additions & 5 deletions docs/feature_rgb_matrix.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ Here is an example using 2 drivers.
!> Note the parentheses, this is so when `RGB_MATRIX_LED_COUNT` is used in code and expanded, the values are added together before any additional math is applied to them. As an example, `rand() % (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)` will give very different results than `rand() % DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL`.
For split keyboards using `RGB_MATRIX_SPLIT` with an LED driver, you can either have the same driver address or different driver addresses. If using different addresses, use `DRIVER_ADDR_1` for one and `DRIVER_ADDR_2` for the other one. Then, in `g_is31_leds`, fill out the correct driver index (0 or 1). If using one address, use `DRIVER_ADDR_1` for both, and use index 0 for `g_is31_leds`.
For split keyboards using `RGB_MATRIX_SPLIT` with an LED driver, you can either have the same driver address or different driver addresses. If using different addresses, use `DRIVER_ADDR_1` for one and `DRIVER_ADDR_2` for the other one. Then, in `g_is31fl3731_leds`, fill out the correct driver index (0 or 1). If using one address, use `DRIVER_ADDR_1` for both, and use index 0 for `g_is31fl3731_leds`.
Define these arrays listing all the LEDs in your `<keyboard>.c`:
```c
const is31_led PROGMEM g_is31_leds[RGB_MATRIX_LED_COUNT] = {
const is31fl3731_led_t PROGMEM g_is31fl3731_leds[RGB_MATRIX_LED_COUNT] = {
/* Refer to IS31 manual for these locations
* driver
* | R location
Expand Down Expand Up @@ -143,7 +143,7 @@ Currently only 4 drivers are supported, but it would be trivial to support all 8
Define these arrays listing all the LEDs in your `<keyboard>.c`:
```c
const is31_led PROGMEM g_is31_leds[RGB_MATRIX_LED_COUNT] = {
const is31fl3733_led_t PROGMEM g_is31fl3733_leds[RGB_MATRIX_LED_COUNT] = {
/* Refer to IS31 manual for these locations
* driver
* | R location
Expand Down Expand Up @@ -224,7 +224,7 @@ Here is an example using 2 drivers.
Define these arrays listing all the LEDs in your `<keyboard>.c`:
```c
const is31_led PROGMEM g_is31_leds[RGB_MATRIX_LED_COUNT] = {
const is31fl3736_led_t PROGMEM g_is31fl3736_leds[RGB_MATRIX_LED_COUNT] = {
/* Refer to IS31 manual for these locations
* driver
* | R location
Expand Down Expand Up @@ -300,7 +300,7 @@ Here is an example using 2 drivers.
Define these arrays listing all the LEDs in your `<keyboard>.c`:
```c
const is31_led PROGMEM g_is31_leds[RGB_MATRIX_LED_COUNT] = {
const is31fl3737_led_t PROGMEM g_is31fl3737_leds[RGB_MATRIX_LED_COUNT] = {
/* Refer to IS31 manual for these locations
* driver
* | R location
Expand Down
8 changes: 4 additions & 4 deletions drivers/led/issi/is31fl3731-simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,9 @@ void is31fl3731_init(uint8_t addr) {
}

void is31fl3731_set_value(int index, uint8_t value) {
is31_led led;
is31fl3731_led_t led;
if (index >= 0 && index < LED_MATRIX_LED_COUNT) {
memcpy_P(&led, (&g_is31_leds[index]), sizeof(led));
memcpy_P(&led, (&g_is31fl3731_leds[index]), sizeof(led));

// Subtract 0x24 to get the second index of g_pwm_buffer

Expand All @@ -181,8 +181,8 @@ void is31fl3731_set_value_all(uint8_t value) {
}

void is31fl3731_set_led_control_register(uint8_t index, bool value) {
is31_led led;
memcpy_P(&led, (&g_is31_leds[index]), sizeof(led));
is31fl3731_led_t led;
memcpy_P(&led, (&g_is31fl3731_leds[index]), sizeof(led));

uint8_t control_register = (led.v - 0x24) / 8;
uint8_t bit_value = (led.v - 0x24) % 8;
Expand Down
9 changes: 6 additions & 3 deletions drivers/led/issi/is31fl3731-simple.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,22 @@
#ifdef ISSI_3731_DEGHOST
# define IS31FL3731_DEGHOST ISSI_3731_DEGHOST
#endif

#define is31_led is31fl3731_led_t
#define g_is31_leds g_is31fl3731_leds
// ========

#define IS31FL3731_I2C_ADDRESS_GND 0x74
#define IS31FL3731_I2C_ADDRESS_SCL 0x75
#define IS31FL3731_I2C_ADDRESS_SDA 0x76
#define IS31FL3731_I2C_ADDRESS_VCC 0x77

typedef struct is31_led {
typedef struct is31fl3731_led_t {
uint8_t driver : 2;
uint8_t v;
} __attribute__((packed)) is31_led;
} __attribute__((packed)) is31fl3731_led_t;

extern const is31_led PROGMEM g_is31_leds[LED_MATRIX_LED_COUNT];
extern const is31fl3731_led_t PROGMEM g_is31fl3731_leds[LED_MATRIX_LED_COUNT];

void is31fl3731_init(uint8_t addr);
void is31fl3731_write_register(uint8_t addr, uint8_t reg, uint8_t data);
Expand Down
8 changes: 4 additions & 4 deletions drivers/led/issi/is31fl3731.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ void is31fl3731_init(uint8_t addr) {
}

void is31fl3731_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
is31_led led;
is31fl3731_led_t led;
if (index >= 0 && index < RGB_MATRIX_LED_COUNT) {
memcpy_P(&led, (&g_is31_leds[index]), sizeof(led));
memcpy_P(&led, (&g_is31fl3731_leds[index]), sizeof(led));

// Subtract 0x24 to get the second index of g_pwm_buffer
if (g_pwm_buffer[led.driver][led.r - 0x24] == red && g_pwm_buffer[led.driver][led.g - 0x24] == green && g_pwm_buffer[led.driver][led.b - 0x24] == blue) {
Expand All @@ -179,8 +179,8 @@ void is31fl3731_set_color_all(uint8_t red, uint8_t green, uint8_t blue) {
}

void is31fl3731_set_led_control_register(uint8_t index, bool red, bool green, bool blue) {
is31_led led;
memcpy_P(&led, (&g_is31_leds[index]), sizeof(led));
is31fl3731_led_t led;
memcpy_P(&led, (&g_is31fl3731_leds[index]), sizeof(led));

uint8_t control_register_r = (led.r - 0x24) / 8;
uint8_t control_register_g = (led.g - 0x24) / 8;
Expand Down
9 changes: 6 additions & 3 deletions drivers/led/issi/is31fl3731.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,24 @@
#ifdef ISSI_3731_DEGHOST
# define IS31FL3731_DEGHOST ISSI_3731_DEGHOST
#endif

#define is31_led is31fl3731_led_t
#define g_is31_leds g_is31fl3731_leds
// ========

#define IS31FL3731_I2C_ADDRESS_GND 0x74
#define IS31FL3731_I2C_ADDRESS_SCL 0x75
#define IS31FL3731_I2C_ADDRESS_SDA 0x76
#define IS31FL3731_I2C_ADDRESS_VCC 0x77

typedef struct is31_led {
typedef struct is31fl3731_led_t {
uint8_t driver : 2;
uint8_t r;
uint8_t g;
uint8_t b;
} __attribute__((packed)) is31_led;
} __attribute__((packed)) is31fl3731_led_t;

extern const is31_led PROGMEM g_is31_leds[RGB_MATRIX_LED_COUNT];
extern const is31fl3731_led_t PROGMEM g_is31fl3731_leds[RGB_MATRIX_LED_COUNT];

void is31fl3731_init(uint8_t addr);
void is31fl3731_write_register(uint8_t addr, uint8_t reg, uint8_t data);
Expand Down
8 changes: 4 additions & 4 deletions drivers/led/issi/is31fl3733-simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,9 @@ void is31fl3733_init(uint8_t addr, uint8_t sync) {
}

void is31fl3733_set_value(int index, uint8_t value) {
is31_led led;
is31fl3733_led_t led;
if (index >= 0 && index < LED_MATRIX_LED_COUNT) {
memcpy_P(&led, (&g_is31_leds[index]), sizeof(led));
memcpy_P(&led, (&g_is31fl3733_leds[index]), sizeof(led));

if (g_pwm_buffer[led.driver][led.v] == value) {
return;
Expand All @@ -192,8 +192,8 @@ void is31fl3733_set_value_all(uint8_t value) {
}

void is31fl3733_set_led_control_register(uint8_t index, bool value) {
is31_led led;
memcpy_P(&led, (&g_is31_leds[index]), sizeof(led));
is31fl3733_led_t led;
memcpy_P(&led, (&g_is31fl3733_leds[index]), sizeof(led));

uint8_t control_register = led.v / 8;
uint8_t bit_value = led.v % 8;
Expand Down
9 changes: 6 additions & 3 deletions drivers/led/issi/is31fl3733-simple.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
# define IS31FL3733_GLOBALCURRENT ISSI_GLOBALCURRENT
#endif

#define is31_led is31fl3733_led_t
#define g_is31_leds g_is31fl3733_leds

#define PUR_0R IS31FL3733_PUR_0R
#define PUR_05KR IS31FL3733_PUR_05KR
#define PUR_3KR IS31FL3733_PUR_3KR
Expand All @@ -73,12 +76,12 @@
#define IS31FL3733_I2C_ADDRESS_VCC_SDA 0x5E
#define IS31FL3733_I2C_ADDRESS_VCC_VCC 0x5F

typedef struct is31_led {
typedef struct is31fl3733_led_t {
uint8_t driver : 2;
uint8_t v;
} __attribute__((packed)) is31_led;
} __attribute__((packed)) is31fl3733_led_t;

extern const is31_led PROGMEM g_is31_leds[LED_MATRIX_LED_COUNT];
extern const is31fl3733_led_t PROGMEM g_is31fl3733_leds[LED_MATRIX_LED_COUNT];

void is31fl3733_init(uint8_t addr, uint8_t sync);
bool is31fl3733_write_register(uint8_t addr, uint8_t reg, uint8_t data);
Expand Down
8 changes: 4 additions & 4 deletions drivers/led/issi/is31fl3733.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,9 @@ void is31fl3733_init(uint8_t addr, uint8_t sync) {
}

void is31fl3733_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
is31_led led;
is31fl3733_led_t led;
if (index >= 0 && index < RGB_MATRIX_LED_COUNT) {
memcpy_P(&led, (&g_is31_leds[index]), sizeof(led));
memcpy_P(&led, (&g_is31fl3733_leds[index]), sizeof(led));

if (g_pwm_buffer[led.driver][led.r] == red && g_pwm_buffer[led.driver][led.g] == green && g_pwm_buffer[led.driver][led.b] == blue) {
return;
Expand All @@ -193,8 +193,8 @@ void is31fl3733_set_color_all(uint8_t red, uint8_t green, uint8_t blue) {
}

void is31fl3733_set_led_control_register(uint8_t index, bool red, bool green, bool blue) {
is31_led led;
memcpy_P(&led, (&g_is31_leds[index]), sizeof(led));
is31fl3733_led_t led;
memcpy_P(&led, (&g_is31fl3733_leds[index]), sizeof(led));

uint8_t control_register_r = led.r / 8;
uint8_t control_register_g = led.g / 8;
Expand Down
9 changes: 6 additions & 3 deletions drivers/led/issi/is31fl3733.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
# define IS31FL3733_GLOBALCURRENT ISSI_GLOBALCURRENT
#endif

#define is31_led is31fl3733_led_t
#define g_is31_leds g_is31fl3733_leds

#define PUR_0R IS31FL3733_PUR_0R
#define PUR_05KR IS31FL3733_PUR_05KR
#define PUR_3KR IS31FL3733_PUR_3KR
Expand All @@ -72,14 +75,14 @@
#define IS31FL3733_I2C_ADDRESS_VCC_SDA 0x5E
#define IS31FL3733_I2C_ADDRESS_VCC_VCC 0x5F

typedef struct is31_led {
typedef struct is31fl3733_led_t {
uint8_t driver : 2;
uint8_t r;
uint8_t g;
uint8_t b;
} __attribute__((packed)) is31_led;
} __attribute__((packed)) is31fl3733_led_t;

extern const is31_led PROGMEM g_is31_leds[RGB_MATRIX_LED_COUNT];
extern const is31fl3733_led_t PROGMEM g_is31fl3733_leds[RGB_MATRIX_LED_COUNT];

void is31fl3733_init(uint8_t addr, uint8_t sync);
bool is31fl3733_write_register(uint8_t addr, uint8_t reg, uint8_t data);
Expand Down
8 changes: 4 additions & 4 deletions drivers/led/issi/is31fl3736-simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,9 @@ void is31fl3736_init(uint8_t addr) {
}

void is31fl3736_set_value(int index, uint8_t value) {
is31_led led;
is31fl3736_led_t led;
if (index >= 0 && index < LED_MATRIX_LED_COUNT) {
memcpy_P(&led, (&g_is31_leds[index]), sizeof(led));
memcpy_P(&led, (&g_is31fl3736_leds[index]), sizeof(led));

if (g_pwm_buffer[led.driver][led.v] == value) {
return;
Expand All @@ -177,8 +177,8 @@ void is31fl3736_set_value_all(uint8_t value) {
}

void is31fl3736_set_led_control_register(uint8_t index, bool value) {
is31_led led;
memcpy_P(&led, (&g_is31_leds[index]), sizeof(led));
is31fl3736_led_t led;
memcpy_P(&led, (&g_is31fl3736_leds[index]), sizeof(led));

// The PWM register for a matrix position (0x00 to 0xBF) is interleaved, so:
// A1=0x00 A2=0x02 A3=0x04 A4=0x06 A5=0x08 A6=0x0A A7=0x0C A8=0x0E
Expand Down
9 changes: 6 additions & 3 deletions drivers/led/issi/is31fl3736-simple.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
# define IS31FL3736_GLOBALCURRENT ISSI_GLOBALCURRENT
#endif

#define is31_led is31fl3736_led_t
#define g_is31_leds g_is31fl3736_leds

#define PUR_0R IS31FL3736_PUR_0R
#define PUR_05KR IS31FL3736_PUR_05KR
#define PUR_1KR IS31FL3736_PUR_1KR
Expand Down Expand Up @@ -68,12 +71,12 @@
#define IS31FL3736_I2C_ADDRESS_VCC_SDA 0x5E
#define IS31FL3736_I2C_ADDRESS_VCC_VCC 0x5F

typedef struct is31_led {
typedef struct is31fl3736_led_t {
uint8_t driver : 2;
uint8_t v;
} __attribute__((packed)) is31_led;
} __attribute__((packed)) is31fl3736_led_t;

extern const is31_led PROGMEM g_is31_leds[LED_MATRIX_LED_COUNT];
extern const is31fl3736_led_t PROGMEM g_is31fl3736_leds[LED_MATRIX_LED_COUNT];

void is31fl3736_init(uint8_t addr);
void is31fl3736_write_register(uint8_t addr, uint8_t reg, uint8_t data);
Expand Down
8 changes: 4 additions & 4 deletions drivers/led/issi/is31fl3736.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,9 @@ void is31fl3736_init(uint8_t addr) {
}

void is31fl3736_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
is31_led led;
is31fl3736_led_t led;
if (index >= 0 && index < RGB_MATRIX_LED_COUNT) {
memcpy_P(&led, (&g_is31_leds[index]), sizeof(led));
memcpy_P(&led, (&g_is31fl3736_leds[index]), sizeof(led));

if (g_pwm_buffer[led.driver][led.r] == red && g_pwm_buffer[led.driver][led.g] == green && g_pwm_buffer[led.driver][led.b] == blue) {
return;
Expand All @@ -179,8 +179,8 @@ void is31fl3736_set_color_all(uint8_t red, uint8_t green, uint8_t blue) {
}

void is31fl3736_set_led_control_register(uint8_t index, bool red, bool green, bool blue) {
is31_led led;
memcpy_P(&led, (&g_is31_leds[index]), sizeof(led));
is31fl3736_led_t led;
memcpy_P(&led, (&g_is31fl3736_leds[index]), sizeof(led));

// The PWM register for a matrix position (0x00 to 0xBF) is interleaved, so:
// A1=0x00 A2=0x02 A3=0x04 A4=0x06 A5=0x08 A6=0x0A A7=0x0C A8=0x0E
Expand Down
9 changes: 6 additions & 3 deletions drivers/led/issi/is31fl3736.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
# define IS31FL3736_GLOBALCURRENT ISSI_GLOBALCURRENT
#endif

#define is31_led is31fl3736_led_t
#define g_is31_leds g_is31fl3736_leds

#define PUR_0R IS31FL3736_PUR_0R
#define PUR_05KR IS31FL3736_PUR_05KR
#define PUR_1KR IS31FL3736_PUR_1KR
Expand Down Expand Up @@ -68,14 +71,14 @@
#define IS31FL3736_I2C_ADDRESS_VCC_SDA 0x5E
#define IS31FL3736_I2C_ADDRESS_VCC_VCC 0x5F

typedef struct is31_led {
typedef struct is31fl3736_led_t {
uint8_t driver : 2;
uint8_t r;
uint8_t g;
uint8_t b;
} __attribute__((packed)) is31_led;
} __attribute__((packed)) is31fl3736_led_t;

extern const is31_led PROGMEM g_is31_leds[RGB_MATRIX_LED_COUNT];
extern const is31fl3736_led_t PROGMEM g_is31fl3736_leds[RGB_MATRIX_LED_COUNT];

void is31fl3736_init(uint8_t addr);
void is31fl3736_write_register(uint8_t addr, uint8_t reg, uint8_t data);
Expand Down
8 changes: 4 additions & 4 deletions drivers/led/issi/is31fl3737-simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ void is31fl3737_init(uint8_t addr) {
}

void is31fl3737_set_value(int index, uint8_t value) {
is31_led led;
is31fl3737_led_t led;
if (index >= 0 && index < LED_MATRIX_LED_COUNT) {
memcpy_P(&led, (&g_is31_leds[index]), sizeof(led));
memcpy_P(&led, (&g_is31fl3737_leds[index]), sizeof(led));

if (g_pwm_buffer[led.driver][led.v] == value) {
return;
Expand All @@ -180,8 +180,8 @@ void is31fl3737_set_value_all(uint8_t value) {
}

void is31fl3737_set_led_control_register(uint8_t index, bool value) {
is31_led led;
memcpy_P(&led, (&g_is31_leds[index]), sizeof(led));
is31fl3737_led_t led;
memcpy_P(&led, (&g_is31fl3737_leds[index]), sizeof(led));

uint8_t control_register = led.v / 8;
uint8_t bit_value = led.v % 8;
Expand Down
6 changes: 3 additions & 3 deletions drivers/led/issi/is31fl3737-simple.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@
#define IS31FL3737_I2C_ADDRESS_SDA 0x5A
#define IS31FL3737_I2C_ADDRESS_VCC 0x5F

typedef struct is31_led {
typedef struct is31fl3737_led_t {
uint8_t driver : 2;
uint8_t v;
} __attribute__((packed)) is31_led;
} __attribute__((packed)) is31fl3737_led_t;

extern const is31_led PROGMEM g_is31_leds[LED_MATRIX_LED_COUNT];
extern const is31fl3737_led_t PROGMEM g_is31fl3737_leds[LED_MATRIX_LED_COUNT];

void is31fl3737_init(uint8_t addr);
void is31fl3737_write_register(uint8_t addr, uint8_t reg, uint8_t data);
Expand Down
Loading

0 comments on commit da4f935

Please sign in to comment.