aboutsummaryrefslogtreecommitdiff
path: root/docs/feature_backlight.md
diff options
context:
space:
mode:
authorzvecr <git@zvecr.com>2019-11-06 00:06:36 +0000
committerzvecr <git@zvecr.com>2019-12-14 03:25:06 +0000
commit3d54b1adf072938c46efba89e31b2afef407db85 (patch)
treecff6fbc66b30e6e8c3b4ef50258b909452b38518 /docs/feature_backlight.md
parentd4c23d881fcd9fafcd3ea678614f006203b64e71 (diff)
downloadqmk_firmware-3d54b1adf072938c46efba89e31b2afef407db85.tar.gz
qmk_firmware-3d54b1adf072938c46efba89e31b2afef407db85.zip
Convert backlight to follow driver rules pattern - update docs
Diffstat (limited to 'docs/feature_backlight.md')
-rw-r--r--docs/feature_backlight.md52
1 files changed, 43 insertions, 9 deletions
diff --git a/docs/feature_backlight.md b/docs/feature_backlight.md
index 71f375594..22abaa60a 100644
--- a/docs/feature_backlight.md
+++ b/docs/feature_backlight.md
@@ -6,16 +6,14 @@ QMK is able to control the brightness of these LEDs by switching them on and off
6 6
7The MCU can only supply so much current to its GPIO pins. Instead of powering the backlight directly from the MCU, the backlight pin is connected to a transistor or MOSFET that switches the power to the LEDs. 7The MCU can only supply so much current to its GPIO pins. Instead of powering the backlight directly from the MCU, the backlight pin is connected to a transistor or MOSFET that switches the power to the LEDs.
8 8
9## Driver configuration 9## Feature Configuration
10 10
11Most keyboards have backlighting enabled by default if they support it, but if it is not working for you, check that your `rules.mk` includes the following: 11Most keyboards have backlighting enabled by default if they support it, but if it is not working for you, check that your `rules.mk` includes the following:
12 12
13```makefile 13```makefile
14BACKLIGHT_ENABLE = software # Valid driver values are 'yes,software,no' 14BACKLIGHT_ENABLE = yes
15``` 15```
16 16
17See below for help on individual drivers.
18
19## Keycodes 17## Keycodes
20Once enabled the following keycodes below can be used to change the backlight level. 18Once enabled the following keycodes below can be used to change the backlight level.
21 19
@@ -51,6 +49,16 @@ Once enabled the following keycodes below can be used to change the backlight le
51|`breathing_enable()` |Turns on backlight breathing | 49|`breathing_enable()` |Turns on backlight breathing |
52|`breathing_disable()` |Turns off backlight breathing | 50|`breathing_disable()` |Turns off backlight breathing |
53 51
52## Driver Configuration
53
54To select which driver to use, configure your `rules.mk` with the following:
55
56```makefile
57BACKLIGHT_DRIVER = software # Valid driver values are 'pwm,software,no'
58```
59
60See below for help on individual drivers.
61
54## Common Driver Configuration 62## Common Driver Configuration
55 63
56To change the behavior of the backlighting, `#define` these in your `config.h`: 64To change the behavior of the backlighting, `#define` these in your `config.h`:
@@ -72,9 +80,9 @@ This functionality is configured at the keyboard level with the `BACKLIGHT_ON_ST
72 80
73## AVR driver 81## AVR driver
74 82
75On AVR boards, the default driver currently sniffs the configuration to pick the best scenario. To enable it, add this to your rules.mk: 83On AVR boards, the default driver currently sniffs the configuration to pick the best scenario. The driver is configured by default, however the equivalent setting within rules.mk would be:
76```makefile 84```makefile
77BACKLIGHT_ENABLE = yes 85BACKLIGHT_DRIVER = pwm
78``` 86```
79 87
80### Caveats 88### Caveats
@@ -150,9 +158,9 @@ The breathing effect is the same as in the hardware PWM implementation.
150 158
151## ARM Driver 159## ARM Driver
152 160
153While still in its early stages, ARM backlight support aims to eventually have feature parity with AVR. To enable it, add this to your rules.mk: 161While still in its early stages, ARM backlight support aims to eventually have feature parity with AVR. The driver is configured by default, however the equivalent setting within rules.mk would be:
154```makefile 162```makefile
155BACKLIGHT_ENABLE = yes 163BACKLIGHT_DRIVER = pwm
156``` 164```
157 165
158### Caveats 166### Caveats
@@ -176,7 +184,7 @@ To change the behavior of the backlighting, `#define` these in your `config.h`:
176 184
177Emulation of PWM while running other keyboard tasks, it offers maximum hardware compatibility without extra platform configuration. The tradeoff is the backlight might jitter when the keyboard is busy. To enable, add this to your rules.mk: 185Emulation of PWM while running other keyboard tasks, it offers maximum hardware compatibility without extra platform configuration. The tradeoff is the backlight might jitter when the keyboard is busy. To enable, add this to your rules.mk:
178```makefile 186```makefile
179BACKLIGHT_ENABLE = software 187BACKLIGHT_DRIVER = software
180``` 188```
181 189
182### Software PWM Configuration 190### Software PWM Configuration
@@ -200,3 +208,29 @@ To activate multiple backlight pins, you need to add something like this to your
200#undef BACKLIGHT_PIN 208#undef BACKLIGHT_PIN
201#define BACKLIGHT_PINS { F5, B2 } 209#define BACKLIGHT_PINS { F5, B2 }
202``` 210```
211
212## Custom Driver
213
214To enable, add this to your rules.mk:
215
216```makefile
217BACKLIGHT_DRIVER = custom
218```
219
220When implementing the custom driver API, the provided keyboard hooks are as follows:
221
222```c
223void backlight_init_ports(void) {
224 // Optional - Run on startup
225 // - usually you want to configure pins here
226}
227void backlight_set(uint8_t level) {
228 // Optional - Run on level change
229 // - usually you want to respond to the new value
230}
231
232void backlight_task(void) {
233 // Optional - Run periodically
234 // - long running actions here can cause performance issues
235}
236```