aboutsummaryrefslogtreecommitdiff
path: root/docs/feature_backlight.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/feature_backlight.md')
-rw-r--r--docs/feature_backlight.md74
1 files changed, 37 insertions, 37 deletions
diff --git a/docs/feature_backlight.md b/docs/feature_backlight.md
index 69391fcefe..545d7be949 100644
--- a/docs/feature_backlight.md
+++ b/docs/feature_backlight.md
@@ -1,10 +1,10 @@
-# Backlighting :id=backlighting
+# Backlighting {#backlighting}
-Many keyboards support backlit keys by way of individual LEDs placed through or underneath the keyswitches. This feature is distinct from both the [RGB Underglow](feature_rgblight.md) and [RGB Matrix](feature_rgb_matrix.md) features as it usually allows for only a single colour per switch, though you can obviously install multiple different single coloured LEDs on a keyboard.
+Many keyboards support backlit keys by way of individual LEDs placed through or underneath the keyswitches. This feature is distinct from both the [RGB Underglow](feature_rgblight) and [RGB Matrix](feature_rgb_matrix) features as it usually allows for only a single colour per switch, though you can obviously install multiple different single coloured LEDs on a keyboard.
QMK is able to control the brightness of these LEDs by switching them on and off rapidly in a certain ratio, a technique known as *Pulse Width Modulation*, or PWM. By altering the duty cycle of the PWM signal, it creates the illusion of dimming.
-## Usage :id=usage
+## Usage {#usage}
Most keyboards have backlighting enabled by default if they support it, but if it is not working for you (or you have added support), check that your `rules.mk` includes the following:
@@ -12,7 +12,7 @@ Most keyboards have backlighting enabled by default if they support it, but if i
BACKLIGHT_ENABLE = yes
```
-## Keycodes :id=keycodes
+## Keycodes {#keycodes}
|Key |Aliases |Description |
|-------------------------------|---------|-----------------------------------|
@@ -24,7 +24,7 @@ BACKLIGHT_ENABLE = yes
|`QK_BACKLIGHT_DOWN` |`BL_DOWN`|Decrease the backlight level |
|`QK_BACKLIGHT_TOGGLE_BREATHING`|`BL_BRTG`|Toggle backlight breathing |
-## Basic Configuration :id=basic-configuration
+## Basic Configuration {#basic-configuration}
Add the following to your `config.h`:
@@ -43,7 +43,7 @@ Add the following to your `config.h`:
Unless you are designing your own keyboard, you generally should not need to change the `BACKLIGHT_PIN` or `BACKLIGHT_ON_STATE`.
-### "On" State :id=on-state
+### "On" State {#on-state}
Most backlight circuits are driven by an N-channel MOSFET or NPN transistor. This means that to turn the transistor *on* and light the LEDs, you must drive the backlight pin, connected to the gate or base, *high*.
Sometimes, however, a P-channel MOSFET, or a PNP transistor is used. In this case, when the transistor is on, the pin is driven *low* instead.
@@ -54,7 +54,7 @@ To configure the "on" state of the backlight circuit, add the following to your
#define BACKLIGHT_ON_STATE 0
```
-### Multiple Backlight Pins :id=multiple-backlight-pins
+### Multiple Backlight Pins {#multiple-backlight-pins}
Most keyboards have only one backlight pin which controls all backlight LEDs (especially if the backlight is connected to a hardware PWM pin).
The `timer` and `software` drivers allow you to define multiple backlight pins, which will be turned on and off at the same time during the PWM duty cycle.
@@ -67,11 +67,11 @@ To configure multiple backlight pins, add something like this to your `config.h`
#define BACKLIGHT_PINS { F5, B2 }
```
-## Driver Configuration :id=driver-configuration
+## Driver Configuration {#driver-configuration}
Backlight driver selection is configured in `rules.mk`. Valid drivers are `pwm` (default), `timer`, `software`, or `custom`. See below for information on individual drivers.
-### PWM Driver :id=pwm-driver
+### PWM Driver {#pwm-driver}
This is the default backlight driver, which leverages the hardware PWM output capability of the microcontroller.
@@ -79,7 +79,7 @@ This is the default backlight driver, which leverages the hardware PWM output ca
BACKLIGHT_DRIVER = pwm
```
-### Timer Driver :id=timer-driver
+### Timer Driver {#timer-driver}
This driver is similar to the PWM driver, but instead of directly configuring the pin to output a PWM signal, an interrupt handler is attached to the timer to turn the pin on and off as appropriate.
@@ -87,7 +87,7 @@ This driver is similar to the PWM driver, but instead of directly configuring th
BACKLIGHT_DRIVER = timer
```
-### Software Driver :id=software-driver
+### Software Driver {#software-driver}
In this mode, PWM is "emulated" while running other keyboard tasks. It offers maximum hardware compatibility without extra platform configuration. However, breathing is not supported, and the backlight can flicker when the keyboard is busy.
@@ -95,7 +95,7 @@ In this mode, PWM is "emulated" while running other keyboard tasks. It offers ma
BACKLIGHT_DRIVER = software
```
-### Custom Driver :id=custom-driver
+### Custom Driver {#custom-driver}
If none of the above drivers apply to your board (for example, you are using a separate IC to control the backlight), you can implement a custom backlight driver using a simple API.
@@ -120,9 +120,9 @@ void backlight_task(void) {
}
```
-## AVR Configuration :id=avr-configuration
+## AVR Configuration {#avr-configuration}
-### PWM Driver :id=avr-pwm-driver
+### PWM Driver {#avr-pwm-driver}
The following table describes the supported pins for the PWM driver. Only cells marked with a timer number are capable of hardware PWM output; any others must use the `timer` driver.
@@ -139,7 +139,7 @@ The following table describes the supported pins for the PWM driver. Only cells
|`D4` | | | | |Timer 1 | |
|`D5` | | | | |Timer 1 | |
-### Timer Driver :id=avr-timer-driver
+### Timer Driver {#avr-timer-driver}
Any GPIO pin can be used with this driver. The following table describes the supported timers:
@@ -153,11 +153,11 @@ The following `#define`s apply only to the `timer` driver:
|-----------------------|-------|----------------|
|`BACKLIGHT_PWM_TIMER` |`1` |The timer to use|
-Note that the choice of timer may conflict with the [Audio](feature_audio.md) feature.
+Note that the choice of timer may conflict with the [Audio](feature_audio) feature.
-## ChibiOS/ARM Configuration :id=arm-configuration
+## ChibiOS/ARM Configuration {#arm-configuration}
-### PWM Driver :id=arm-pwm-driver
+### PWM Driver {#arm-pwm-driver}
Depending on the ChibiOS board configuration, you may need to enable PWM at the keyboard level. For STM32, this would look like:
@@ -183,7 +183,7 @@ The following `#define`s apply only to the `pwm` driver:
Refer to the ST datasheet for your particular MCU to determine these values. For example, these defaults are set up for pin `B8` on a Proton-C (STM32F303) using `TIM4_CH3` on AF2. Unless you are designing your own keyboard, you generally should not need to change them.
-### Timer Driver :id=arm-timer-driver
+### Timer Driver {#arm-timer-driver}
Depending on the ChibiOS board configuration, you may need to enable general-purpose timers at the keyboard level. For STM32, this would look like:
@@ -213,97 +213,97 @@ The values of these resistors are not critical - see [this Electronics StackExch
![Backlight example circuit](https://i.imgur.com/BmAvoUC.png)
-## API :id=api
+## API {#api}
-### `void backlight_toggle(void)` :id=api-backlight-toggle
+### `void backlight_toggle(void)` {#api-backlight-toggle}
Toggle the backlight on or off.
---
-### `void backlight_enable(void)` :id=api-backlight-enable
+### `void backlight_enable(void)` {#api-backlight-enable}
Turn the backlight on.
---
-### `void backlight_disable(void)` :id=api-backlight-disable
+### `void backlight_disable(void)` {#api-backlight-disable}
Turn the backlight off.
---
-### `void backlight_step(void)` :id=api-backlight-step
+### `void backlight_step(void)` {#api-backlight-step}
Cycle through backlight levels.
---
-### `void backlight_increase(void)` :id=api-backlight-increase
+### `void backlight_increase(void)` {#api-backlight-increase}
Increase the backlight level.
---
-### `void backlight_decrease(void)` :id=api-backlight-decrease
+### `void backlight_decrease(void)` {#api-backlight-decrease}
Decrease the backlight level.
---
-### `void backlight_level(uint8_t level)` :id=api-backlight-level
+### `void backlight_level(uint8_t level)` {#api-backlight-level}
Set the backlight level.
-#### Arguments :id=api-backlight-level-arguments
+#### Arguments {#api-backlight-level-arguments}
- `uint8_t level`
The level to set, from 0 to `BACKLIGHT_LEVELS`.
---
-### `uint8_t get_backlight_level(void)` :id=api-get-backlight-level
+### `uint8_t get_backlight_level(void)` {#api-get-backlight-level}
Get the current backlight level.
-#### Return Value :id=api-get-backlight-level-return
+#### Return Value {#api-get-backlight-level-return}
The current backlight level, from 0 to `BACKLIGHT_LEVELS`.
---
-### `bool is_backlight_enabled(void)` :id=api-is-backlight-enabled
+### `bool is_backlight_enabled(void)` {#api-is-backlight-enabled}
Get the current backlight state.
-#### Return Value :id=api-is-backlight-enabled-return
+#### Return Value {#api-is-backlight-enabled-return}
`true` if the backlight is enabled.
---
-### `void backlight_toggle_breathing(void)` :id=api-backlight-toggle-breathing
+### `void backlight_toggle_breathing(void)` {#api-backlight-toggle-breathing}
Toggle backlight breathing on or off.
---
-### `void backlight_enable_breathing(void)` :id=api-backlight-enable-breathing
+### `void backlight_enable_breathing(void)` {#api-backlight-enable-breathing}
Turn backlight breathing on.
---
-### `void backlight_disable_breathing(void)` :id=api-backlight-disable-breathing
+### `void backlight_disable_breathing(void)` {#api-backlight-disable-breathing}
Turn backlight breathing off.
---
-### `bool is_backlight_breathing(void)` :id=api-is-backlight-breathing
+### `bool is_backlight_breathing(void)` {#api-is-backlight-breathing}
Get the current backlight breathing state.
-#### Return Value :id=api-is-backlight-breathing-return
+#### Return Value {#api-is-backlight-breathing-return}
`true` if backlight breathing is enabled.