Skip to content

Commit

Permalink
sn32 rgb driver: correct SN32_RGB_MATRIX_ROWS_HW init
Browse files Browse the repository at this point in the history
fix ROW2COL PWM bug on COL2ROW

A column would light up when pressed on this scenario
  • Loading branch information
dexter93 committed Sep 17, 2024
1 parent 0c03312 commit 36a5a7f
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions drivers/led/sn32f2xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -461,9 +461,12 @@ static void shared_matrix_rgb_disable_output(void) {
for (uint8_t x = 0; x < SN32_RGB_MATRIX_ROWS_HW; x++) {
# if (SN32_PWM_CONTROL == HARDWARE_PWM)
pwmDisableChannel(&PWMD1, chan_row_order[x]);
# elif (SN32_PWM_CONTROL == SOFTWARE_PWM)
gpio_set_pin_input(led_row_pins[x]);
# endif // SN32_PWM_CONTROL
# if (SN32_PWM_OUTPUT_ACTIVE_LEVEL == SN32_PWM_OUTPUT_ACTIVE_HIGH)
gpio_write_pin_low(led_row_pins[x]);
# elif (SN32_PWM_OUTPUT_ACTIVE_LEVEL == SN32_PWM_OUTPUT_ACTIVE_LOW)
gpio_write_pin_high(led_row_pins[x]);
# endif // SN32_RGB_OUTPUT_ACTIVE_LEVEL
}
# endif // DIODE_DIRECTION != SN32_PWM_DIRECTION
}
Expand Down Expand Up @@ -590,9 +593,11 @@ static void rgb_callback(PWMDriver *pwmp) {
void sn32f2xx_init(void) {
for (uint8_t x = 0; x < SN32_RGB_MATRIX_ROWS_HW; x++) {
gpio_set_pin_output_push_pull(led_row_pins[x]);
# if (SN32_RGB_OUTPUT_ACTIVE_LEVEL == SN32_RGB_OUTPUT_ACTIVE_HIGH)
# if ((SN32_PWM_DIRECTION == COL2ROW) && (SN32_RGB_OUTPUT_ACTIVE_LEVEL == SN32_RGB_OUTPUT_ACTIVE_HIGH) || \
(SN32_PWM_DIRECTION == ROW2COL) && (SN32_PWM_OUTPUT_ACTIVE_LEVEL == SN32_PWM_OUTPUT_ACTIVE_HIGH))
gpio_write_pin_low(led_row_pins[x]);
# elif (SN32_RGB_OUTPUT_ACTIVE_LEVEL == SN32_RGB_OUTPUT_ACTIVE_LOW)
# elif ((SN32_PWM_DIRECTION == COL2ROW) && (SN32_RGB_OUTPUT_ACTIVE_LEVEL == SN32_RGB_OUTPUT_ACTIVE_LOW) || \
(SN32_PWM_DIRECTION == ROW2COL) && (SN32_PWM_OUTPUT_ACTIVE_LEVEL == SN32_PWM_OUTPUT_ACTIVE_LOW))
gpio_write_pin_high(led_row_pins[x]);
# endif // SN32_RGB_OUTPUT_ACTIVE_LEVEL
}
Expand Down

0 comments on commit 36a5a7f

Please sign in to comment.