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/quantum.h | |
parent | abd36de5adbb484695d3500ad790df557d4f5419 (diff) | |
download | firmware-552f8d81b9bff8010b328ee944d50830cfcaea5c.tar.gz firmware-552f8d81b9bff8010b328ee944d50830cfcaea5c.tar.bz2 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/quantum.h')
-rw-r--r-- | quantum/quantum.h | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/quantum/quantum.h b/quantum/quantum.h index 7dc14e628..d03ba5942 100644 --- a/quantum/quantum.h +++ b/quantum/quantum.h @@ -211,9 +211,21 @@ typedef ioline_t pin_t; #define SEND_STRING(string) send_string_P(PSTR(string)) #define SEND_STRING_DELAY(string, interval) send_string_with_delay_P(PSTR(string), interval) -extern const bool ascii_to_shift_lut[128]; -extern const bool ascii_to_altgr_lut[128]; +// Look-Up Tables (LUTs) to convert ASCII character to keycode sequence. extern const uint8_t ascii_to_keycode_lut[128]; +extern const uint8_t ascii_to_shift_lut[16]; +extern const uint8_t ascii_to_altgr_lut[16]; +// clang-format off +#define KCLUT_ENTRY(a, b, c, d, e, f, g, h) \ + ( ((a) ? 1 : 0) << 0 \ + | ((b) ? 1 : 0) << 1 \ + | ((c) ? 1 : 0) << 2 \ + | ((d) ? 1 : 0) << 3 \ + | ((e) ? 1 : 0) << 4 \ + | ((f) ? 1 : 0) << 5 \ + | ((g) ? 1 : 0) << 6 \ + | ((h) ? 1 : 0) << 7 ) +// clang-format on void send_string(const char *str); void send_string_with_delay(const char *str, uint8_t interval); |