Skip to content

Conversation

@mcendu
Copy link

@mcendu mcendu commented Jan 16, 2025

This patchset stores character mappings in PROGMEM, which explicitly instructs the compiler to not load them into RAM at program startup. In turn, these mappings require special macros from <avr/pgmspace.h> to read. This reduces the RAM overhead of this library to a minimum. For portability, <avr/pgmspace.h> is indirectly included via the Arduino core's main header, <Arduino.h>, which provides the macros as no-ops on non-AVR platforms.

To counteract the slower speed of loading from ROM (LPM takes 3 cycles on Uno, while LD takes 2), The character tables are sorted by code point in ascending order, and bsearch() is used for lookup.

mcendu added 26 commits January 15, 2025 10:01
This allows sketches to successfully link when this library is included in multiple files.
Arduino Uno has only a feeble 2 kilobytes of RAM. As data are put into
RAM by default on AVR, the conversion tables will easily eat up all the
precious RAM space.

Declaring the tables PGMSPACE should solve the RAM usage and make it
compatible with AVR again.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant