aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzvecr <git@zvecr.com>2019-05-04 01:24:07 +0100
committerDrashna Jaelre <drashna@live.com>2019-05-03 17:24:07 -0700
commitda995d2aeace38cd548c77f341920fab49501ded (patch)
tree49ccf7e44338db3ed1fa68938cdb81011235be93
parentbdc8d89e6b8f49528b716d9bd3343a4f9e9327bd (diff)
downloadqmk_firmware-da995d2aeace38cd548c77f341920fab49501ded.tar.gz
qmk_firmware-da995d2aeace38cd548c77f341920fab49501ded.zip
[Docs] Add examples to debugging docs (#5555)
* Add examples to debugging docs * Add examples to debugging docs - review comments * Update matrix keypress example to use uprintf
-rw-r--r--docs/newbs_testing_debugging.md60
1 files changed, 58 insertions, 2 deletions
diff --git a/docs/newbs_testing_debugging.md b/docs/newbs_testing_debugging.md
index d78311339..771846b40 100644
--- a/docs/newbs_testing_debugging.md
+++ b/docs/newbs_testing_debugging.md
@@ -13,9 +13,9 @@ Note: These programs are not provided by or endorsed by QMK.
13* [Keyboard Tester](http://www.keyboardtester.com) (Web Based) 13* [Keyboard Tester](http://www.keyboardtester.com) (Web Based)
14* [Keyboard Checker](http://keyboardchecker.com) (Web Based) 14* [Keyboard Checker](http://keyboardchecker.com) (Web Based)
15 15
16## Debugging With QMK Toolbox 16## Debugging
17 17
18[QMK Toolbox](https://github.com/qmk/qmk_toolbox) will show messages from your keyboard if you have `CONSOLE_ENABLE = yes` in your `rules.mk`. By default the output is very limited, but you can turn on debug mode to increase the amount of debug output. Use the `DEBUG` keycode in your keymap, use the [Command](feature_command.md) feature to enable debug mode, or add the following code to your keymap. 18Your keyboard will output debug information if you have `CONSOLE_ENABLE = yes` in your `rules.mk`. By default the output is very limited, but you can turn on debug mode to increase the amount of debug output. Use the `DEBUG` keycode in your keymap, use the [Command](feature_command.md) feature to enable debug mode, or add the following code to your keymap.
19 19
20```c 20```c
21void keyboard_post_init_user(void) { 21void keyboard_post_init_user(void) {
@@ -27,6 +27,14 @@ void keyboard_post_init_user(void) {
27} 27}
28``` 28```
29 29
30### Debugging With QMK Toolbox
31
32For compatible platforms, [QMK Toolbox](https://github.com/qmk/qmk_toolbox) can be used to display debug messages from your keyboard.
33
34### Debugging With hid_listen
35
36Prefer a terminal based solution? [hid_listen](https://www.pjrc.com/teensy/hid_listen.html), provided by PJRC, can also be used to display debug messages. Prebuilt binaries for Windows,Linux,and MacOS are available.
37
30<!-- FIXME: Describe the debugging messages here. --> 38<!-- FIXME: Describe the debugging messages here. -->
31 39
32## Sending Your Own Debug Messages 40## Sending Your Own Debug Messages
@@ -41,3 +49,51 @@ After that you can use a few different print functions:
41* `uprintf("%s string", var)`: Print a formatted string 49* `uprintf("%s string", var)`: Print a formatted string
42* `dprint("string")` Print a simple string, but only when debug mode is enabled 50* `dprint("string")` Print a simple string, but only when debug mode is enabled
43* `dprintf("%s string", var)`: Print a formatted string, but only when debug mode is enabled 51* `dprintf("%s string", var)`: Print a formatted string, but only when debug mode is enabled
52
53## Debug Examples
54
55Below is a collection of real world debugging examples. For additional information, refer to [Debugging/Troubleshooting QMK](faq_debug.md).
56
57### Which matrix position is this keypress?
58
59When porting, or when attempting to diagnose pcb issues, it can be useful to know if a keypress is scanned correctly. To enable logging for this scenario, add the following code to your keymaps `keymap.c`
60
61```c
62bool process_record_user(uint16_t keycode, keyrecord_t *record) {
63 // If console is enabled, it will print the matrix position and status of each key pressed
64#ifdef CONSOLE_ENABLE
65 uprintf("KL: kc: %u, col: %u, row: %u, pressed: %u\n", keycode, record->event.key.col, record->event.key.row, record->event.pressed);
66#endif
67 return true;
68}
69```
70
71Example output
72```text
73Waiting for device:.......
74Listening:
75KL: kc: 169, col: 0, row: 0, pressed: 1
76KL: kc: 169, col: 0, row: 0, pressed: 0
77KL: kc: 174, col: 1, row: 0, pressed: 1
78KL: kc: 174, col: 1, row: 0, pressed: 0
79KL: kc: 172, col: 2, row: 0, pressed: 1
80KL: kc: 172, col: 2, row: 0, pressed: 0
81```
82
83### How long did it take to scan for a keypress?
84
85When testing performance issues, it can be useful to know the frequency at which the switch matrix is being scanned. To enable logging for this scenario, add the following code to your keymaps `config.h`
86
87```c
88#define DEBUG_MATRIX_SCAN_RATE
89```
90
91Example output
92```text
93 > matrix scan frequency: 315
94 > matrix scan frequency: 313
95 > matrix scan frequency: 316
96 > matrix scan frequency: 316
97 > matrix scan frequency: 316
98 > matrix scan frequency: 316
99```