diff options
author | Drashna Jael're <drashna@live.com> | 2022-05-29 15:38:33 -0700 |
---|---|---|
committer | Drashna Jael're <drashna@live.com> | 2022-05-29 15:38:33 -0700 |
commit | 30aac80d5a6d8c6f7c06efb49189d748e70edc4a (patch) | |
tree | ceb11968ae41228e4b110c07467cdca7cc9cff22 /quantum/backlight | |
parent | 67f4e5f34489abf986dedb4984b256692086c615 (diff) | |
parent | e22a183329fd05d39f88bb9dfebe98cfa7cd8402 (diff) |
Merge remote-tracking branch 'qmk 0.17.0' into firmware21
Diffstat (limited to 'quantum/backlight')
-rw-r--r-- | quantum/backlight/backlight_avr.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/quantum/backlight/backlight_avr.c b/quantum/backlight/backlight_avr.c index f3a0252270..474e0a86f5 100644 --- a/quantum/backlight/backlight_avr.c +++ b/quantum/backlight/backlight_avr.c @@ -405,14 +405,18 @@ ISR(TIMERx_OVF_vect) uint16_t interval = (uint16_t)get_breathing_period() * breathing_ISR_frequency / BREATHING_STEPS; // resetting after one period to prevent ugly reset at overflow. breathing_counter = (breathing_counter + 1) % (get_breathing_period() * breathing_ISR_frequency); - uint8_t index = breathing_counter / interval % BREATHING_STEPS; + uint8_t index = breathing_counter / interval; + // limit index to max step value + if (index >= BREATHING_STEPS) { + index = BREATHING_STEPS - 1; + } if (((breathing_halt == BREATHING_HALT_ON) && (index == BREATHING_STEPS / 2)) || ((breathing_halt == BREATHING_HALT_OFF) && (index == BREATHING_STEPS - 1))) { breathing_interrupt_disable(); } // Set PWM to a brightnessvalue scaled to the configured resolution - set_pwm(cie_lightness(rescale_limit_val(scale_backlight((uint16_t)pgm_read_byte(&breathing_table[index]) * ICRx / 255)))); + set_pwm(cie_lightness(rescale_limit_val(scale_backlight((uint32_t)pgm_read_byte(&breathing_table[index]) * ICRx / 255)))); } #endif // BACKLIGHT_BREATHING |