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.<_e_1q6o >To find out how Shox96 works, read this article.
First, the strings that need to compressed should to be listed in a file (usually with.txt extension).<_e_1q6o >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>
./shox96 G <text_file> <output_header_name>
The command with capital G provides more compression taking into account repeating texts across the file.<_e_1q6o >For example, if we use the file
proverbs.txtgiven in the repository and the run command
./shox96 g proverbs.txt proverbs, a file by name
proverbs.hwill be generated. This file can be copied alongside any
.inofile and included. Then the
shox96_progmem_0_2.hin this library can be called to uncompress the strings.
Please try the examples provided along with this library to see how it works.
This 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.
Original html size: 65540 bytes
Compressed size: 22973 bytes
Savings: 64.95%This example demonstrates de-compression of Error messages. Source:
Original size: 2122 bytes
Compressed size: 1212 bytes
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%<_e_1q6o >