pimoroni / st7789-python

Python library to control an ST7789 240x240 1.3" TFT LCD display.
MIT License
197 stars 53 forks source link

Dual displays no longer functional on newest library version #34

Open mitgobla opened 1 month ago

mitgobla commented 1 month ago

Previously, you could run two SPI displays (I was able to run two 240x240 round displays) at the same time, so long that the CS and BL pins were different.

For reference, this was discussed on the forums and this is where I was able to implement it from: https://forums.pimoroni.com/t/two-1-3-spi-colour-lcd-240x240-on-one-pi/16737/8

Now, when attempting to run the gif.py or image.py example with a minor addition to initialize a copy of disp as disp2 with the CS and BL pins changed, I get the following error message:

Traceback (most recent call last):
  File "/home/pi/Downloads/st7789-python/examples/gif.py", line 57, in <module>
    disp2 = st7789.ST7789(
  File "/usr/local/lib/python3.9/dist-packages/st7789/__init__.py", line 154, in __init__
    self._dc = gpiodevice.get_pin(dc, "st7789-dc", OUTL)
  File "/usr/local/lib/python3.9/dist-packages/gpiodevice/__init__.py", line 163, in get_pin
    lines = chip.request_lines(consumer=f"{consumer}-{label}", config={line_offset: settings})
  File "/home/pi/.local/lib/python3.9/site-packages/gpiod/chip.py", line 315, in request_lines
    req_internal = self._chip.request_lines(line_cfg, consumer, event_buffer_size)
OSError: [Errno 16] Device or resource busy

It appears that the latest version no longer releases the DC pin after use and therefore the second display cannot be initialized.

Steps:

  1. Create display such as those in the examples with cs as BG_SPI_CS_BACK and backlight as 18
  2. Create second display with cs as BG_SPI_CS_FRONT and backlight as 19
  3. Run the code. Error occurs when second display is initialized.
mitgobla commented 1 month ago

I've been able to confirm, returning to version 0.0.4 I am able to have both displays use the same DC port. Version 1.0.0 and latest 1.0.1 return the error mentioned above.