aboutsummaryrefslogtreecommitdiff
path: root/docs/custom_quantum_functions.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/custom_quantum_functions.md')
-rw-r--r--docs/custom_quantum_functions.md44
1 files changed, 22 insertions, 22 deletions
diff --git a/docs/custom_quantum_functions.md b/docs/custom_quantum_functions.md
index f291fc2d2..655fa1578 100644
--- a/docs/custom_quantum_functions.md
+++ b/docs/custom_quantum_functions.md
@@ -116,29 +116,29 @@ Use the `IS_LED_ON(usb_led, led_name)` and `IS_LED_OFF(usb_led, led_name)` macro
116```c 116```c
117void led_set_user(uint8_t usb_led) { 117void led_set_user(uint8_t usb_led) {
118 if (IS_LED_ON(usb_led, USB_LED_NUM_LOCK)) { 118 if (IS_LED_ON(usb_led, USB_LED_NUM_LOCK)) {
119 PORTB |= (1<<0); 119 writePinLow(B0);
120 } else { 120 } else {
121 PORTB &= ~(1<<0); 121 writePinHigh(B0);
122 } 122 }
123 if (IS_LED_ON(usb_led, USB_LED_CAPS_LOCK)) { 123 if (IS_LED_ON(usb_led, USB_LED_CAPS_LOCK)) {
124 PORTB |= (1<<1); 124 writePinLow(B1);
125 } else { 125 } else {
126 PORTB &= ~(1<<1); 126 writePinHigh(B1);
127 } 127 }
128 if (IS_LED_ON(usb_led, USB_LED_SCROLL_LOCK)) { 128 if (IS_LED_ON(usb_led, USB_LED_SCROLL_LOCK)) {
129 PORTB |= (1<<2); 129 writePinLow(B2);
130 } else { 130 } else {
131 PORTB &= ~(1<<2); 131 writePinHigh(B2);
132 } 132 }
133 if (IS_LED_ON(usb_led, USB_LED_COMPOSE)) { 133 if (IS_LED_ON(usb_led, USB_LED_COMPOSE)) {
134 PORTB |= (1<<3); 134 writePinLow(B3);
135 } else { 135 } else {
136 PORTB &= ~(1<<3); 136 writePinHigh(B3);
137 } 137 }
138 if (IS_LED_ON(usb_led, USB_LED_KANA)) { 138 if (IS_LED_ON(usb_led, USB_LED_KANA)) {
139 PORTB |= (1<<4); 139 writePinLow(B4);
140 } else { 140 } else {
141 PORTB &= ~(1<<4); 141 writePinHigh(B4);
142 } 142 }
143} 143}
144``` 144```
@@ -189,16 +189,18 @@ However, if you have hardware stuff that you need initialized, this is the best
189 189
190### Example `keyboard_pre_init_user()` Implementation 190### Example `keyboard_pre_init_user()` Implementation
191 191
192This example, at the keyboard level, sets up B1, B2, and B3 as LED pins. 192This example, at the keyboard level, sets up B0, B1, B2, B3, and B4 as LED pins.
193 193
194```c 194```c
195void keyboard_pre_init_user(void) { 195void keyboard_pre_init_user(void) {
196 // Call the keyboard pre init code. 196 // Call the keyboard pre init code.
197 197
198 // Set our LED pins as output 198 // Set our LED pins as output
199 DDRB |= (1<<1); 199 setPinOutput(B0);
200 DDRB |= (1<<2); 200 setPinOutput(B1);
201 DDRB |= (1<<3); 201 setPinOutput(B2);
202 setPinOutput(B3);
203 setPinOutput(B4);
202} 204}
203``` 205```
204 206
@@ -270,16 +272,13 @@ This is controlled by two functions: `suspend_power_down_*` and `suspend_wakeup_
270 272
271### Example suspend_power_down_user() and suspend_wakeup_init_user() Implementation 273### Example suspend_power_down_user() and suspend_wakeup_init_user() Implementation
272 274
273This example, at the keyboard level, sets up B1, B2, and B3 as LED pins.
274 275
275```c 276```c
276void suspend_power_down_user(void) 277void suspend_power_down_user(void) {
277{
278 rgb_matrix_set_suspend_state(true); 278 rgb_matrix_set_suspend_state(true);
279} 279}
280 280
281void suspend_wakeup_init_user(void) 281void suspend_wakeup_init_user(void) {
282{
283 rgb_matrix_set_suspend_state(false); 282 rgb_matrix_set_suspend_state(false);
284} 283}
285``` 284```
@@ -356,11 +355,11 @@ user_config_t user_config;
356 355
357This sets up a 32 bit structure that we can store settings with in memory, and write to the EEPROM. Using this removes the need to define variables, since they're defined in this structure. Remember that `bool` (boolean) values use 1 bit, `uint8_t` uses 8 bits, `uint16_t` uses up 16 bits. You can mix and match, but changing the order can cause issues, as it will change the values that are read and written. 356This sets up a 32 bit structure that we can store settings with in memory, and write to the EEPROM. Using this removes the need to define variables, since they're defined in this structure. Remember that `bool` (boolean) values use 1 bit, `uint8_t` uses 8 bits, `uint16_t` uses up 16 bits. You can mix and match, but changing the order can cause issues, as it will change the values that are read and written.
358 357
359We're using `rgb_layer_change`, for the `layer_state_set_*` function, and use `matrix_init_user` and `process_record_user` to configure everything. 358We're using `rgb_layer_change`, for the `layer_state_set_*` function, and use `keyboard_post_init_user` and `process_record_user` to configure everything.
360 359
361Now, using the `matrix_init_user` code above, you want to add `eeconfig_read_user()` to it, to populate the structure you've just created. And you can then immediately use this structure to control functionality in your keymap. And It should look like: 360Now, using the `keyboard_post_init_user` code above, you want to add `eeconfig_read_user()` to it, to populate the structure you've just created. And you can then immediately use this structure to control functionality in your keymap. And It should look like:
362``` 361```
363void matrix_init_user(void) { 362void keyboard_post_init_user(void) {
364 // Call the keymap level matrix init. 363 // Call the keymap level matrix init.
365 364
366 // Read the user config from EEPROM 365 // Read the user config from EEPROM
@@ -447,6 +446,7 @@ And lastly, you want to add the `eeconfig_init_user` function, so that when the
447 446
448``` 447```
449void eeconfig_init_user(void) { // EEPROM is getting reset! 448void eeconfig_init_user(void) { // EEPROM is getting reset!
449 user_config.raw = 0;
450 user_config.rgb_layer_change = true; // We want this enabled by default 450 user_config.rgb_layer_change = true; // We want this enabled by default
451 eeconfig_update_user(user_config.raw); // Write default value to EEPROM now 451 eeconfig_update_user(user_config.raw); // Write default value to EEPROM now
452 452