1. mrdude

    OP mrdude GBAtemp Maniac
    Member

    Joined:
    Dec 11, 2015
    Messages:
    1,069
    Country:
    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?
     
    peteruk and BigOnYa like this.
  2. thesjaakspoiler

    thesjaakspoiler GBAtemp Regular
    Member

    Joined:
    Nov 20, 2018
    Messages:
    252
    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.
     
    mrdude likes this.
  3. mrdude

    OP mrdude GBAtemp Maniac
    Member

    Joined:
    Dec 11, 2015
    Messages:
    1,069
    Country:
    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.
     
    peteruk likes this.
  4. mrdude

    OP mrdude GBAtemp Maniac
    Member

    Joined:
    Dec 11, 2015
    Messages:
    1,069
    Country:
    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.
     

    Attached Files:

    peteruk likes this.
Draft saved Draft deleted
Loading...

Hide similar threads Similar threads with keywords - compression, Payload,