summaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
authorYan-Fa Li <yanfali@gmail.com>2019-11-23 07:37:25 -0800
committerJoel Challis <git@zvecr.com>2019-11-23 15:37:25 +0000
commit3541f01a72c4bf2e284d6c96b9697d29c68a47bd (patch)
tree3bdb7cc003a890ae45edf1751d4a0e88ff91aa18 /docs
parenteae21eed743d8bb9fd961f91d97a92f0f94247fe (diff)
Update led_update_kb example (#7451)
* Update led_update_kb example * Update comment to explain pin behavior * wordsmith * wordsmithing 2
Diffstat (limited to 'docs')
-rw-r--r--docs/custom_quantum_functions.md35
1 files changed, 10 insertions, 25 deletions
diff --git a/docs/custom_quantum_functions.md b/docs/custom_quantum_functions.md
index 3879e43bc7..71a30bc7c6 100644
--- a/docs/custom_quantum_functions.md
+++ b/docs/custom_quantum_functions.md
@@ -132,31 +132,16 @@ Some examples include:
bool led_update_kb(led_t led_state) {
bool res = led_update_user(led_state);
if(res) {
- if (led_state.num_lock) {
- writePinLow(B0);
- } else {
- writePinHigh(B0);
- }
- if (led_state.caps_lock) {
- writePinLow(B1);
- } else {
- writePinHigh(B1);
- }
- if (led_state.scroll_lock) {
- writePinLow(B2);
- } else {
- writePinHigh(B2);
- }
- if (led_state.compose) {
- writePinLow(B3);
- } else {
- writePinHigh(B3);
- }
- if (led_state.kana) {
- writePinLow(B4);
- } else {
- writePinHigh(B4);
- }
+ // writePin sets the pin high for 1 and low for 0.
+ // In this example the pins are inverted, setting
+ // it low/0 turns it on, and high/1 turns the LED off.
+ // This behavior depends on whether the LED is between the pin
+ // and VCC or the pin and GND.
+ writePin(B0, !led_state.num_lock);
+ writePin(B1, !led_state.caps_lock);
+ writePin(B2, !led_state.scroll_lock);
+ writePin(B3, !led_state.compose);
+ writePin(B4, !led_state.kana);
}
return res;
}