-
Notifications
You must be signed in to change notification settings - Fork 22
Description
As referenced in the following:
- Fix sleep/wake not working. Adafruit_CircuitPython_DisplayIO_SSD1306#43
- Fix sleep/wake, again Adafruit_CircuitPython_DisplayIO_SSD1306#44
- https://forums.adafruit.com/viewtopic.php?t=212512
there is an issue when using a single-byte command for sleep/wake. For this particular library, the error occurs when attempting to construct the "send" buffer vs the 4-Wire implementations, and apparently as well in the "core" CircuitPython images for micro-controllers.
Example from the SSD1306 driver (as mentioned above):
(0xAE, b"")
(0xAE, [])
Previous version (2.0.1) used the first form, but that did not work on Blinka, which I was using at the time. Version 2.0.2 incorporated my change, the second form.
The following code exemplifies the issue:
from circuitpython_typing import ReadableBuffer
def pretty_print(prefix, data):
hex_code = "".join(["%02X " % x for x in data])
print(f"{prefix} {hex_code}\n")
def i2c_usage(command: int, data: ReadableBuffer):
sent_this = bytes([command] + data)
pretty_print("i2c", sent_this)
def four_wire(command: int, data: ReadableBuffer):
b = bytes([command])
pretty_print("4-cmd", b)
pretty_print("4-buffer", data)
# SSD1036 "sleep"
# 2.0.2
print("My change-----------------")
four_wire(0xAE, [])
i2c_usage(0xAE, [])
# 2.0.1
print("Old usage-----------------")
four_wire(0xAE,b"")
i2c_usage(0xAE,b"")
I do not have all the available interface devices needed to test "all the changes", but my opinion is that the least disruptive would be to update this library's I2C implementation to be more forgiving and "revert" the SSD1306 change in a new 2.0.3 version.