Skip to content

Remove unnecessary delays from SSD1306 SPI transfer code #756

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

mateusznowakdev
Copy link

Hello,

for my recent project I'm using a small SSD1306 display, 128x32, over SPI.

I've noticed that the SPI communication code - the tx function - has 1ms delay for each SPI transfer, which is quite a lot even if considered a "safety margin". There's 7ms of total delay introduced each time new screen contents are sent (set column address, set page address, then send buffer data). Actually, on lower performance microcontrollers this can be as much as 10ms, as tested with custom SAMD21 board. This makes it impossible to create an application that tries to target 60fps - games, smooth UI, etc.

This behaviour was introduced with the very first version of SSD1306 driver. I guess this went unnoticed because most of the time 128x64 displays are used, and registers are not updated in that case. The delay of 1.5ms was simply less of a problem than 10ms.

As an example, MicroPython SSD1306 library does not have any delay before each transaction. TinyGo SH1106 driver has 1µs (not 1ms), but based on comments even such tiny delay may be unnecessary.

I also fail to see why CS pin needs to be pulled high before DC pin is changed, but since other implementations have this logic let's keep it as is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant