summaryrefslogtreecommitdiff
path: root/quantum/send_string.c
diff options
context:
space:
mode:
authorQMK Bot <hello@qmk.fm>2021-03-12 07:04:21 +0000
committerQMK Bot <hello@qmk.fm>2021-03-12 07:04:21 +0000
commit71f8f5048b0c583893e26b7a419f40de58c11891 (patch)
tree411fe6f77f735e72365200d1dec03451051b5e1e /quantum/send_string.c
parent183c49f3522e948c541ee0cc63997f438994c534 (diff)
parent88dce243750d9e80948cd7262566182018d7bbdf (diff)
Merge remote-tracking branch 'origin/master' into develop
Diffstat (limited to 'quantum/send_string.c')
-rw-r--r--quantum/send_string.c56
1 files changed, 55 insertions, 1 deletions
diff --git a/quantum/send_string.c b/quantum/send_string.c
index 0e8902ca3f..7d096b4273 100644
--- a/quantum/send_string.c
+++ b/quantum/send_string.c
@@ -249,4 +249,58 @@ void send_char(char ascii_code) {
if (is_dead) {
tap_code(KC_SPACE);
}
-} \ No newline at end of file
+}
+
+void send_dword(uint32_t number) {
+ send_word(number >> 16);
+ send_word(number & 0xFFFFUL);
+}
+
+void send_word(uint16_t number) {
+ send_byte(number >> 8);
+ send_byte(number & 0xFF);
+}
+
+void send_byte(uint8_t number) {
+ send_nibble(number >> 4);
+ send_nibble(number & 0xF);
+}
+
+void send_nibble(uint8_t number) {
+ switch (number & 0xF) {
+ case 0 ... 9:
+ send_char(number + '0');
+ break;
+ case 10 ... 15:
+ send_char(number - 10 + 'a');
+ break;
+ }
+}
+
+void tap_random_base64(void) {
+#if defined(__AVR_ATmega32U4__)
+ uint8_t key = (TCNT0 + TCNT1 + TCNT3 + TCNT4) % 64;
+#else
+ uint8_t key = rand() % 64;
+#endif
+ switch (key) {
+ case 0 ... 25:
+ send_char(key + 'A');
+ break;
+ case 26 ... 51:
+ send_char(key - 26 + 'a');
+ break;
+ case 52:
+ send_char('0');
+ break;
+ case 53 ... 61:
+ send_char(key - 53 + '1');
+ break;
+ case 62:
+ send_char('+');
+ break;
+ case 63:
+ send_char('/');
+ break;
+ }
+}