diff options
author | Ted M Lin <tedmlin@gmail.com> | 2020-03-02 18:43:18 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-03 10:43:18 +1100 |
commit | 552f8d81b9bff8010b328ee944d50830cfcaea5c (patch) | |
tree | 645321809be268907d4676759bb10c7eff4e4400 /quantum/keymap_extras/sendstring_turkish_q.h | |
parent | abd36de5adbb484695d3500ad790df557d4f5419 (diff) | |
download | qmk_firmware-552f8d81b9bff8010b328ee944d50830cfcaea5c.tar.gz qmk_firmware-552f8d81b9bff8010b328ee944d50830cfcaea5c.zip |
Reduce PROGMEM usage for sendstring LUT (#8109)
* Reduce PROGMEM usage for keycode map
Bit-pack the keycode bool array to gain back a small amount of flash space.
The trade-off is an increase in runtime instructions when running macros.
It does make the code a bit harder to read, as well as maintain.
For configs that use send_string() et al, it saves ~100 bytes.
* Switch to macro and common definition
Rewrite the array declarations so both the unpacked (original) and
packed LUT arrays can use the same value definitions. This is done by
defining a macro that "knows what to do".
This makes the code much easier to read and maintain.
* Fix macro typos and improve perf
Pack the bits in a more efficient order for extraction.
And also fix the copy/paste error in the macro...
* Switch fully to packed LUT
Some minor reformatting.
Compile tested all sendstring_xyz.h to make sure they were converted
properly. Also checked that an unconverted version would generate a
compile error.
* Apply whitespace suggestions from code review
Co-Authored-By: Ryan <fauxpark@gmail.com>
Co-authored-by: Ryan <fauxpark@gmail.com>
Diffstat (limited to 'quantum/keymap_extras/sendstring_turkish_q.h')
-rw-r--r-- | quantum/keymap_extras/sendstring_turkish_q.h | 69 |
1 files changed, 35 insertions, 34 deletions
diff --git a/quantum/keymap_extras/sendstring_turkish_q.h b/quantum/keymap_extras/sendstring_turkish_q.h index 58505b849..97c990c12 100644 --- a/quantum/keymap_extras/sendstring_turkish_q.h +++ b/quantum/keymap_extras/sendstring_turkish_q.h | |||
@@ -19,47 +19,48 @@ | |||
19 | #pragma once | 19 | #pragma once |
20 | 20 | ||
21 | #include "keymap_turkish_q.h" | 21 | #include "keymap_turkish_q.h" |
22 | #include "quantum.h" | ||
22 | 23 | ||
23 | // clang-format off | 24 | // clang-format off |
24 | 25 | ||
25 | const bool ascii_to_shift_lut[128] PROGMEM = { | 26 | const uint8_t ascii_to_shift_lut[16] PROGMEM = { |
26 | 0, 0, 0, 0, 0, 0, 0, 0, | 27 | KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0), |
27 | 0, 0, 0, 0, 0, 0, 0, 0, | 28 | KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0), |
28 | 0, 0, 0, 0, 0, 0, 0, 0, | 29 | KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0), |
29 | 0, 0, 0, 0, 0, 0, 0, 0, | 30 | KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0), |
30 | 31 | ||
31 | 0, 1, 0, 0, 0, 1, 1, 1, | 32 | KCLUT_ENTRY(0, 1, 0, 0, 0, 1, 1, 1), |
32 | 1, 1, 0, 1, 0, 0, 0, 1, | 33 | KCLUT_ENTRY(1, 1, 0, 1, 0, 0, 0, 1), |
33 | 0, 0, 0, 0, 0, 0, 0, 0, | 34 | KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0), |
34 | 0, 0, 1, 1, 0, 1, 1, 1, | 35 | KCLUT_ENTRY(0, 0, 1, 1, 0, 1, 1, 1), |
35 | 0, 1, 1, 1, 1, 1, 1, 1, | 36 | KCLUT_ENTRY(0, 1, 1, 1, 1, 1, 1, 1), |
36 | 1, 1, 1, 1, 1, 1, 1, 1, | 37 | KCLUT_ENTRY(1, 1, 1, 1, 1, 1, 1, 1), |
37 | 1, 1, 1, 1, 1, 1, 1, 1, | 38 | KCLUT_ENTRY(1, 1, 1, 1, 1, 1, 1, 1), |
38 | 1, 1, 1, 0, 0, 0, 1, 1, | 39 | KCLUT_ENTRY(1, 1, 1, 0, 0, 0, 1, 1), |
39 | 0, 0, 0, 0, 0, 0, 0, 0, | 40 | KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0), |
40 | 0, 0, 0, 0, 0, 0, 0, 0, | 41 | KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0), |
41 | 0, 0, 0, 0, 0, 0, 0, 0, | 42 | KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0), |
42 | 0, 0, 0, 0, 0, 0, 0, 0 | 43 | KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0), |
43 | }; | 44 | }; |
44 | 45 | ||
45 | const bool ascii_to_altgr_lut[128] PROGMEM = { | 46 | const uint8_t ascii_to_altgr_lut[16] PROGMEM = { |
46 | 0, 0, 0, 0, 0, 0, 0, 0, | 47 | KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0), |
47 | 0, 0, 0, 0, 0, 0, 0, 0, | 48 | KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0), |
48 | 0, 0, 0, 0, 0, 0, 0, 0, | 49 | KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0), |
49 | 0, 0, 0, 0, 0, 0, 0, 0, | 50 | KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0), |
50 | 51 | ||
51 | 0, 0, 0, 1, 1, 0, 0, 0, | 52 | KCLUT_ENTRY(0, 0, 0, 1, 1, 0, 0, 0), |
52 | 0, 0, 0, 0, 0, 0, 0, 0, | 53 | KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0), |
53 | 0, 0, 0, 0, 0, 0, 0, 0, | 54 | KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0), |
54 | 0, 0, 0, 0, 0, 0, 0, 0, | 55 | KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0), |
55 | 1, 0, 0, 0, 0, 0, 0, 0, | 56 | KCLUT_ENTRY(1, 0, 0, 0, 0, 0, 0, 0), |
56 | 0, 0, 0, 0, 0, 0, 0, 0, | 57 | KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0), |
57 | 0, 0, 0, 0, 0, 0, 0, 0, | 58 | KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0), |
58 | 0, 0, 0, 1, 1, 1, 0, 0, | 59 | KCLUT_ENTRY(0, 0, 0, 1, 1, 1, 0, 0), |
59 | 1, 0, 0, 0, 0, 0, 0, 0, | 60 | KCLUT_ENTRY(1, 0, 0, 0, 0, 0, 0, 0), |
60 | 0, 0, 0, 0, 0, 0, 0, 0, | 61 | KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0), |
61 | 0, 0, 0, 0, 0, 0, 0, 0, | 62 | KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0), |
62 | 0, 0, 0, 1, 1, 1, 1, 0 | 63 | KCLUT_ENTRY(0, 0, 0, 1, 1, 1, 1, 0), |
63 | }; | 64 | }; |
64 | 65 | ||
65 | const uint8_t ascii_to_keycode_lut[128] PROGMEM = { | 66 | const uint8_t ascii_to_keycode_lut[128] PROGMEM = { |