qmk_firmware/quantum
Brice Figureau b61baf4281 Fix #3566 use an hardware timer for software PWM stability (#3615)
With my XD60, I noticed that when typing the backlight was flickering.

The XD60 doesn't have the backlight wired to a hardware PWM pin.
I assumed it was a timing issue in the matrix scan that made the PWM
lit the LED a bit too longer. I verified it because the more keys that
were pressed, the more lighting I observed.

This patch makes the software PWM be called during CPU interruptions.
It works almost like the hardware PWM, except instead of using
the CPU waveform generation, the CPU will fire interruption
when the LEDs need be turned on or off.

Using the same timer system as for hardware PWM, when the counter
will reach OCRxx (the current backlight level), an Output Compare
match interrupt will be fired and we'll turn the LEDs off.
When the counter reaches its maximum value, an overflow interrupt
will be triggered in which we turn the LEDs on.
This way we replicate the hardware backlight PWM duty cycle.

This gives a better time stability of the PWM computation than pure
software PWM, leading to a flicker free backlight.

Since this is reusing the hardware PWM code, software PWM also supports
backlight breathing.

Note that if timer1 is used for audio, backlight will use timer3, and if
timer3 is used for audio backlight will use timer1.
If both timers are used for audio, then this feature is disabled and we
revert to the matrix scan based PWM computation.

