bitbank2 / ssd1327

SSD1327 and SSD1322 OLED display library for Arduino+Linux
26 stars 5 forks source link

ssd1327WriteDataBlock and oledWrite broken by Arduino 32-byte buffer limit #9

Open jkunkee opened 2 years ago

jkunkee commented 2 years ago

While developing for my Particle Photon (Arduino environment, several 10s of KiB RAM) and using the backbuffer-dependent features, I noticed that I2C writes were being cut short.

From what I can tell, this is due to the Arduino Wire library having an I2C buffer length of 32 bytes (like here). It seems that Wire.write() truncates long writes to this length, so only the SSD1327 'this is data' byte and 31 bytes of pixel data go through. This leads to chunks of lines being skipped, causing the display to seem corrupted and cut off.

My workaround is to simply avoid the limit on my 128x128 SSD1327 board:

ssd1327ShowBitmap(NULL, 0, 0, 0, 62, 128);
ssd1327ShowBitmap(NULL, 0, 62, 0, 62, 128);
ssd1327ShowBitmap(NULL, 0, 124, 0, 4, 128);

(This depends on also fixing the backbuffer address calculation issue.)

I would have submitted a fix in either ssd1327WriteDataBlock or oledWrite, but I don't see an obvious place for the change. Given there's a workaround, I thought I'd describe the issue here for anyone else hitting it and leave working out a fix for another day.