Skip to content

Commit

Permalink
Update is31fl3731-simple (qmk#7610)
Browse files Browse the repository at this point in the history
* update simple

* Update is31fl3731-simple.c
  • Loading branch information
Xelus22 authored Dec 6, 2020
1 parent c59f87a commit 6b1f96d
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions drivers/issi/is31fl3731-simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ uint8_t g_twi_transfer_buffer[20];
// buffers and the transfers in IS31FL3731_write_pwm_buffer() but it's
// probably not worth the extra complexity.
uint8_t g_pwm_buffer[LED_DRIVER_COUNT][144];
bool g_pwm_buffer_update_required = false;
bool g_pwm_buffer_update_required[LED_DRIVER_COUNT] = {false};

/* There's probably a better way to init this... */
#if LED_DRIVER_COUNT == 1
Expand All @@ -75,7 +75,7 @@ uint8_t g_led_control_registers[LED_DRIVER_COUNT][18] = {{0}, {0}, {0}};
#elif LED_DRIVER_COUNT == 4
uint8_t g_led_control_registers[LED_DRIVER_COUNT][18] = {{0}, {0}, {0}, {0}};
#endif
bool g_led_control_registers_update_required = false;
bool g_led_control_registers_update_required[LED_DRIVER_COUNT] = {false};

// This is the bit pattern in the LED control registers
// (for matrix A, add one to register for matrix B)
Expand Down Expand Up @@ -190,8 +190,8 @@ void IS31FL3731_set_value(int index, uint8_t value) {
is31_led led = g_is31_leds[index];

// Subtract 0x24 to get the second index of g_pwm_buffer
g_pwm_buffer[led.driver][led.v - 0x24] = value;
g_pwm_buffer_update_required = true;
g_pwm_buffer[led.driver][led.v - 0x24] = value;
g_pwm_buffer_update_required[led.driver] = true;
}
}

Expand All @@ -213,20 +213,21 @@ void IS31FL3731_set_led_control_register(uint8_t index, bool value) {
g_led_control_registers[led.driver][control_register] &= ~(1 << bit_value);
}

g_led_control_registers_update_required = true;
g_led_control_registers_update_required[led.driver] = true;
}

void IS31FL3731_update_pwm_buffers(uint8_t addr, uint8_t index) {
if (g_pwm_buffer_update_required) {
if (g_pwm_buffer_update_required[index]) {
IS31FL3731_write_pwm_buffer(addr, g_pwm_buffer[index]);
g_pwm_buffer_update_required = false;
g_pwm_buffer_update_required[index] = false;
}
}

void IS31FL3731_update_led_control_registers(uint8_t addr, uint8_t index) {
if (g_led_control_registers_update_required) {
if (g_led_control_registers_update_required[index]) {
for (int i = 0; i < 18; i++) {
IS31FL3731_write_register(addr, i, g_led_control_registers[index][i]);
}
g_led_control_registers_update_required[index] = false;
}
}

0 comments on commit 6b1f96d

Please sign in to comment.