Close

Implementing vertical scrolling effect with SSD1322 controller

A project log for ESP8266 Twitter Client

ESP8266 Twitter client with OLED display

Andrei MehiläinenAndrei Mehiläinen 06/11/2017 at 11:420 Comments

Please make sure to watch the video demonstrating the functionality of the device and check out the following source code files in order to understand better the description below:

The SSD1322 controller has enough memory to keep two copies of 256x64 pixel frame buffer. Only one of those copies is shown on the display at a time. The second copy sits in the memory just below or above the page being shown. There’s a Set Start Line command, which defines the line (in memory) from which the controller starts to render the content of the memory. When the start line is incremented, the content on the display appears to be scrolling upwards. In the GIF animation below the white area represents the controller memory and the gray area represents the content rendered on the display:

So, when a new tweet is to be shown, the following happens:

  1. Draw the tweet into the frame buffer (in ESP8266 memory).
  2. Send frame buffer to SSD1322 controller, into the memory location which is currently not being displayed.
  3. Start the timer. Each time the timer is triggered, use Set Start Line command to increment the start line.
  4. Disable the timer when all 64 lines are scrolled. The new frame buffer is now fully displayed.

The Set Start Line command involves sending only two bytes on SPI bus to SSD1322 controller. This is of course very fast operation and doesn’t load ESP8266 much at all.

The scrolling effect looks a little bit nicer when its progression is not linear. I used the following Excel formula to pre-calculate timer intervals between each start line increment:

=POWER(2;10*((A1/62)-1))*40+1
The formula produces the following curve:

Pre-calculated interval values are stored in a lookup table. The table is accessed each time the timer is triggered and the new value is used to setup the next timer event. This results in a scrolling effect which slows down exponentially.

Discussions