aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Challis <git@zvecr.com>2019-12-16 16:39:54 +0000
committerGitHub <noreply@github.com>2019-12-16 16:39:54 +0000
commitadb72b60b0ea151ad12df03b1d6659fad464c400 (patch)
tree8540ee009c9faebd0e09d95dee2f26a1f1980342
parentbc2157eea8aa99970a3785439efe5823fc76b0b4 (diff)
parent3d54b1adf072938c46efba89e31b2afef407db85 (diff)
downloadqmk_firmware-adb72b60b0ea151ad12df03b1d6659fad464c400.tar.gz
qmk_firmware-adb72b60b0ea151ad12df03b1d6659fad464c400.zip
Merge pull request #7276 from zvecr/feature/backlight_driver_config
Convert backlight to follow driver rules pattern
-rw-r--r--common_features.mk15
-rw-r--r--docs/feature_backlight.md52
-rw-r--r--quantum/stm32/proton_c.mk4
3 files changed, 52 insertions, 19 deletions
diff --git a/common_features.mk b/common_features.mk
index 1c814286c..9b60eeed0 100644
--- a/common_features.mk
+++ b/common_features.mk
@@ -231,15 +231,16 @@ endif
231 231
232# backward compat 232# backward compat
233ifeq ($(strip $(BACKLIGHT_CUSTOM_DRIVER)), yes) 233ifeq ($(strip $(BACKLIGHT_CUSTOM_DRIVER)), yes)
234 BACKLIGHT_ENABLE = custom 234 BACKLIGHT_DRIVER = custom
235endif 235endif
236 236
237VALID_BACKLIGHT_TYPES := yes software custom 237VALID_BACKLIGHT_TYPES := pwm software custom
238 238
239BACKLIGHT_ENABLE ?= no 239BACKLIGHT_ENABLE ?= no
240ifneq ($(strip $(BACKLIGHT_ENABLE)), no) 240BACKLIGHT_DRIVER ?= pwm
241 ifeq ($(filter $(BACKLIGHT_ENABLE),$(VALID_BACKLIGHT_TYPES)),) 241ifeq ($(strip $(BACKLIGHT_ENABLE)), yes)
242 $(error BACKLIGHT_ENABLE="$(BACKLIGHT_ENABLE)" is not a valid backlight type) 242 ifeq ($(filter $(BACKLIGHT_DRIVER),$(VALID_BACKLIGHT_TYPES)),)
243 $(error BACKLIGHT_DRIVER="$(BACKLIGHT_DRIVER)" is not a valid backlight type)
243 endif 244 endif
244 245
245 ifeq ($(strip $(VISUALIZER_ENABLE)), yes) 246 ifeq ($(strip $(VISUALIZER_ENABLE)), yes)
@@ -250,10 +251,10 @@ ifneq ($(strip $(BACKLIGHT_ENABLE)), no)
250 SRC += $(QUANTUM_DIR)/backlight/backlight.c 251 SRC += $(QUANTUM_DIR)/backlight/backlight.c
251 OPT_DEFS += -DBACKLIGHT_ENABLE 252 OPT_DEFS += -DBACKLIGHT_ENABLE
252 253
253 ifeq ($(strip $(BACKLIGHT_ENABLE)), software) 254 ifeq ($(strip $(BACKLIGHT_DRIVER)), software)
254 SRC += $(QUANTUM_DIR)/backlight/backlight_soft.c 255 SRC += $(QUANTUM_DIR)/backlight/backlight_soft.c
255 else 256 else
256 ifeq ($(strip $(BACKLIGHT_ENABLE)), custom) 257 ifeq ($(strip $(BACKLIGHT_DRIVER)), custom)
257 OPT_DEFS += -DBACKLIGHT_CUSTOM_DRIVER 258 OPT_DEFS += -DBACKLIGHT_CUSTOM_DRIVER
258 endif 259 endif
259 260
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```
diff --git a/quantum/stm32/proton_c.mk b/quantum/stm32/proton_c.mk
index ff28a4cb5..b25b55504 100644
--- a/quantum/stm32/proton_c.mk
+++ b/quantum/stm32/proton_c.mk
@@ -5,9 +5,7 @@ AUDIO_ENABLE = yes
5WS2812_DRIVER = bitbang 5WS2812_DRIVER = bitbang
6 6
7# Force task driven PWM until ARM can provide automatic configuration 7# Force task driven PWM until ARM can provide automatic configuration
8ifneq ($(strip $(BACKLIGHT_ENABLE)), no) 8BACKLIGHT_DRIVER = software
9 BACKLIGHT_ENABLE = software
10endif
11 9
12# The rest of these settings shouldn't change 10# The rest of these settings shouldn't change
13 11