Adafruit Oled: Scroll a list of text


I’m using the Adafruit_SSD1306 library and the SPI version to drive Adafruit’s 128x64 Oled display.

My plan is to scroll smoothly vertically through the list of items of an text array. The scroll direction and step should be controlled by a button or an encoder.
Guy Carpenter is doing this in his python (library) very nicely. Unfortunately I’m not capable to “translate” this into C++.

Does anyone has a hint into the right direction, how to do this? I’m not seeking for the complete code here, but more a guidance, as I want to understand it myself.
Guy’s library supports additionally something like panning, which is not necessary for my plans. But it would be awesome though.

Thanks in advance.


It’s pretty easy to do. If you’re drawing from an array of lines for example, you probably have a variable for the top line, so starting at the loop using display.drawString(0, y, line[top+index]) for the full page height + 1 line, and incrementing y by the font height, you can display a page. The starting y should be -(font height) to 0 so it draws only partial text above the top line. So to easily get the y and top, have a pixel top that you convert to top and y, as top = (pixeltop / fontheight) and y = (pixeltop % fontheight) - fontheight. Or something close to that. pixeltop would range from 0 to total lines - visible lines * fontheight.

Thanks CuriousTech,

I will try that and come back in case of any questions.

Thank You,