Skip to content

Commit 8defb44

Browse files
siara-ccsiara-in
authored andcommitted
Fix API and Update Readme
1 parent 58678a1 commit 8defb44

File tree

12 files changed

+104
-389
lines changed

12 files changed

+104
-389
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright [yyyy] [name of copyright owner]
189+
Copyright 2019 Siara Logics (cc)
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

README.md

Lines changed: 69 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,69 @@
1-
# Shox96_Arduino_Progmem_lib
2-
Store and retrieve compressed data using Progmem for Arduino Uno and upwards
1+
# Compression and decompression Library for use with Arduino Flash Memory (PROGMEM)
2+
3+
[Shox96](https://github.com/siara-cc/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.
4+
5+
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.
6+
7+
## Applications
8+
9+
- Displaying descriptive error or warning messages
10+
- Storing text file content (such as html)
11+
- Transferring compressed content over low speed networks
12+
13+
## Usage
14+
15+
First, the strings that need to compressed should to be listed in a file (usually with .txt extension).
16+
17+
Download [Shox96](https://github.com/siara-cc/Shox96) and compile it using instructions provided in the repository. Then create compressed PROGMEM header using following command:
18+
19+
```
20+
./shox96 g <text_file> <output_header_name>
21+
```
22+
23+
or
24+
25+
```
26+
./shox96 G <text_file> <output_header_name>
27+
```
28+
29+
The command with capital G provides more compression taking into account repeating texts across the file.
30+
31+
For example, if we use the file `proverbs.txt` given in the repository and the command `./shox96 g proverbs.txt proverbs`, a file by name `proverbs.h` will be generated.
32+
33+
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.
34+
35+
Please try the examples provided along with this library to see how it works.
36+
37+
## Compatibility
38+
39+
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.
40+
41+
## Limitations
42+
43+
- Only text data (ASCII 32 to 126, 13, 10, 9) can be compressed using Shox96
44+
- The capital G parameter requires more memory allocated for decompression. Please see `Html` example
45+
- It is useful only if saving by compressing text content is over 3000 bytes since the decompressor takes as much space.
46+
47+
## Examples and screenshots
48+
49+
### Html
50+
51+
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.
52+
53+
![](ss_html.png?raw=true)
54+
55+
### Error Messages
56+
57+
This example demonstrates de-compression of Error messages. Source: `include/errno.h` of GCC.
58+
59+
![](ss_err_msgs.png?raw=true)
60+
61+
### Proverbs
62+
63+
This example demonstrates de-compression of compressed proverbs. Source: https://en.wikipedia.org/wiki/List_of_proverbial_phrases.
64+
65+
![](ss_proverbs.png?raw=true)
66+
67+
## Issues
68+
69+
If you face any problems, please create issue on GitHub.

examples/Compress_Short_Strings/Compress_Short_Strings.ino

Lines changed: 0 additions & 86 deletions
This file was deleted.

examples/Error_Messages/Error_Messages.ino

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@
1616
https://github.com/siara-cc/Shox96/blob/master/Shox96_Article_0_2_0.pdf?raw=true
1717
1818
Other projects using Shox96:
19+
Compression library for Arduino - https://github.com/siara-cc/Shox96_Arduino_lib
1920
As SQLite loadable extension - https://github.com/siara-cc/Shox96_Sqlite_UDF
2021
Sqlite3 Library for ESP32 - https://github.com/siara-cc/esp32_arduino_sqlite3_lib
2122
Sqlite3 Library for ESP8266 - https://github.com/siara-cc/esp_arduino_sqlite3_lib
2223
Sqlite3 Library for ESP-IDF - https://github.com/siara-cc/esp32-idf-sqlite3
2324
*/
24-
#include "shox96_0_2.h"
25+
#include "shox96_progmem_0_2.h"
2526
#include "errno.h"
2627

2728
void setup() {
@@ -32,7 +33,7 @@ void setup() {
3233
char out[100];
3334

3435
for (int i=0; i < errno0_2_line_count; i++) {
35-
int len = shox96_0_2_decompress(errno0_2, i, out, 0);
36+
int len = shox96_0_2_pgm_decompress(errno0_2, i, out, 0);
3637
out[len] = 0;
3738
Serial.write(out);
3839
Serial.write("\n");

examples/Html/Html.ino

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@
1414
https://github.com/siara-cc/Shox96/blob/master/Shox96_Article_0_2_0.pdf?raw=true
1515
1616
Other projects using Shox96:
17+
Compression library for Arduino - https://github.com/siara-cc/Shox96_Arduino_lib
1718
As SQLite loadable extension - https://github.com/siara-cc/Shox96_Sqlite_UDF
1819
Sqlite3 Library for ESP32 - https://github.com/siara-cc/esp32_arduino_sqlite3_lib
1920
Sqlite3 Library for ESP8266 - https://github.com/siara-cc/esp_arduino_sqlite3_lib
2021
Sqlite3 Library for ESP-IDF - https://github.com/siara-cc/esp32-idf-sqlite3
2122
*/
22-
#include "shox96_0_2.h"
23+
#include "shox96_progmem_0_2.h"
2324
#include "Html.h"
2425

2526
void setup() {
@@ -34,7 +35,7 @@ void setup() {
3435
char out[1000];
3536

3637
for (int i=0; i < html0_2_line_count; i++) {
37-
int len = shox96_0_2_decompress(html0_2, i, out, 0);
38+
int len = shox96_0_2_pgm_decompress(html0_2, i, out, 0);
3839
out[len] = 0;
3940
Serial.write(out);
4041
Serial.write("\n");

examples/Proverbs/Proverbs.ino

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@
1313
https://github.com/siara-cc/Shox96/blob/master/Shox96_Article_0_2_0.pdf?raw=true
1414
1515
Other projects using Shox96:
16+
Compression library for Arduino - https://github.com/siara-cc/Shox96_Arduino_lib
1617
As SQLite loadable extension - https://github.com/siara-cc/Shox96_Sqlite_UDF
1718
Sqlite3 Library for ESP32 - https://github.com/siara-cc/esp32_arduino_sqlite3_lib
1819
Sqlite3 Library for ESP8266 - https://github.com/siara-cc/esp_arduino_sqlite3_lib
1920
Sqlite3 Library for ESP-IDF - https://github.com/siara-cc/esp32-idf-sqlite3
2021
*/
21-
#include "shox96_0_2.h"
22+
#include "shox96_progmem_0_2.h"
2223
#include "Proverbs.h"
2324

2425
void setup() {
@@ -52,15 +53,15 @@ void loop() {
5253
}
5354
}
5455

55-
if (ch == 1) {
56+
if (ch == '1') {
5657
for (int i=0; i < Proverbs0_2_line_count; i++) {
57-
int len = shox96_0_2_decompress(Proverbs0_2, i, out, 0);
58+
int len = shox96_0_2_pgm_decompress(Proverbs0_2, i, out, 0);
5859
out[len] = 0;
5960
Serial.write(out);
6061
Serial.write("\n");
6162
}
62-
} else if (ch == 2) {
63-
int len = shox96_0_2_decompress(Proverbs0_2, random(0, Proverbs0_2_line_count - 1), out, 0);
63+
} else if (ch == '2') {
64+
int len = shox96_0_2_pgm_decompress(Proverbs0_2, random(0, Proverbs0_2_line_count - 1), out, 0);
6465
out[len] = 0;
6566
Serial.write(out);
6667
Serial.write("\n\n");

library.properties

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
name=Shox96
2-
version=0.2
1+
name=Shox96 Promem
2+
version=1.0
33
author=Arundale Ramanathan
44
maintainer=Arun <arun@siara.cc>
5-
sentence=Shox96 Compression library for Arduino UNO and up
6-
paragraph=Compress short strings and messages and save upto 60% space on RAM or PROGMEM
5+
sentence=Compress short strings and messages and save space on Flash (PROGMEM)
6+
paragraph=This library allows storing of compressed text strings in Arduino Program Memory and provides API to retrieve each string individually using index.
77
category=Data Storage
8-
url=https://github.com/siara-cc/Shox96_Arduino_lib
8+
url=https://github.com/siara-cc/Shox96_Arduino_Progmem_lib
99
architectures=*

0 commit comments

Comments
 (0)