aboutsummaryrefslogtreecommitdiffstats
path: root/docs/custom_quantum_functions.md
diff options
context:
space:
mode:
authorGravatar Drashna Jaelre <drashna@live.com>2019-03-18 14:22:02 -0700
committerGravatar MechMerlin <30334081+mechmerlin@users.noreply.github.com>2019-03-18 14:22:02 -0700
commitc534a4c775098f2b6cc8e7f36d35cf642f4323a5 (patch)
treef025c6ade37e4fc6bc930e05fe9a734dd273c974 /docs/custom_quantum_functions.md
parent28e182bc8a2976562e0d76a1332527e0a4be81ea (diff)
downloadqmk_firmware-c534a4c775098f2b6cc8e7f36d35cf642f4323a5.tar.gz
[Docs] Smallish overhaul of the docs (#5281)
* Fix up Common functions doc * Add to extra commands to flashing doc * Rearrange and touch up Macros * Expand Newbs Flashing guide * Update process_record documentation * Add git to best practices name in sidebar * Expand FAQ for build/flashing * Add deprecated info to functions * Update docs/feature_macros.md Co-Authored-By: drashna <drashna@live.com> * Update docs/feature_macros.md Co-Authored-By: drashna <drashna@live.com> * Update docs/flashing.md Co-Authored-By: drashna <drashna@live.com> * Update docs/flashing.md Co-Authored-By: drashna <drashna@live.com> * Update docs/keymap.md Co-Authored-By: drashna <drashna@live.com> * Update docs/newbs_flashing.md Co-Authored-By: drashna <drashna@live.com> * Update docs/newbs_flashing.md Co-Authored-By: drashna <drashna@live.com> * Update docs/custom_quantum_functions.md Co-Authored-By: drashna <drashna@live.com> * Update docs/faq_build.md Co-Authored-By: drashna <drashna@live.com> * Update docs/feature_macros.md Co-Authored-By: drashna <drashna@live.com> * Update docs/keymap.md Co-Authored-By: drashna <drashna@live.com> * Fix up Common functions doc * Make pre-init example accurate * Update docs/custom_quantum_functions.md Co-Authored-By: drashna <drashna@live.com> * Zadig Driver catchall * Spelling Depriciated * Completely remove fn_actions section
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
```c
void led_set_user(uint8_t usb_led) {
if (IS_LED_ON(usb_led, USB_LED_NUM_LOCK)) {
- PORTB |= (1<<0);
+ writePinLow(B0);
} else {
- PORTB &= ~(1<<0);
+ writePinHigh(B0);
}
if (IS_LED_ON(usb_led, USB_LED_CAPS_LOCK)) {
- PORTB |= (1<<1);
+ writePinLow(B1);
} else {
- PORTB &= ~(1<<1);
+ writePinHigh(B1);
}
if (IS_LED_ON(usb_led, USB_LED_SCROLL_LOCK)) {
- PORTB |= (1<<2);
+ writePinLow(B2);
} else {
- PORTB &= ~(1<<2);
+ writePinHigh(B2);
}
if (IS_LED_ON(usb_led, USB_LED_COMPOSE)) {
- PORTB |= (1<<3);
+ writePinLow(B3);
} else {
- PORTB &= ~(1<<3);
+ writePinHigh(B3);
}
if (IS_LED_ON(usb_led, USB_LED_KANA)) {
- PORTB |= (1<<4);
+ writePinLow(B4);
} else {
- PORTB &= ~(1<<4);
+ writePinHigh(B4);
}
}
```
@@ -189,16 +189,18 @@ However, if you have hardware stuff that you need initialized, this is the best
### Example `keyboard_pre_init_user()` Implementation
-This example, at the keyboard level, sets up B1, B2, and B3 as LED pins.
+This example, at the keyboard level, sets up B0, B1, B2, B3, and B4 as LED pins.
```c
void keyboard_pre_init_user(void) {
// Call the keyboard pre init code.
// Set our LED pins as output
- DDRB |= (1<<1);
- DDRB |= (1<<2);
- DDRB |= (1<<3);
+ setPinOutput(B0);
+ setPinOutput(B1);
+ setPinOutput(B2);
+ setPinOutput(B3);
+ setPinOutput(B4);
}
```
@@ -270,16 +272,13 @@ This is controlled by two functions: `suspend_power_down_*` and `suspend_wakeup_
### Example suspend_power_down_user() and suspend_wakeup_init_user() Implementation
-This example, at the keyboard level, sets up B1, B2, and B3 as LED pins.
```c
-void suspend_power_down_user(void)
-{
+void suspend_power_down_user(void) {
rgb_matrix_set_suspend_state(true);
}
-void suspend_wakeup_init_user(void)
-{
+void suspend_wakeup_init_user(void) {
rgb_matrix_set_suspend_state(false);
}
```
@@ -356,11 +355,11 @@ user_config_t user_config;
This 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.
-We're using `rgb_layer_change`, for the `layer_state_set_*` function, and use `matrix_init_user` and `process_record_user` to configure everything.
+We're using `rgb_layer_change`, for the `layer_state_set_*` function, and use `keyboard_post_init_user` and `process_record_user` to configure everything.
-Now, 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:
+Now, 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:
```
-void matrix_init_user(void) {
+void keyboard_post_init_user(void) {
// Call the keymap level matrix init.
// 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
```
void eeconfig_init_user(void) { // EEPROM is getting reset!
+ user_config.raw = 0;
user_config.rgb_layer_change = true; // We want this enabled by default
eeconfig_update_user(user_config.raw); // Write default value to EEPROM now