Gerty Part 2 – OLED Test

<< Part 1

The OLED display uses a serial interface (SPI) to the microcontroller, which basically means all the data is send along one wire, one byte at a time (with a couple more wires to control the flow of the data). This makes connections very simple, but this comes at the expense of speed of communication. The software library that was supplied with the display wraps up the control of the data lines so that it is also easy to send commands such as draw line or show bitmap without having to worry about how the data is actually sent between the MCU and the display.

Displaying a full screen 96×64 bitmap took nearly a second, and the image could be seen appearing down the screen. When Gerty is in his unhappy/concerned mood, the image alternates between two views, one looking left, one looking right. I wanted to be able to reproduce this on my version, but that was going to be impossible at that speed.

The display library code library is generic and flexible, but controls all of the actual data transfer itself. The Atmel MCU supports a “hardware” SPI mode which allows the MCU to take over the data transfer at a very low level and is about 5 times faster that doing it via software. It was relatively straightforward to modify the display library to use the hardware SPI mode which gave an immediate improvement to the speed the screen is drawn.

The MCU does not have much RAM (2k) and a single full screen image is 12,288 bytes in size (6144 pixels with 2 bytes of colour data per pixel). The MCU does have much more flash memory (32k) and the display library expects any bitmaps to be displayed to have been saved into the flash memory when the MCU is initially programmed. I wanted to be able to load an image on demand from the SD card and then display it, so another modification to the library was required. An additional function was added that would display a single pixel high bitmap from data held in RAM. It then became a case of loading each line of the bitmap from the SD, sending it to the display and then moving down to the next line, until all the bitmap had been transferred.

The end result of these modifications was the ability to show any image on the SD card on demand, almost instantaneously.

Part 3 >>

Leave a Reply

Your email address will not be published. Required fields are marked *