aboutsummaryrefslogtreecommitdiff
path: root/docs/feature_backlight.md
diff options
context:
space:
mode:
authorBalz Guenat <balz.guenat@gmail.com>2018-01-01 23:47:51 +0100
committerJack Humbert <jack.humb@gmail.com>2018-01-01 17:47:51 -0500
commit4931510ad38aadb1769c9241bfad0c3d77ad687f (patch)
treeb2e23ebbde408a3f6580b34e8cf3332346e7c3f3 /docs/feature_backlight.md
parentd6215ad6aff3857cea8a6877b56a547a76ab13ac (diff)
downloadqmk_firmware-4931510ad38aadb1769c9241bfad0c3d77ad687f.tar.gz
qmk_firmware-4931510ad38aadb1769c9241bfad0c3d77ad687f.zip
backlight breathing overhaul (#2187)
* add breathing to bananasplit * backlight breathing overhaul * fix the backlight_tick thing. * fix for vision_division backlight * fix a few keymaps and probably break breathing for some weirdly set-up boards. * remove BL_x keycodes because they made unreasonable assumptions * some fixes for BL keycodes * integer cie lightness scaling * use cie lightness for non-breathing backlight and make breathing able to reach true max brightness
Diffstat (limited to 'docs/feature_backlight.md')
-rw-r--r--docs/feature_backlight.md28
1 files changed, 25 insertions, 3 deletions
diff --git a/docs/feature_backlight.md b/docs/feature_backlight.md
index aa747f90e..97421c043 100644
--- a/docs/feature_backlight.md
+++ b/docs/feature_backlight.md
@@ -10,8 +10,30 @@ These keycodes control the backlight. Most keyboards use this for single color i
10|---------|------------------------------------------| 10|---------|------------------------------------------|
11|`BL_TOGG`|Turn the backlight on or off | 11|`BL_TOGG`|Turn the backlight on or off |
12|`BL_STEP`|Cycle through backlight levels | 12|`BL_STEP`|Cycle through backlight levels |
13|`BL_x` |Set a specific backlight level between 0-9| 13|`BL_ON` |Set backlight to max brightness |
14|`BL_ON` |An alias for `BL_9` | 14|`BL_OFF` |Turn backlight off |
15|`BL_OFF` |An alias for `BL_0` |
16|`BL_INC` |Increase backlight level | 15|`BL_INC` |Increase backlight level |
17|`BL_DEC` |Decrease backlight level | 16|`BL_DEC` |Decrease backlight level |
17|`BL_BRTG`|Toggle backlight breathing |
18
19Note that for backlight breathing, you need to have `#define BACKLIGHT_BREATHING` in your config.h.
20
21## Configuration Options in `config.h`
22
23* `BACKLIGHT_PIN B7` defines the pin that controlls the LEDs. Unless you design your own keyboard, you don't need to set this.
24* `BACKLIGHT_LEVELS 3` defines the number of brightness levels (excluding OFF).
25* `BACKLIGHT_BREATHING` if defined, enables backlight breathing. Note that this is only available if `BACKLIGHT_PIN` is B5, B6 or B7.
26* `BREATHING_PERIOD 6` defines the length of one backlight "breath" in seconds.
27
28## Notes on Implementation
29
30To change the brightness when using pins B5, B6 or B7, the PWM (Pulse Width Modulation) functionality of the on-chip timer is used.
31The timer is a counter that counts up to a certain TOP value (`0xFFFF` set in ICR1) before resetting to 0.
32We also set an OCR1x register.
33When the counter reaches the value stored in that register, the PWM pin drops to low.
34The PWM pin is pulled high again when the counter resets to 0.
35Therefore, OCR1x basically sets the duty cycle of the LEDs and as such the brightness where `0` is the darkest and `0xFFFF` the brightest setting.
36
37To enable the breathing effect, we register an interrupt handler to be called whenever the counter resets (with `ISR(TIMER1_OVF_vect)`).
38In this handler, which gets called roughly 244 times per second, we compute the desired brightness using a precomputed brightness curve.
39To disable breathing, we can just disable the respective interrupt vector and reset the brightness to the desired level.