I have a I2C 128x32 OLED Display (wide.hk) that I currently talk to with the amazing u8g Library.
I came to the point where I want to show way more graphics then my ATMega32u4 can hold in progmem. Because of this I tried to integrate an microSD card reader into my setup.
I can read files from the microSD card with the (also) amazing SDfat Library. But I have problem with handling this data.
It starts with the problem that every function in the two graphic library I tried (Adafruit_GFX, u8G) that are able to Display graphics in bulk (drawBitmap, drawXBM, etc.) wants to use PROGMEM (or U8G_PROGMEM). Also those variables are mostly defined as static. I see no way how I could pass Data on runtime to the Display if those functions nly except static progmem data.
Because of this I'm currently thinking about using binary files (010101) to show on-pixel and off-pixel. But walking down this road the last days seems exhausting and cant be right. Am I missing something?
Has anyone done something like this and could give me a hint?
If you want to just shift bitmaps from the SD to the display, then you have to adopt a 'bit at a time approach' - ie read some data from the SD, send it to the display, read a bit more, send it to the display until you have transferred the whole image.
The amount you can transfer at a time is dependent on the amount of RAM you have available - this will be much less than the amount of flash (progmem) you're likely to have.
I'm currently doing something similar for a ST7735 based display - I'm using the Adafruit GFX and ST7735 libraries but have extended the latter by adding in a handy function that will write image data in the display's native 65k colour format (2 bytes/pixel) directly from a buffer in RAM to the display. I've got enough free RAM to read one line of the image off the SD and then send to the display at a time.
I then added another function to my main program that takes the name of the file to load, the x & y of where to show the bitmap, and the width of the bitmap, as parameters and then then reads the file one line at a time into ram & then calls the library function to transfer this to the display.
Mh, I see what you mean. Space really is extremly tight on those chips.
I just tried said technique of reading binary files and printing them as single pixel of 1 and 0.
It is disappointing that the whole idea of loading XBM is just worth to display a lame splashscreen-image. One can only image how nice it would be to use it for dynamic data as well.
Ok. Thank you, I guess I have to go down that gravel road with my inline skater.
You can write directly to that display. If you have your bitmap stored on the SD card organized like the 1306 screen memory you could do something like this:
The ssd1306_command and _data functions are from the Adafruit library but you could cut and paste them into your sketch if you're using a different library.
Ideally the buffer would be 512 bytes but a smaller one would still work okay. I haven't tried this but I suspect it would be pretty fast if you're using hardware SPI.