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:
- Draw the tweet into the frame buffer (in ESP8266 memory).
- Send frame buffer to SSD1322 controller, into the memory location which is currently not being displayed.
- Start the timer. Each time the timer is triggered, use Set Start Line command to increment the start line.
- 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+1The 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.