Hacking Payload compression?

mrdude

Developer
OP
Developer
Joined
Dec 11, 2015
Messages
3,076
Trophies
1
Age
56
XP
8,193
Due to the size of certain payloads and putting multiple payloads on the same trinket m0 - we could do with being able to compress them to fit on the trinket flash memory - and decompress them on the fly when sending to the switch as a payload.

I came across this - https://github.com/atomicobject/heatshrink, which seems like it should be able to do that, has anyone tried and succeeded using any other types of compression and if so can you share your code?
 
  • Like
Reactions: peteruk and BigOnYa

thesjaakspoiler

Well-Known Member
Member
Joined
Nov 20, 2018
Messages
935
Trophies
0
Age
124
XP
1,443
Country
Afghanistan
Nice idea!
For the Arduino there are also compression libraries.
https://github.com/siara-cc/Unishox_Arduino_Progmem_lib
I tried compression a fusee payload with zip and it was reduced to about 60%.
Note that you also need to include the compression library itself, which will make the trinket code slightly bigger.
So I expect that you'll win about 30% per payload.
 
  • Like
Reactions: mrdude

mrdude

Developer
OP
Developer
Joined
Dec 11, 2015
Messages
3,076
Trophies
1
Age
56
XP
8,193
Nice idea!
For the Arduino there are also compression libraries.
https://github.com/siara-cc/Unishox_Arduino_Progmem_lib
I tried compression a fusee payload with zip and it was reduced to about 60%.
Note that you also need to include the compression library itself, which will make the trinket code slightly bigger.
So I expect that you'll win about 30% per payload.
That's just for strings, heatshrink can do binary data/bytes - so can compress better.

I found this:
https://github.com/p-v-o-s/Arduino-HScompression

It has an example ino file on how to use it for compression + decompression. The main goal is to make a compressor on the pc, compress the payload and convert to byte array (I know how to do this), then decompress that on the trinket and send as a decompressed payload.
 
  • Like
Reactions: peteruk

mrdude

Developer
OP
Developer
Joined
Dec 11, 2015
Messages
3,076
Trophies
1
Age
56
XP
8,193
I've attached a modded version of the Heat Shink compression program to show that it's indeed possible to put compressed payload data on a trinket and decompress it - you can check by using rx/tx/gnd pins on the trinket and use putty or arduino serial monitor to check input(payload) being compressed - then decompressed.

This could be adapted for those tight on space when using multiple payloads on the trinket - although it will have an impact on sending the payloads due to time required to decompress, maybe that would not a big deal if sending small chunks of data. I doubt it would be too hard to implement into current trinket software for sending payloads - although I didn't try this yet myself.
 

Attachments

  • HStest.zip
    15.2 KB · Views: 104
  • Like
Reactions: peteruk

Site & Scene News

Popular threads in this forum

Recent Content

General chit-chat
Help Users
  • No one is chatting at the moment.
    K3Nv2 @ K3Nv2: Sorry for accidentally bending over