Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ISSI3741 #9912

Merged
merged 7 commits into from
Sep 3, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 16 additions & 52 deletions drivers/issi/is31fl3741.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,22 +78,6 @@ bool g_scaling_registers_update_required[DRIVER_COUNT] = {false};

uint8_t g_scaling_registers[DRIVER_COUNT][ISSI_MAX_LEDS];
melgeek001365 marked this conversation as resolved.
Show resolved Hide resolved

uint32_t IS31FL3741_get_cw_sw_position(uint8_t cs, uint8_t sw) {
uint32_t pos = 0;

if (cs < 31) {
if (sw < 7) {
pos = (sw - 1) * 30 + (cs - 1);

} else {
pos = 0xB4 + (sw - 7) * 30 + (cs - 1);
}
} else {
pos = 0xB4 + 0x5A + (sw - 1) * 9 + (cs - 31);
}

return pos;
}

void IS31FL3741_write_register(uint8_t addr, uint8_t reg, uint8_t data) {
g_twi_transfer_buffer[0] = reg;
Expand Down Expand Up @@ -186,15 +170,10 @@ void IS31FL3741_init(uint8_t addr) {
void IS31FL3741_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
if (index >= 0 && index < DRIVER_LED_TOTAL) {
is31_led led = g_is31_leds[index];
uint32_t rp = 0, gp = 0, bp = 0;

rp = IS31FL3741_get_cw_sw_position(led.rcs, led.rsw);
gp = IS31FL3741_get_cw_sw_position(led.gcs, led.gsw);
bp = IS31FL3741_get_cw_sw_position(led.bcs, led.bsw);

g_pwm_buffer[led.driver][rp] = red;
g_pwm_buffer[led.driver][gp] = green;
g_pwm_buffer[led.driver][bp] = blue;
g_pwm_buffer[led.driver][led.r] = red;
g_pwm_buffer[led.driver][led.g] = green;
g_pwm_buffer[led.driver][led.b] = blue;
g_pwm_buffer_update_required = true;
}
}
Expand All @@ -208,26 +187,22 @@ void IS31FL3741_set_color_all(uint8_t red, uint8_t green, uint8_t blue) {
void IS31FL3741_set_led_control_register(uint8_t index, bool red, bool green, bool blue) {
is31_led led = g_is31_leds[index];

uint32_t scaling_register_r = IS31FL3741_get_cw_sw_position(led.rcs, led.rsw);
uint32_t scaling_register_g = IS31FL3741_get_cw_sw_position(led.gcs, led.gsw);
uint32_t scaling_register_b = IS31FL3741_get_cw_sw_position(led.bcs, led.bsw);

if (red) {
g_scaling_registers[led.driver][scaling_register_r] = 0xFF;
g_scaling_registers[led.driver][led.r] = 0xFF;
} else {
g_scaling_registers[led.driver][scaling_register_r] = 0x00;
g_scaling_registers[led.driver][led.r] = 0x00;
}

if (green) {
g_scaling_registers[led.driver][scaling_register_g] = 0xFF;
g_scaling_registers[led.driver][led.g] = 0xFF;
} else {
g_scaling_registers[led.driver][scaling_register_g] = 0x00;
g_scaling_registers[led.driver][led.g] = 0x00;
}

if (blue) {
g_scaling_registers[led.driver][scaling_register_b] = 0xFF;
g_scaling_registers[led.driver][led.b] = 0xFF;
} else {
g_scaling_registers[led.driver][scaling_register_b] = 0x00;
g_scaling_registers[led.driver][led.b] = 0x00;
}

g_scaling_registers_update_required[led.driver] = true;
Expand All @@ -242,15 +217,9 @@ void IS31FL3741_update_pwm_buffers(uint8_t addr1, uint8_t addr2) {
}

void IS31FL3741_set_pwm_buffer(const is31_led *pled, uint8_t red, uint8_t green, uint8_t blue) {
uint32_t rp = 0, gp = 0, bp = 0;

rp = IS31FL3741_get_cw_sw_position(pled->rcs, pled->rsw);
gp = IS31FL3741_get_cw_sw_position(pled->gcs, pled->gsw);
bp = IS31FL3741_get_cw_sw_position(pled->bcs, pled->bsw);

g_pwm_buffer[pled->driver][rp] = red;
g_pwm_buffer[pled->driver][gp] = green;
g_pwm_buffer[pled->driver][bp] = blue;
g_pwm_buffer[pled->driver][pled->r] = red;
g_pwm_buffer[pled->driver][pled->g] = green;
g_pwm_buffer[pled->driver][pled->b] = blue;

g_pwm_buffer_update_required = true;
}
Expand Down Expand Up @@ -278,13 +247,8 @@ void IS31FL3741_update_led_control_registers(uint8_t addr, uint8_t index) {
}

void IS31FL3741_set_scaling_registers(const is31_led *pled, uint8_t red, uint8_t green, uint8_t blue) {
uint32_t rp = 0, gp = 0, bp = 0;

rp = IS31FL3741_get_cw_sw_position(pled->rcs, pled->rsw);
gp = IS31FL3741_get_cw_sw_position(pled->gcs, pled->gsw);
bp = IS31FL3741_get_cw_sw_position(pled->bcs, pled->bsw);

g_scaling_registers[pled->driver][rp] = red;
g_scaling_registers[pled->driver][gp] = green;
g_scaling_registers[pled->driver][bp] = blue;
g_scaling_registers[pled->driver][pled->r] = red;
g_scaling_registers[pled->driver][pled->g] = green;
g_scaling_registers[pled->driver][pled->b] = blue;
}

Loading