aboutsummaryrefslogtreecommitdiff
path: root/docs/custom_quantum_functions.md
diff options
context:
space:
mode:
authorzvecr <git@zvecr.com>2019-04-01 19:32:39 +0100
committerMechMerlin <30334081+mechmerlin@users.noreply.github.com>2019-04-01 11:32:39 -0700
commit40c6269f9fdd279b16ee49e49c8fbd256b79ccae (patch)
tree58a51a3dd7f79ec94cc18fac87546e25f4027126 /docs/custom_quantum_functions.md
parent58b065cfdaca29144fa7fd18d482223bc1ea7308 (diff)
downloadqmk_firmware-40c6269f9fdd279b16ee49e49c8fbd256b79ccae.tar.gz
qmk_firmware-40c6269f9fdd279b16ee49e49c8fbd256b79ccae.zip
Fix typo in keyboard_post_init_user example, remove EPRM from Persistent Configuration (EEPROM) (#5528)
Diffstat (limited to 'docs/custom_quantum_functions.md')
-rw-r--r--docs/custom_quantum_functions.md21
1 files changed, 8 insertions, 13 deletions
diff --git a/docs/custom_quantum_functions.md b/docs/custom_quantum_functions.md
index 655fa1578..418faf349 100644
--- a/docs/custom_quantum_functions.md
+++ b/docs/custom_quantum_functions.md
@@ -235,7 +235,7 @@ This example, running after everything else has initialized, sets up the rgb und
235void keyboard_post_init_user(void) { 235void keyboard_post_init_user(void) {
236 // Call the post init code. 236 // Call the post init code.
237 rgblight_enable_noeeprom(); // enables Rgb, without saving settings 237 rgblight_enable_noeeprom(); // enables Rgb, without saving settings
238 rgblight_sethsv_noeeprom(180, 255, 255): // sets the color to teal/cyan without saving 238 rgblight_sethsv_noeeprom(180, 255, 255); // sets the color to teal/cyan without saving
239 rgblight_mode_noeeprom(RGBLIGHT_MODE_BREATHING + 3); // sets mode to Fast breathing without saving 239 rgblight_mode_noeeprom(RGBLIGHT_MODE_BREATHING + 3); // sets mode to Fast breathing without saving
240} 240}
241``` 241```
@@ -342,7 +342,7 @@ This is an example of how to add settings, and read and write it. We're using th
342 342
343 343
344In your keymap.c file, add this to the top: 344In your keymap.c file, add this to the top:
345``` 345```c
346typedef union { 346typedef union {
347 uint32_t raw; 347 uint32_t raw;
348 struct { 348 struct {
@@ -358,7 +358,7 @@ This sets up a 32 bit structure that we can store settings with in memory, and w
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. 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.
359 359
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: 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:
361``` 361```c
362void keyboard_post_init_user(void) { 362void keyboard_post_init_user(void) {
363 // Call the keymap level matrix init. 363 // Call the keymap level matrix init.
364 364
@@ -375,7 +375,7 @@ void keyboard_post_init_user(void) {
375``` 375```
376The above function will use the EEPROM config immediately after reading it, to set the default layer's RGB color. The "raw" value of it is converted in a usable structure based on the "union" that you created above. 376The above function will use the EEPROM config immediately after reading it, to set the default layer's RGB color. The "raw" value of it is converted in a usable structure based on the "union" that you created above.
377 377
378``` 378```c
379uint32_t layer_state_set_user(uint32_t state) { 379uint32_t layer_state_set_user(uint32_t state) {
380 switch (biton32(state)) { 380 switch (biton32(state)) {
381 case _RAISE: 381 case _RAISE:
@@ -397,8 +397,8 @@ uint32_t layer_state_set_user(uint32_t state) {
397 return state; 397 return state;
398} 398}
399``` 399```
400This will cause the RGB underglow to be changed ONLY if the value was enabled. Now to configure this value, create a new keycode for `process_record_user` called `RGB_LYR` and `EPRM`. Additionally, we want to make sure that if you use the normal RGB codes, that it turns off Using the example above, make it look this: 400This will cause the RGB underglow to be changed ONLY if the value was enabled. Now to configure this value, create a new keycode for `process_record_user` called `RGB_LYR`. Additionally, we want to make sure that if you use the normal RGB codes, that it turns off Using the example above, make it look this:
401``` 401```c
402 402
403bool process_record_user(uint16_t keycode, keyrecord_t *record) { 403bool process_record_user(uint16_t keycode, keyrecord_t *record) {
404 switch (keycode) { 404 switch (keycode) {
@@ -415,11 +415,6 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
415 PLAY_NOTE_ARRAY(tone_qwerty); 415 PLAY_NOTE_ARRAY(tone_qwerty);
416 } 416 }
417 return true; // Let QMK send the enter press/release events 417 return true; // Let QMK send the enter press/release events
418 case EPRM:
419 if (record->event.pressed) {
420 eeconfig_init(); // resets the EEPROM to default
421 }
422 return false;
423 case RGB_LYR: // This allows me to use underglow as layer indication, or as normal 418 case RGB_LYR: // This allows me to use underglow as layer indication, or as normal
424 if (record->event.pressed) { 419 if (record->event.pressed) {
425 user_config.rgb_layer_change ^= 1; // Toggles the status 420 user_config.rgb_layer_change ^= 1; // Toggles the status
@@ -442,9 +437,9 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
442 } 437 }
443} 438}
444``` 439```
445And lastly, you want to add the `eeconfig_init_user` function, so that when the EEPROM is reset, you can specify default values, and even custom actions. For example, if you want to set rgb layer indication by default, and save the default valued. 440And lastly, you want to add the `eeconfig_init_user` function, so that when the EEPROM is reset, you can specify default values, and even custom actions. To force an EEPROM reset, use the `EEP_RST` keycode or [Bootmagic](feature_bootmagic.md) functionallity. For example, if you want to set rgb layer indication by default, and save the default valued.
446 441
447``` 442```c
448void eeconfig_init_user(void) { // EEPROM is getting reset! 443void eeconfig_init_user(void) { // EEPROM is getting reset!
449 user_config.raw = 0; 444 user_config.raw = 0;
450 user_config.rgb_layer_change = true; // We want this enabled by default 445 user_config.rgb_layer_change = true; // We want this enabled by default