Shox96 is a technique used for compressing and decompressing short strings. This library allows storing of compressed text strings in Arduino Program Memory and provides API to retrieve each string individually using index.
Shox96 can achieve upto 60% compression depending on the composition of text. This can be especially useful in constrained environments like Arduino Uno where only 32kb of Flash memory is available.
To find out how Shox96 works, read this article.
ApplicationsFirst, the strings that need to compressed should to be listed in a file (usually with.txt extension).
Download Shox96 and compile it using instructions provided in the repository. Then create compressed PROGMEM header using following command:<_e_1q6o>:./shox96 g <text_file> <output_header_name>
or
./shox96 G <text_file> <output_header_name>
The command with capital G provides more compression taking into account repeating texts across the file.
For example, if we use the file proverbs.txt
given in the repository and the run command ./shox96 g proverbs.txt proverbs
, a file by name proverbs.h
will be generated. This file can be copied alongside any .ino
file and included. Then the shox96_0_2_pgm_decompress()
API from shox96_progmem_0_2.h
in this library can be called to uncompress the strings.
Please try the examples provided along with this library to see how it works.
CompatibilityThis library can be used with Arduino Duemilanove, Uno upwards. It is useful only if saving by compressing text content is over 3000 bytes since the decompressor takes as much space.
LimitationsThe capital G parameter requires more memory allocated for decompression. Please see Html
example
This example demonstrates de-compression of Html content. Source of Html content is https://github.com/modularcode/modular-admin-html, which is released under MIT License.
Original html size: 65540 bytes
Compressed size: 22973 bytes
Savings: 64.95%
This example demonstrates de-compression of Error messages. Source: include/errno.h
of GCC.
Original size: 2122 bytes
Compressed size: 1212 bytes
Savings: 42.88%
The savings do not justify compression as the decompressor itself takes around 3500 bytes. This example has been given to show the use case.
This example demonstrates de-compression of compressed proverbs. Source: https://en.wikipedia.org/wiki/List_of_proverbial_phrases.
Original size : 25244 bytes
Compressed size: 14556 bytes
Savings: 42.34%
Comments
Please log in or sign up to comment.