* Defined IS_(HOST_)LED_ON/OFF() and improved LED documentation
* Update docs/custom_quantum_functions.md
Co-Authored-By: DidierLoiseau <didierloiseau+github@gmail.com>
* Update docs/custom_quantum_functions.md
Co-Authored-By: DidierLoiseau <didierloiseau+github@gmail.com>
* Integrated @drashna and @fauxpark's PR comments
- changed all plurals of "LED" to "LEDs" in the file
- rewording of the note about host_keyboard_leds() vs. led_set_user()
* Update docs/custom_quantum_functions.md
Co-Authored-By: DidierLoiseau <didierloiseau+github@gmail.com>
pull/4866/head0.6.238
DidierLoiseau6 years agocommitted byDrashna Jaelre
Call this function to get the last received LED state.
This is useful for reading the LED state outside `led_set_*`, e.g. in [`matrix_scan_user()`](#matrix-scanning-code).
For convenience, you can use the `IS_HOST_LED_ON(LED_NAME)` and `IS_HOST_LED_OFF(LED_NAME)` macros instead of calling `host_keyboard_leds()` directly.
## Setting physical LED state
Some keyboard implementations provide convenience methods for setting the state of the physical LEDs.
### Ergodox and Ergodox EZ
The Ergodox EZ implementation provides `ergodox_right_led_``1`/`2`/`3_on`/`off()`
to turn individual LEDs on and off, as well as
`ergodox_right_led_on`/`off(uint8_t led)`
to turn them on and off by their number.
In addition, it is possible to specify the brightness level with `ergodox_led_all_set(uint8_t n)`,
for individual LEDs with `ergodox_right_led_1`/`2`/`3_set(uint8_t n)`
or by their number using `ergodox_right_led_set(uint8_t led, uint8_t n)`.
It defines `LED_BRIGHTNESS_LO` for the lowest brightness and `LED_BRIGHTNESS_HI` for the highest brightness, which is also the default.
# Matrix Initialization Code
Before a keyboard can be used the hardware must be initialized. QMK handles initialization of the keyboard matrix itself, but if you have other hardware like LED's or i²c controllers you will need to set up that hardware before it can be used.
Before a keyboard can be used the hardware must be initialized. QMK handles initialization of the keyboard matrix itself, but if you have other hardware like LEDs or i²c controllers you will need to set up that hardware before it can be used.
### Example `matrix_init_user()` Implementation
@ -176,7 +214,7 @@ This example has been deliberately omitted. You should understand enough about Q
This function gets called at every matrix scan, which is basically as often as the MCU can handle. Be careful what you put here, as it will get run a lot.
You should use this function if you need custom matrix scanning code. It can also be used for custom status output (such as LED's or a display) or other functionality that you want to trigger regularly even when the user isn't typing.
You should use this function if you need custom matrix scanning code. It can also be used for custom status output (such as LEDs or a display) or other functionality that you want to trigger regularly even when the user isn't typing.