Signed-off-by: Brice Figureau <brice@daysofwonder.com>
2019-04-22 08:34:13 -07:00
..
api Merge ChibiOS and LUFA descriptor support (#2362) 2018-02-08 15:07:46 -05:00
audio Adds the Planck EZ, 3737 RGB, fixes out-of-tune notes (#5532) 2019-04-08 16:57:43 -07:00
debounce [core] Fix for eager_pr #5643 2019-04-18 15:45:36 -07:00
keymap_extras Add UK variant of the SEND_STRING() LUTs 2019-02-18 08:47:31 -08:00
process_keycode fix combo enabling logic (#5610) 2019-04-14 11:02:41 -07:00
rgb_matrix_animations Fix bugs that cause compile failures when enabling only some animations. 2019-04-06 10:59:25 -07:00
serial_link Only re-send matrix every 5ms 2017-04-09 18:34:59 +03:00
split_common Change split_common to use RGBLIGHT_SPLIT (#5509) 2019-04-19 15:25:08 -07:00
stm32 Adds the Planck EZ, 3737 RGB, fixes out-of-tune notes (#5532) 2019-04-08 16:57:43 -07:00
template Update ps2avrgb readme template (#5584) 2019-04-11 15:39:40 -07:00
tools Backlight abstraction and other changes (#439) 2016-06-23 22:18:20 -04:00
visualizer Fixing dead links (#5503) 2019-03-29 06:20:25 -07:00
api.c rgblight split transfer non-eeprom config (#5396) 2019-03-15 13:46:49 -07:00
api.h Only include lufa.h if AVR in quantum/api.h 2018-10-16 17:11:51 -04:00
color.c RGB Matrix Overhaul (#5372) 2019-04-02 17:24:14 -07:00
color.h Adds IS31FL3731 RGB Matrix Implementation (#2910) 2018-05-08 15:24:18 -04:00
config_common.h Add new keyboard Plaid and ATMEGA328p support (#5379) 2019-03-12 11:48:17 -07:00
debounce.h Removed #include "matrix.h" from debounce.h 2019-01-26 22:44:33 +11:00
dynamic_keymap.c Added SS_TAP_CODE, SS_DOWN_CODE, SS_UP_CODE 2019-03-30 14:24:13 +11:00
dynamic_keymap.h Added macros to Dynamic Keymaps, Zeal60 RGB backlight improvements (#4520) 2018-11-30 08:43:34 -08:00
dynamic_macro.h Fix dynamic macros on ChibiOS keyboards 2017-09-30 06:22:24 -10:00
encoder.c Added encoder support to split common code (#5477) 2019-04-03 16:01:17 -07:00
encoder.h Added encoder support to split common code (#5477) 2019-04-03 16:01:17 -07:00
fauxclicky.c Faux clicky bug fixes 2017-04-19 01:40:16 +07:00
fauxclicky.h Faux clicky bug fixes 2017-04-19 01:40:16 +07:00
keycode_config.c Fix #1566 - NKRO reseting issue 2018-03-25 13:17:52 -04:00
keycode_config.h Allow mod swapping for mod tap (MT) (#1202) 2017-06-26 18:54:01 -04:00
keymap_common.c Next set of split_common changes (#4974) 2019-03-12 10:23:28 -07:00
keymap.h Merge ChibiOS and LUFA descriptor support (#2362) 2018-02-08 15:07:46 -05:00
led_matrix_drivers.c fix the led_matrix.h naming conflict 2019-02-10 15:37:12 -08:00
led_matrix.c fix the led_matrix.h naming conflict 2019-02-10 15:37:12 -08:00
led_tables.c Move CIE1931 and breathing tables to its own file 2017-04-09 18:34:59 +03:00
led_tables.h Move CIE1931 and breathing tables to its own file 2017-04-09 18:34:59 +03:00
ledmatrix.h fix the led_matrix.h naming conflict 2019-02-10 15:37:12 -08:00
matrix.c Port DIRECT_PINS from split_common/matrix.c to matrix.c (#5091) 2019-04-11 11:51:55 -07:00
mcu_selection.mk Adds Proton C Conversion (#4661) 2019-01-10 08:22:57 -08:00
pincontrol.h Clarify the quantum license (#1042) 2017-03-28 15:20:36 -07:00
pointing_device.c Added Dichotemy Keyboard, updated docs for Pointing Device (#1817) 2017-10-10 07:07:59 -10:00
pointing_device.h Fix Pointing Device code (#1934) 2017-10-31 11:13:00 -04:00
quantum_keycodes.h Fix indentation in quantum_keycodes.h (#5221) 2019-02-24 15:21:09 -08:00
quantum.c Fix #3566 use an hardware timer for software PWM stability (#3615) 2019-04-22 08:34:13 -07:00
quantum.h Fix #3566 use an hardware timer for software PWM stability (#3615) 2019-04-22 08:34:13 -07:00
rgb_matrix_drivers.c Features/ws2812 matrix driver (#5418) 2019-04-14 17:50:35 -07:00
rgb_matrix_types.h RGB Matrix support for Massdrop CTRL/ALT (#5328) 2019-04-03 18:30:47 -07:00
rgb_matrix.c Fix bugs that cause compile failures when enabling only some animations. 2019-04-06 10:59:25 -07:00
rgb_matrix.h Define RGB colors (#5300) 2019-04-22 08:26:41 -07:00
rgb.h Add effect speed support for RGB Matrix *No EEPROM yet* (#2922) 2018-05-08 23:23:21 -04:00
rgblight_list.h Define RGB colors (#5300) 2019-04-22 08:26:41 -07:00
rgblight_modes.h Add function to support split-keyboard in rgblight.[ch]. (#5020) 2019-04-19 15:05:51 -07:00
rgblight_post_config.h Change split_common to use RGBLIGHT_SPLIT (#5509) 2019-04-19 15:25:08 -07:00
rgblight_reconfig.h rgblight.[ch] more configurable (#3582) 2018-09-13 10:24:09 -07:00
rgblight_types.h Adds support for Planck Rev 6 (#2666) 2018-07-16 11:48:31 -04:00
rgblight.c Add function to support split-keyboard in rgblight.[ch]. (#5020) 2019-04-19 15:05:51 -07:00
rgblight.h Add function to support split-keyboard in rgblight.[ch]. (#5020) 2019-04-19 15:05:51 -07:00
send_string_keycodes.h Clean up SEND_STRING keycodes and add media keys (#3214) 2018-06-28 08:55:04 -04:00
variable_trace.c Clarify the quantum license (#1042) 2017-03-28 15:20:36 -07:00
variable_trace.h Clarify the quantum license (#1042) 2017-03-28 15:20:36 -07:00
velocikey.c Velocikey: Match RGB animation speed to typing speed (#3754) 2019-02-21 07:22:46 -08:00
velocikey.h Velocikey: Match RGB animation speed to typing speed (#3754) 2019-02-21 07:22:46 -08:00