Skip to content
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

sleep() throws error #17

Closed
EAGrahamJr opened this issue Feb 2, 2024 · 3 comments
Closed

sleep() throws error #17

EAGrahamJr opened this issue Feb 2, 2024 · 3 comments

Comments

@EAGrahamJr
Copy link
Contributor

Adding a display.sleep() call at the end of the example causes an error to be thrown. This the hacked-up code that reproduces the error:

import busio
import displayio
import board
import adafruit_displayio_sh1106

# Create the I2C interface.
i2c = busio.I2C(board.SCL, board.SDA)
display_bus = displayio.I2CDisplay(i2c, device_address=0x3C)

WIDTH = 128
HEIGHT = 64
# create the display and put it to sleep
display = adafruit_displayio_sh1106.SH1106(display_bus, width=WIDTH, height=HEIGHT)
display.sleep()

This is the error (personal directories removed):

$ python brokesleep.py 
Traceback (most recent call last):
  File "brokesleep.py", line 14, in <module>
    display.sleep()
  File "venv/lib/python3.11/site-packages/adafruit_displayio_sh1106.py", line 111, in sleep
    self.bus.send(0xAE, b"")  # 0xAE = display off, sleep mode
    ^^^^^^^^^^^^^^^^^^^^^^^^
  File "venv/lib/python3.11/site-packages/displayio/_i2cdisplay.py", line 90, in send
    self._send(DISPLAY_COMMAND, CHIP_SELECT_UNTOUCHED, bytes([command] + data))
                                                             ~~~~~~~~~~^~~~~~
TypeError: can only concatenate list (not "bytes") to list
@dargus
Copy link
Contributor

dargus commented May 25, 2024

More info:
The issue affects both .sleep() and .wake().
I was able to get it working by putting
self.bus.send(0xAE, 0x00)
into adafruit_displayio_sh1106.py

and I ALSO had to modify i2cdisplaybus/init.py from
self._send(DISPLAY_COMMAND, CHIP_SELECT_UNTOUCHED, bytes([command] + data))
to
self._send(DISPLAY_COMMAND, CHIP_SELECT_UNTOUCHED, bytes([command] + [data]))

I'm not a good enough python programmer to figure out where/how this needs to be fixed at large, but hopefully it helps someone else if this can't be fixed upstream or elsewhere.

@dargus
Copy link
Contributor

dargus commented May 29, 2024

#18

Pull request submitted that should fix this.

@FoamyGuy
Copy link
Contributor

FoamyGuy commented Jun 9, 2024

resolved by #18

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

No branches or pull requests

3 participants