Project tutorial
Compression Library for Use with Arduino Flash (PROGMEM)

Compression Library for Use with Arduino Flash (PROGMEM) © Apache-2.0

Achieve up to 60% saving on program memory space using Shox96 Guaranteed Text Compression Library for Arduino Uno and upwards.

  • 1,170 views
  • 1 comment
  • 5 respects

Components and supplies

A000066 iso both
Arduino UNO & Genuino UNO
This project works on Arduino Uno/Duemilanove upwards
×1

About this project

<_e_1q6o >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.

<_e_1q6o >To find out how Shox96 works, read this article.

Applications

<_e_1q6o >
  • Displaying descriptive error or warning messages
  • <_e_1q6o >
  • Storing text file content (such as html)
  • <_e_1q6o >
  • Transferring compressed content over low speed networks
  • Usage

    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>

    or

    <_e_1q6o >./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.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.

    Compatibility

    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.

    Limitations

    <_e_1q6o >
  • Only text data (ASCII 32 to 126, 13, 10, 9) can be compressed using Shox96
  • <_e_1q6o ><_e_1q6o >The capital G parameter requires more memory allocated for decompression. Please see Html example<_e_1q6o >
  • It is useful only if saving by compressing text content is over 3000 bytes since the decompressor takes as much space.
  • Examples and screenshots

    Html

    <_e_1q6o >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%

    Error Messages

    <_e_1q6o >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.

    Proverbs

    <_e_1q6o >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 >

    Code

    Compression Library for use with Arduino Flash Memory
    Please read the documentation to find out how to use this library. Or download the library and check out the examples.

    Comments

    Similar projects you might like

    RGB LED Fading Arduino Library

    Project in progress by tinkersprojects

    • 3,661 views
    • 1 comment
    • 5 respects

    How to Use ServoTimer2 Library (Simple Explain) Servo Sweep

    Project tutorial by ashraf_minhaj

    • 9,369 views
    • 6 comments
    • 12 respects

    G-Code Arduino Library

    Project in progress by tinkersprojects

    • 9,780 views
    • 2 comments
    • 15 respects

    LoRa E32 Device for Arduino, ESP32 or ESP8266: Library

    Project tutorial by Renzo Mischianti

    • 3,901 views
    • 2 comments
    • 20 respects

    Arduino RFID Flash Cards (Matching Game)

    Project tutorial by RobotGeek Projects Team

    • 1,432 views
    • 0 comments
    • 4 respects

    Torch LED Library

    Project in progress by tinkersprojects

    • 1,014 views
    • 0 comments
    • 2 respects
    Add projectSign up / Login