aboutsummaryrefslogtreecommitdiff
path: root/docs/feature_dip_switch.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/feature_dip_switch.md')
-rw-r--r--docs/feature_dip_switch.md19
1 files changed, 12 insertions, 7 deletions
diff --git a/docs/feature_dip_switch.md b/docs/feature_dip_switch.md
index 15e449c4c..6fbe91657 100644
--- a/docs/feature_dip_switch.md
+++ b/docs/feature_dip_switch.md
@@ -9,6 +9,8 @@ and this to your `config.h`:
9```c 9```c
10// Connects each switch in the dip switch to the GPIO pin of the MCU 10// Connects each switch in the dip switch to the GPIO pin of the MCU
11#define DIP_SWITCH_PINS { B14, A15, A10, B9 } 11#define DIP_SWITCH_PINS { B14, A15, A10, B9 }
12// For split keyboards, you can separately define the right side pins
13#define DIP_SWITCH_PINS_RIGHT { ... }
12``` 14```
13 15
14or 16or
@@ -23,8 +25,9 @@ or
23The callback functions can be inserted into your `<keyboard>.c`: 25The callback functions can be inserted into your `<keyboard>.c`:
24 26
25```c 27```c
26void dip_switch_update_kb(uint8_t index, bool active) { 28bool dip_switch_update_kb(uint8_t index, bool active) {
27 dip_switch_update_user(index, active); 29 if (!dip_switch_update_user(index, active)) { return false; }
30 return true;
28} 31}
29``` 32```
30 33
@@ -32,7 +35,7 @@ void dip_switch_update_kb(uint8_t index, bool active) {
32or `keymap.c`: 35or `keymap.c`:
33 36
34```c 37```c
35void dip_switch_update_user(uint8_t index, bool active) { 38bool dip_switch_update_user(uint8_t index, bool active) {
36 switch (index) { 39 switch (index) {
37 case 0: 40 case 0:
38 if(active) { audio_on(); } else { audio_off(); } 41 if(active) { audio_on(); } else { audio_off(); }
@@ -57,6 +60,7 @@ void dip_switch_update_user(uint8_t index, bool active) {
57 } 60 }
58 break; 61 break;
59 } 62 }
63 return true;
60} 64}
61``` 65```
62 66
@@ -64,8 +68,9 @@ Additionally, we support bit mask functions which allow for more complex handlin
64 68
65 69
66```c 70```c
67void dip_switch_update_mask_kb(uint32_t state) { 71bool dip_switch_update_mask_kb(uint32_t state) {
68 dip_switch_update_mask_user(state); 72 if (!dip_switch_update_mask_user(state)) { return false; }
73 return true;
69} 74}
70``` 75```
71 76
@@ -73,7 +78,7 @@ void dip_switch_update_mask_kb(uint32_t state) {
73or `keymap.c`: 78or `keymap.c`:
74 79
75```c 80```c
76void dip_switch_update_mask_user(uint32_t state) { 81bool dip_switch_update_mask_user(uint32_t state) {
77 if (state & (1UL<<0) && state & (1UL<<1)) { 82 if (state & (1UL<<0) && state & (1UL<<1)) {
78 layer_on(_ADJUST); // C on esc 83 layer_on(_ADJUST); // C on esc
79 } else { 84 } else {
@@ -89,10 +94,10 @@ void dip_switch_update_mask_user(uint32_t state) {
89 } else { 94 } else {
90 layer_off(_TEST_B); 95 layer_off(_TEST_B);
91 } 96 }
97 return true;
92} 98}
93``` 99```
94 100
95
96## Hardware 101## Hardware
97 102
98### Connects each switch in the dip switch to the GPIO pin of the MCU 103### Connects each switch in the dip switch to the GPIO pin of the MCU