Skip to content

Commit

Permalink
LED drivers: misc formatting and typos (qmk#22857)
Browse files Browse the repository at this point in the history
  • Loading branch information
fauxpark authored and mechlovin committed Jan 17, 2024
1 parent cb95e79 commit 2483dab
Show file tree
Hide file tree
Showing 23 changed files with 307 additions and 76 deletions.
11 changes: 11 additions & 0 deletions drivers/led/aw20216s.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ void aw20216s_flush(void);
#define CS16_SW1 0x0F
#define CS17_SW1 0x10
#define CS18_SW1 0x11

#define CS1_SW2 0x12
#define CS2_SW2 0x13
#define CS3_SW2 0x14
Expand All @@ -137,6 +138,7 @@ void aw20216s_flush(void);
#define CS16_SW2 0x21
#define CS17_SW2 0x22
#define CS18_SW2 0x23

#define CS1_SW3 0x24
#define CS2_SW3 0x25
#define CS3_SW3 0x26
Expand All @@ -155,6 +157,7 @@ void aw20216s_flush(void);
#define CS16_SW3 0x33
#define CS17_SW3 0x34
#define CS18_SW3 0x35

#define CS1_SW4 0x36
#define CS2_SW4 0x37
#define CS3_SW4 0x38
Expand All @@ -173,6 +176,7 @@ void aw20216s_flush(void);
#define CS16_SW4 0x45
#define CS17_SW4 0x46
#define CS18_SW4 0x47

#define CS1_SW5 0x48
#define CS2_SW5 0x49
#define CS3_SW5 0x4A
Expand All @@ -191,6 +195,7 @@ void aw20216s_flush(void);
#define CS16_SW5 0x57
#define CS17_SW5 0x58
#define CS18_SW5 0x59

#define CS1_SW6 0x5A
#define CS2_SW6 0x5B
#define CS3_SW6 0x5C
Expand All @@ -209,6 +214,7 @@ void aw20216s_flush(void);
#define CS16_SW6 0x69
#define CS17_SW6 0x6A
#define CS18_SW6 0x6B

#define CS1_SW7 0x6C
#define CS2_SW7 0x6D
#define CS3_SW7 0x6E
Expand All @@ -227,6 +233,7 @@ void aw20216s_flush(void);
#define CS16_SW7 0x7B
#define CS17_SW7 0x7C
#define CS18_SW7 0x7D

#define CS1_SW8 0x7E
#define CS2_SW8 0x7F
#define CS3_SW8 0x80
Expand All @@ -245,6 +252,7 @@ void aw20216s_flush(void);
#define CS16_SW8 0x8D
#define CS17_SW8 0x8E
#define CS18_SW8 0x8F

#define CS1_SW9 0x90
#define CS2_SW9 0x91
#define CS3_SW9 0x92
Expand All @@ -263,6 +271,7 @@ void aw20216s_flush(void);
#define CS16_SW9 0x9F
#define CS17_SW9 0xA0
#define CS18_SW9 0xA1

#define CS1_SW10 0xA2
#define CS2_SW10 0xA3
#define CS3_SW10 0xA4
Expand All @@ -281,6 +290,7 @@ void aw20216s_flush(void);
#define CS16_SW10 0xB1
#define CS17_SW10 0xB2
#define CS18_SW10 0xB3

#define CS1_SW11 0xB4
#define CS2_SW11 0xB5
#define CS3_SW11 0xB6
Expand All @@ -299,6 +309,7 @@ void aw20216s_flush(void);
#define CS16_SW11 0xC3
#define CS17_SW11 0xC4
#define CS18_SW11 0xC5

#define CS1_SW12 0xC6
#define CS2_SW12 0xC7
#define CS3_SW12 0xC8
Expand Down
14 changes: 9 additions & 5 deletions drivers/led/issi/is31fl3218-mono.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "is31fl3218-mono.h"
#include <string.h>
#include "i2c_master.h"
Expand Down Expand Up @@ -93,14 +94,17 @@ void is31fl3218_init(void) {

void is31fl3218_set_value(int index, uint8_t value) {
is31fl3218_led_t led;

if (index >= 0 && index < IS31FL3218_LED_COUNT) {
memcpy_P(&led, (&g_is31fl3218_leds[index]), sizeof(led));

if (g_pwm_buffer[led.v - IS31FL3218_REG_PWM] == value) {
return;
}

g_pwm_buffer[led.v - IS31FL3218_REG_PWM] = value;
g_pwm_buffer_update_required = true;
}
if (g_pwm_buffer[led.v - IS31FL3218_REG_PWM] == value) {
return;
}
g_pwm_buffer[led.v - IS31FL3218_REG_PWM] = value;
g_pwm_buffer_update_required = true;
}

void is31fl3218_set_value_all(uint8_t value) {
Expand Down
18 changes: 11 additions & 7 deletions drivers/led/issi/is31fl3218.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "is31fl3218.h"
#include <string.h>
#include "i2c_master.h"
Expand Down Expand Up @@ -93,16 +94,19 @@ void is31fl3218_init(void) {

void is31fl3218_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
is31fl3218_led_t led;

if (index >= 0 && index < IS31FL3218_LED_COUNT) {
memcpy_P(&led, (&g_is31fl3218_leds[index]), sizeof(led));

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) {
return;
}

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;
g_pwm_buffer_update_required = true;
}
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) {
return;
}
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;
g_pwm_buffer_update_required = true;
}

void is31fl3218_set_color_all(uint8_t red, uint8_t green, uint8_t blue) {
Expand Down
9 changes: 5 additions & 4 deletions drivers/led/issi/is31fl3731-mono.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ void is31fl3731_write_register(uint8_t addr, uint8_t reg, uint8_t data) {

#if IS31FL3731_I2C_PERSISTENCE > 0
for (uint8_t i = 0; i < IS31FL3731_I2C_PERSISTENCE; i++) {
if (i2c_transmit(addr << 1, i2c_transfer_buffer, 2, IS31FL3731_I2C_TIMEOUT) == 0) {
break;
}
if (i2c_transmit(addr << 1, i2c_transfer_buffer, 2, IS31FL3731_I2C_TIMEOUT) == 0) break;
}
#else
i2c_transmit(addr << 1, i2c_transfer_buffer, 2, IS31FL3731_I2C_TIMEOUT);
Expand Down Expand Up @@ -174,14 +172,15 @@ void is31fl3731_init(uint8_t addr) {

void is31fl3731_set_value(int index, uint8_t value) {
is31fl3731_led_t led;

if (index >= 0 && index < IS31FL3731_LED_COUNT) {
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.v - 0x24] == value) {
return;
}

g_pwm_buffer[led.driver][led.v - 0x24] = value;
g_pwm_buffer_update_required[led.driver] = true;
}
Expand Down Expand Up @@ -212,6 +211,7 @@ void is31fl3731_set_led_control_register(uint8_t index, bool value) {
void is31fl3731_update_pwm_buffers(uint8_t addr, uint8_t index) {
if (g_pwm_buffer_update_required[index]) {
is31fl3731_write_pwm_buffer(addr, g_pwm_buffer[index]);

g_pwm_buffer_update_required[index] = false;
}
}
Expand All @@ -221,6 +221,7 @@ void is31fl3731_update_led_control_registers(uint8_t addr, uint8_t index) {
for (int i = 0; i < IS31FL3731_LED_CONTROL_REGISTER_COUNT; i++) {
is31fl3731_write_register(addr, i, g_led_control_registers[index][i]);
}

g_led_control_registers_update_required[index] = false;
}
}
Expand Down
8 changes: 6 additions & 2 deletions drivers/led/issi/is31fl3731.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,15 @@ void is31fl3731_init(uint8_t addr) {

void is31fl3731_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
is31fl3731_led_t led;

if (index >= 0 && index < IS31FL3731_LED_COUNT) {
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) {
return;
}

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 Down Expand Up @@ -224,17 +226,19 @@ void is31fl3731_set_led_control_register(uint8_t index, bool red, bool green, bo
void is31fl3731_update_pwm_buffers(uint8_t addr, uint8_t index) {
if (g_pwm_buffer_update_required[index]) {
is31fl3731_write_pwm_buffer(addr, g_pwm_buffer[index]);

g_pwm_buffer_update_required[index] = 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[index]) {
for (int i = 0; i < IS31FL3731_LED_CONTROL_REGISTER_COUNT; i++) {
is31fl3731_write_register(addr, i, g_led_control_registers[index][i]);
}

g_led_control_registers_update_required[index] = false;
}
g_led_control_registers_update_required[index] = false;
}

void is31fl3731_flush(void) {
Expand Down
4 changes: 4 additions & 0 deletions drivers/led/issi/is31fl3733-mono.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,14 @@ void is31fl3733_init(uint8_t addr, uint8_t sync) {

void is31fl3733_set_value(int index, uint8_t value) {
is31fl3733_led_t led;

if (index >= 0 && index < IS31FL3733_LED_COUNT) {
memcpy_P(&led, (&g_is31fl3733_leds[index]), sizeof(led));

if (g_pwm_buffer[led.driver][led.v] == value) {
return;
}

g_pwm_buffer[led.driver][led.v] = value;
g_pwm_buffer_update_required[led.driver] = true;
}
Expand Down Expand Up @@ -241,6 +243,7 @@ void is31fl3733_update_pwm_buffers(uint8_t addr, uint8_t index) {
if (!is31fl3733_write_pwm_buffer(addr, g_pwm_buffer[index])) {
g_led_control_registers_update_required[index] = true;
}

g_pwm_buffer_update_required[index] = false;
}
}
Expand All @@ -252,6 +255,7 @@ void is31fl3733_update_led_control_registers(uint8_t addr, uint8_t index) {
for (int i = 0; i < IS31FL3733_LED_CONTROL_REGISTER_COUNT; i++) {
is31fl3733_write_register(addr, i, g_led_control_registers[index][i]);
}

g_led_control_registers_update_required[index] = false;
}
}
Expand Down
4 changes: 4 additions & 0 deletions drivers/led/issi/is31fl3733.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,14 @@ void is31fl3733_init(uint8_t addr, uint8_t sync) {

void is31fl3733_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
is31fl3733_led_t led;

if (index >= 0 && index < IS31FL3733_LED_COUNT) {
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;
}

g_pwm_buffer[led.driver][led.r] = red;
g_pwm_buffer[led.driver][led.g] = green;
g_pwm_buffer[led.driver][led.b] = blue;
Expand Down Expand Up @@ -256,6 +258,7 @@ void is31fl3733_update_pwm_buffers(uint8_t addr, uint8_t index) {
if (!is31fl3733_write_pwm_buffer(addr, g_pwm_buffer[index])) {
g_led_control_registers_update_required[index] = true;
}

g_pwm_buffer_update_required[index] = false;
}
}
Expand All @@ -267,6 +270,7 @@ void is31fl3733_update_led_control_registers(uint8_t addr, uint8_t index) {
for (int i = 0; i < IS31FL3733_LED_CONTROL_REGISTER_COUNT; i++) {
is31fl3733_write_register(addr, i, g_led_control_registers[index][i]);
}

g_led_control_registers_update_required[index] = false;
}
}
Expand Down
4 changes: 4 additions & 0 deletions drivers/led/issi/is31fl3736-mono.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,14 @@ void is31fl3736_init(uint8_t addr) {

void is31fl3736_set_value(int index, uint8_t value) {
is31fl3736_led_t led;

if (index >= 0 && index < IS31FL3736_LED_COUNT) {
memcpy_P(&led, (&g_is31fl3736_leds[index]), sizeof(led));

if (g_pwm_buffer[led.driver][led.v] == value) {
return;
}

g_pwm_buffer[led.driver][led.v] = value;
g_pwm_buffer_update_required[led.driver] = true;
}
Expand Down Expand Up @@ -215,6 +217,7 @@ void is31fl3736_update_pwm_buffers(uint8_t addr, uint8_t index) {
is31fl3736_select_page(addr, IS31FL3736_COMMAND_PWM);

is31fl3736_write_pwm_buffer(addr, g_pwm_buffer[index]);

g_pwm_buffer_update_required[index] = false;
}
}
Expand All @@ -226,6 +229,7 @@ void is31fl3736_update_led_control_registers(uint8_t addr, uint8_t index) {
for (int i = 0; i < IS31FL3736_LED_CONTROL_REGISTER_COUNT; i++) {
is31fl3736_write_register(addr, i, g_led_control_registers[index][i]);
}

g_led_control_registers_update_required[index] = false;
}
}
Expand Down
4 changes: 4 additions & 0 deletions drivers/led/issi/is31fl3736.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,14 @@ void is31fl3736_init(uint8_t addr) {

void is31fl3736_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
is31fl3736_led_t led;

if (index >= 0 && index < IS31FL3736_LED_COUNT) {
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;
}

g_pwm_buffer[led.driver][led.r] = red;
g_pwm_buffer[led.driver][led.g] = green;
g_pwm_buffer[led.driver][led.b] = blue;
Expand Down Expand Up @@ -232,6 +234,7 @@ void is31fl3736_update_pwm_buffers(uint8_t addr, uint8_t index) {
is31fl3736_select_page(addr, IS31FL3736_COMMAND_PWM);

is31fl3736_write_pwm_buffer(addr, g_pwm_buffer[index]);

g_pwm_buffer_update_required[index] = false;
}
}
Expand All @@ -243,6 +246,7 @@ void is31fl3736_update_led_control_registers(uint8_t addr, uint8_t index) {
for (int i = 0; i < IS31FL3736_LED_CONTROL_REGISTER_COUNT; i++) {
is31fl3736_write_register(addr, i, g_led_control_registers[index][i]);
}

g_led_control_registers_update_required[index] = false;
}
}
Expand Down
4 changes: 4 additions & 0 deletions drivers/led/issi/is31fl3737-mono.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,14 @@ void is31fl3737_init(uint8_t addr) {

void is31fl3737_set_value(int index, uint8_t value) {
is31fl3737_led_t led;

if (index >= 0 && index < IS31FL3737_LED_COUNT) {
memcpy_P(&led, (&g_is31fl3737_leds[index]), sizeof(led));

if (g_pwm_buffer[led.driver][led.v] == value) {
return;
}

g_pwm_buffer[led.driver][led.v] = value;
g_pwm_buffer_update_required[led.driver] = true;
}
Expand Down Expand Up @@ -212,6 +214,7 @@ void is31fl3737_update_pwm_buffers(uint8_t addr, uint8_t index) {
is31fl3737_select_page(addr, IS31FL3737_COMMAND_PWM);

is31fl3737_write_pwm_buffer(addr, g_pwm_buffer[index]);

g_pwm_buffer_update_required[index] = false;
}
}
Expand All @@ -223,6 +226,7 @@ void is31fl3737_update_led_control_registers(uint8_t addr, uint8_t index) {
for (int i = 0; i < IS31FL3737_LED_CONTROL_REGISTER_COUNT; i++) {
is31fl3737_write_register(addr, i, g_led_control_registers[index][i]);
}

g_led_control_registers_update_required[index] = false;
}
}
Expand Down
Loading

0 comments on commit 2483dab

Please sign in to comment.