PyDevices / pydisplay

Display, touch and encoder drivers for MicroPython, CircuitPython and Python
Other
34 stars 9 forks source link

Not able to integrate Multiple display #3

Closed shrynikjain closed 6 months ago

shrynikjain commented 10 months ago

Hi bdbarnett, Trying to integrate two same size display driver ili9341. I have created two display bus in board_config.py and in lv_config.py Using same SPI Bus with different cs pin on esp32-s3 which have 8MB PSRAM and 8MB PSROM using micropython 1.20. Compiled and build from [kdschlosser] repo, I am not able get how to integrate two display. I am attaching board_config file and lv_config file and screenshot of obtained result on display. Could you help with one example how to integrate more than one display using same SPI for micropython lvgl. board_config.txt lv_config.txt sample_pgrm.txt photo_2024-01-12_16-05-02

bdbarnett commented 10 months ago

I haven't tried with multiple displays, so I'm not sure if it will work in the current implementation, but that is certainly something I am interested in implementing. Here are a few things I would try:

in board_config.py, you have

from lib.lcd_bus import SPIBus

That is forcing it to use lcd_bus.py, the MicroPython implementation of lcd_bus. Since you are using an ESP32, the lcd_bus written in C and included with @kdschlosser's build will be faster. Try removing lib. from that line. Also, you have quad_spi=True. lcd_bus.py ignores this because it doesn't support quad_spi. When you remove lib. as recommended, be sure to make quad_spi=False.

For the rest of this, reference: https://docs.lvgl.io/master/overview/display.html

In sample_pgrm.py, you've commented out the line

#from lv_config import display,display1

Uncomment that. When only using a single display, you don't need to worry with this because lv.screen_load() is "always applied on the most recently created (default) display". When using multiple displays, you need to specify which display to put the screen on with lv.display_load_screen(disp, scr). To assign a screen to the non-default display, format it like:

lv.display_load_screen(display._disp_drv, scr)
lv.display_load_screen(display1._disp_drv, scr1)

I'm seeing now that I should have named it disp_drv instead of _disp_drv. I'll probably change that in a future revision of lv_driver_framework.py.

shrynikjain commented 10 months ago

Thank you for the reply, as according to your suggestion i tried "lv.display_load_screen(display._disp_drv, scr)" but getting error as follows, "Traceback (most recent call last): File "", line 69, in AttributeError: 'module' object has no attribute 'display_load_screen'"

could you guide what i am missing and where im doing wrong.

kdschlosser commented 10 months ago

are you using a shared bus? meaning are the displays sharing the same SPI lines? or do you have 2 completely separate sets of connections to the MCU?

bdbarnett commented 10 months ago

@shrynikjain Sorry about that. I gave you the wrong function to call. A lot has changed from lvgl 8.3, which is what I'm used to, and 9.0. The function is

lv.display_load_scr

not

lv.display_load_screen
shrynikjain commented 10 months ago

are you using a shared bus? meaning are the displays sharing the same SPI lines? or do you have 2 completely separate sets of connections to the MCU?

Thank you for the reply, I'm using same SPI lines(Bus) with different CS pin

shrynikjain commented 10 months ago

@shrynikjain Sorry about that. I gave you the wrong function to call. A lot has changed from lvgl 8.3, which is what I'm used to, and 9.0. The function is

lv.display_load_scr

not

lv.display_load_screen

Thank you for the reply, I'll check.

kdschlosser commented 10 months ago

are you using the same spi host number for both as well?

shrynikjain commented 10 months ago

are you using the same spi host number for both as well?

i am using diffrent spi host number for display1 using spihost as '0' and for display2 using spihost as '1'

kdschlosser commented 10 months ago

NO, they need to both use the same SPI host number. If they are using the same pins they both must use the same host number.

kdschlosser commented 10 months ago

and you should never use SPI host 0 if you are using an ESP32 device. That host is reserved for SPIRAM and SPIFLASH. use either host 1 or host 2 if it is supported.

My recommendation is for you to use hardware SPI pins. This will perform better.