tomjuggler / SmartPoiOffline

ESP8266 APA102 POV poi example code
3 stars 3 forks source link

store images in progmem? #2

Open 5ch4um1 opened 3 years ago

5ch4um1 commented 3 years ago

I really like the simplicity of this sketch, but space is rather limited, what would you think about adding an examples folder or something like that, and put a version there that stores the images in program memory? the modifications was basically just 3 lines:

include <avr/pgmspace.h>

const uint8_t PROGMEM message1Data[] =

X = pgm_read_dword (&(message1Data[counter++]));

and this seems to work, not sure if this is the correct way to do this though? But it can store a lot bigger images now on those arduino nano clones... And as i said, i tried some of the patterns from the fastled examples, and to be honest, some of them look pretty great as poi and there is space for a lot of them... :) image image

tomjuggler commented 3 years ago

Hi, this particular sketch is for learning purposes. I have pasted some more advanced SmartPoiNano code I used in actual performance for you to check out here: sketch1 and here: sketch2 I have not been developing the Arduino nano version of my poi since 2017 so I hope the code still works. At least you will get an idea of how I used PROGMEM, EEPRom switch, timers, and FastLED palettes to make the patterns more interesting, including putting letters together into words. I highly recommend checking out the more recent versions of SmartPoi, the ESP-01 or D1 Mini cost the same as Nano, but can fit 100 images or more on, in a "real" file system accessible via WiFi!

tomjuggler commented 3 years ago

Sorry those examples were for Arduino version 1.0.6 and don't compile anymore! I don't have time to update them I'm afraid

5ch4um1 commented 3 years ago

ah, no worries, and thank you, looks really interesting! i thought about an alphabet too... mine would need to be 16 px high though... xD one basic thing i'd like to understand next would be how to read one line from a 16 byte array, and save it to another 32 byte array, like, the original and it's mirrored version, and read the X from there, since my leds are "back to back", that would mean 2x the space, and my image editing skills are not the best either, would make things a lot simpler, i guess that's what i'll try next. and yeah, it totally serves that purpose, already learned a lot by adapting it to the ws2812 leds :)
to understand the difference, does your code actually read each byte 3 times? i tried X = pgm_read_byte, but this didn't work, pgm_read_dword did work, so i'm happy with that for now i guess. would be nice to understand what is happening some day though... xD

tomjuggler commented 3 years ago

Please don't make a mirror image - my LED's are back to back, and I send the same image to both strips (just wire up the data line to the same pin)

I started with WS2811/12 myself, so I know they do work, just not as nicely as the APA102.

As for the bytes. You are close, the code is extracting RGB information from each byte. I have compressed each pixel into one byte. a byte is 8 bits, so the first two are for R, the 2nd two are for G, and the last 3 are for B. Sorry, I really forgot, compressing is a big part of the code here, it's what enabled me to put so many images in a Nano's tiny memory.

I am afraid that the Processing code I made years ago to generate the compressed images is even more of a mess than the Arduino code here. I could dig up the program if you think it might help, but it might just raise more questions.. I really was still learning at that point, and did just enough to get by!