Local buffer array for SSD1306 reasonable?

Dear Arduino community,

I bought some cheap SSD1306 Oleds on eBay and got them working via i2c with a different library than the one from Adafruit (because ACK?!). I would like to refactor and rewrite this whole library because of usage and functionality.

This library does not use a buffer char array with 8192 bits and writes directly to the SSD1306 buffer as opposed to the adafruit library.

So my questions are: 1. Is it reasonable to use a local char buffer array and display the content after any modifications where done via a display() method in terms of memory usage, framerate and overall code efficiency?

  1. If my calculations are correct: the local buffer would use 1024 byte which is allready 50% of the ATMega328 SRAM?! This does not leave plenty of room for other stuff right?

  2. I would really like to implement some sort of GUI library with buttons and views which are animatable: would a local buffer help me to do so (animating eg. the whole content of the screen from left to right etc.)?

Thanks in advance!

Hi

U8glib addresses the problem of not having enough RAM. U8glib requires only 128 Bytes for the graphics buffer + some extra data for the library. U8glib also supports those OLEDs, which do not send a proper ACK. See the special option for U8glib with I2C:

U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NO_ACK);

There is also a GUI library available, which i created some time back: M2tklib. M2tklib is available for U8glib and both libs will work together.

Links: https://code.google.com/p/u8glib/ https://code.google.com/p/m2tklib/

Oliver

I did some 3d on the display as you can see here: http://oskit.se/3d-rendering-on-arduino/

I only have whole buffer for the text just so I can do printf to it directly (21x8 chars buffer). For the 3d I transfer data in 64 byte chunks. My i2c driver handles everything in the background through interrupts.

You only need to keep as much data as necessary in memory on any given time. For example, characters can be stored in program memory and transfered in chunks of 6 bytes to the display as you iterate through the text buffer and pick the right graphical characters to transfer (which you store in program memory). For speed, I suggest doing asynchronous transfers because that way you can do other things while i2c hardware is writing data to the display.

For an implementation in C for how to do async transfers, you can have a look at my ssd1306 library which you can find as part of my kernel project here: https://github.com/mkschreder/fortmax-blocks/blob/master/kernel/src/ssd1306.c