Skip to content

Commit

Permalink
Revert "Fixed out of bounds array access in SN32F24XB RGB matrix (qmk…
Browse files Browse the repository at this point in the history
…#308)" (qmk#313)

This reverts commit 7a08ea9.
  • Loading branch information
dexter93 authored Dec 21, 2022
1 parent 7a08ea9 commit 76cf9e5
Showing 1 changed file with 18 additions and 21 deletions.
39 changes: 18 additions & 21 deletions drivers/led/sn32/rgb_matrix_sn32f24xb.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ void rgb_ch_ctrl(PWMConfig *cfg) {
cfg->channels[1].mode = PWM_OUTPUT_ACTIVE_LOW;
chan_col_order[i] = 1;
break;

case B10:
cfg->channels[2].pfpamsk = 1;
case A2:
Expand Down Expand Up @@ -300,26 +300,23 @@ void update_pwm_channels(PWMDriver *pwmp) {
matrix_scan_keys(raw_matrix,col_idx);
#endif
uint8_t led_index = g_led_config.matrix_co[row_idx][col_idx];
// Check if led index is within array bounds
if (led_index < DRIVER_LED_TOTAL) {
// Check if we need to enable RGB output
if (led_state[led_index].b != 0) enable_pwm |= true;
if (led_state[led_index].g != 0) enable_pwm |= true;
if (led_state[led_index].r != 0) enable_pwm |= true;
// Update matching RGB channel PWM configuration
switch(current_row % LED_MATRIX_ROW_CHANNELS) {
case 0:
if(enable_pwm) pwmEnableChannelI(pwmp,chan_col_order[col_idx],led_state[led_index].b);
break;
case 1:
if(enable_pwm) pwmEnableChannelI(pwmp,chan_col_order[col_idx],led_state[led_index].g);
break;
case 2:
if(enable_pwm) pwmEnableChannelI(pwmp,chan_col_order[col_idx],led_state[led_index].r);
break;
default:
;
}
// Check if we need to enable RGB output
if (led_state[led_index].b != 0) enable_pwm |= true;
if (led_state[led_index].g != 0) enable_pwm |= true;
if (led_state[led_index].r != 0) enable_pwm |= true;
// Update matching RGB channel PWM configuration
switch(current_row % LED_MATRIX_ROW_CHANNELS) {
case 0:
if(enable_pwm) pwmEnableChannelI(pwmp,chan_col_order[col_idx],led_state[led_index].b);
break;
case 1:
if(enable_pwm) pwmEnableChannelI(pwmp,chan_col_order[col_idx],led_state[led_index].g);
break;
case 2:
if(enable_pwm) pwmEnableChannelI(pwmp,chan_col_order[col_idx],led_state[led_index].r);
break;
default:
;
}
}
}
Expand Down

0 comments on commit 76cf9e5

Please sign in to comment.