Browse Source

Add tap_random_base64 and software timer info to Useful Functions doc (#4360)

* Update docs

* Add security caveat

Co-Authored-By: drashna <drashna@live.com>

* Wordsmithing

Co-Authored-By: drashna <drashna@live.com>

* Update docs/ref_functions.md

Co-Authored-By: drashna <drashna@live.com>
pjones-keymap
Drashna Jaelre 7 months ago
parent
commit
75a51659ab
2 changed files with 21 additions and 17 deletions
  1. 0
    17
      docs/faq_keymap.md
  2. 21
    0
      docs/ref_functions.md

+ 0
- 17
docs/faq_keymap.md View File

@@ -211,20 +211,3 @@ here real_mods lost state for 'physical left shift'.
211 211
 
212 212
 weak_mods is ORed with real_mods when keyboard report is sent.
213 213
 https://github.com/tmk/tmk_core/blob/master/common/action_util.c#L57
214
-
215
-## Timer Functionality
216
-
217
-It's possible to start timers and read values for time-specific events - here's an example:
218
-
219
-```c
220
-static uint16_t key_timer;
221
-key_timer = timer_read();
222
-
223
-if (timer_elapsed(key_timer) < 100) {
224
-  // do something if less than 100ms have passed
225
-} else {
226
-  // do something if 100ms or more have passed
227
-}
228
-```
229
-
230
-It's best to declare the `static uint16_t key_timer;` at the top of the file, outside of any code blocks you're using it in.

+ 21
- 0
docs/ref_functions.md View File

@@ -96,3 +96,24 @@ And to do so, add `reset_keyboard()` to your function or macro, and this will re
96 96
 If you're having issues with Audio, RGB Underglow, backlighting or keys acting weird, then you can reset the EEPROM (persistent setting storage).  Bootmagic is one way to do this, but if that isn't enabled, then you can use a custom macro to do so.
97 97
 
98 98
 To wipe the EEPROM, run `eeconfig_init()` from your function or macro to reset most of the settings to default.
99
+
100
+## Tap random key
101
+
102
+If you want to send a random character to the host computer, you can use the `tap_random_base64()` function. This [pseudorandomly](https://en.wikipedia.org/wiki/Pseudorandom_number_generator) selects a number between 0 and 63, and then sends a key press based on that selection. (0–25 is `A`–`Z`, 26–51 is `a`–`z`, 52–61 is `0`–`9`, 62 is `+` and 63 is `/`).  
103
+
104
+?> Needless to say, but this is _not_ a cryptographically secure method of generating random Base64 keys or passwords.
105
+
106
+## Software Timers
107
+
108
+It's possible to start timers and read values for time-specific events. Here's an example:
109
+
110
+```c
111
+static uint16_t key_timer;
112
+key_timer = timer_read();
113
+
114
+if (timer_elapsed(key_timer) < 100) {
115
+  // do something if less than 100ms have passed
116
+} else {
117
+  // do something if 100ms or more have passed
118
+}
119
+```

Loading…
Cancel
Save