diff options
Diffstat (limited to 'docs/custom_quantum_functions.md')
-rw-r--r-- | docs/custom_quantum_functions.md | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/docs/custom_quantum_functions.md b/docs/custom_quantum_functions.md index ab3a72e5d..984787331 100644 --- a/docs/custom_quantum_functions.md +++ b/docs/custom_quantum_functions.md | |||
@@ -139,7 +139,7 @@ void led_set_user(uint8_t usb_led) { | |||
139 | 139 | ||
140 | 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. | 140 | 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. |
141 | 141 | ||
142 | ### Example `matrix_init_kb()` Implementation | 142 | ### Example `matrix_init_user()` Implementation |
143 | 143 | ||
144 | This example, at the keyboard level, sets up B1, B2, and B3 as LED pins. | 144 | This example, at the keyboard level, sets up B1, B2, and B3 as LED pins. |
145 | 145 | ||
@@ -177,3 +177,39 @@ This function gets called at every matrix scan, which is basically as often as t | |||
177 | 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. | 177 | 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. |
178 | 178 | ||
179 | 179 | ||
180 | # Layer Change Code | ||
181 | |||
182 | Thir runs code every time that the layers get changed. This can be useful for layer indication, or custom layer handling. | ||
183 | |||
184 | ### Example `layer_state_set_*` Implementation | ||
185 | |||
186 | This example shows how to set the [RGB Underglow](feature_rgblight.md) lights based on the layer, using the Planck as an example | ||
187 | |||
188 | ``` | ||
189 | uint32_t layer_state_set_user(uint32_t state) { | ||
190 | switch (biton32(state)) { | ||
191 | case _RAISE: | ||
192 | rgblight_setrgb (0x00, 0x00, 0xFF); | ||
193 | break; | ||
194 | case _LOWER: | ||
195 | rgblight_setrgb (0xFF, 0x00, 0x00); | ||
196 | break; | ||
197 | case _PLOVER: | ||
198 | rgblight_setrgb (0x00, 0xFF, 0x00); | ||
199 | break; | ||
200 | case _ADJUST: | ||
201 | rgblight_setrgb (0x7A, 0x00, 0xFF); | ||
202 | break; | ||
203 | default: // for any other layers, or the default layer | ||
204 | rgblight_setrgb (0x00, 0xFF, 0xFF); | ||
205 | break; | ||
206 | } | ||
207 | return state; | ||
208 | } | ||
209 | ``` | ||
210 | ### `matrix_init_*` Function Documentation | ||
211 | |||
212 | * Keyboard/Revision: `void uint32_t layer_state_set_kb(uint32_t state)` | ||
213 | * Keymap: `uint32_t layer_state_set_user(uint32_t state)` | ||
214 | |||
215 | The `state` is the bitmask of the active layers, as explained in the [Keymap Overview](keymap.md#keymap-layer-status) | ||