adafruit / Adafruit-SSD1351-library

Adafruit library for the 1.27" and 1.5" color OLEDs in the shop
http://www.adafruit.com/products/1431
Other
107 stars 49 forks source link

begin() Misconfiguration via Doubled Command Writes #17

Closed PalantirWielder closed 5 years ago

PalantirWielder commented 6 years ago

During setup the display controller should be configured with singular "Command" bytes, optionally followed by 1 or more "Data" bytes. There are 3 places within Adafruit_SSD1351::begin(void) where a "Command" transmission is followed by another "Command" when it should be a "Data" transmission.

SSD1351 Technical Data document, Rev 1.3, section 9 indicates that "D/C#" line should be "0" (Command) once at the start of a command, then "1" (Data) in each subsequent data transmission.

I'm guessing that the three highlighted writeCommand()'s are being ignored since they don't have data following them. And the secondary writeCommand()'s payloads of 0xF1, 0x32, and 0x05 are being ignored because they are not 0-data-byte Commands. If the commands were 1+ data-byte Commands, there's no "Data" immediately following them to complete the command. However if the values were changed to match 0-data-byte commands, i.e. 0x5C, 0x5D, 0xA4-0xA7, etc, I suspect they'd be incorrectly interpreted as valid commands.

In spite of this the display still operates. I suspect that the controller's default "reset values" are being relied upon since the three commands don't complete appropriately. Additionally, I've the display by displaying a static image using the current library, as well as the library modified to change the secondary writeCommand()'s to writeData()'s. I recorded a video of the display in both configurations at 240 fps, and there's a visible difference in the row scanning frequency, indicating that there is a functional difference to the two library configurations (Command-Command versus Command-Data).

It's possible the code I've highlighted is a typo, or there's something I missed in the technical document. I'd be interested to hear what other people think.

TL;DR: If this is a typo, the secondary writeCommand() on lines 385, 422, and 425 should be changed to writeData()

https://github.com/adafruit/Adafruit-SSD1351-library/blob/8b60d5be9f92081305a43f96ad246604435ca9d4/Adafruit_SSD1351.cpp#L384-L385 https://github.com/adafruit/Adafruit-SSD1351-library/blob/8b60d5be9f92081305a43f96ad246604435ca9d4/Adafruit_SSD1351.cpp#L421-L422 https://github.com/adafruit/Adafruit-SSD1351-library/blob/8b60d5be9f92081305a43f96ad246604435ca9d4/Adafruit_SSD1351.cpp#L424-L425

ladyada commented 5 years ago

hiya fixed by refactoring how we do the init code!