Bodmer / TFT_eSPI

Arduino and PlatformIO IDE compatible TFT library optimised for the Raspberry Pi Pico (RP2040), STM32, ESP8266 and ESP32 that supports different driver chips
Other
3.65k stars 1.05k forks source link

Multiple display support #663

Closed SunboX closed 4 years ago

SunboX commented 4 years ago

Hi,

I read about the reasons why only one display is supported from the library in issues #138

Two years have passed now, is there any plan to support multiple displays? Otherwise we have to implement a facade for each function call to simplify our code.

greetings, André

Bodmer commented 4 years ago

Thanks for the question. Unfortunately there are no plans for supporting multiple displays so the chip selects for the displays have to be managed by the sketch and this approach appears relatively simple to implement.

There is a "gotcha" in the latest library that improves performance by minimising the setAddrWindow position commands needed, you will need to tweak the library to avoid this for multiple displays by commenting out the "if" conditions here and here.

I understand that it is not ideal but the rarity of multiple display support means I cannot justify the effort to implement independent display classes that track all the different settings (font selected, cursor position etc) for different displays.

SunboX commented 4 years ago

Hey, thanks for the quick response! I understand your reasons, could I maybe offer a small wish?

In our case, it's easy. We have two identical displays. And there's a huge chance that the project is getting bigger and live for a longer time. Because of the second reason, I don't like to break the update-ability by forking your lib and modifiyng the code for our needs.

Is there a chance to add a small feature like this?

#define ADDRESS_PERFORMANCE_TWEAK

#if defined(ADDRESS_PERFORMANCE_TWEAK)
  // No need to send x if it has not changed (speeds things up)
  if (addr_col != (x0<<16 | x1)) {
    DC_C; tft_Write_8(TFT_CASET);
    DC_D; tft_Write_32C(x0, x1);
    addr_col = (x0<<16 | x1);
  }
#endif

greetings, André

Bodmer commented 4 years ago

OK, no problem, I will add this tomorrow sometime.

SunboX commented 4 years ago

That's really great, thanks a lot! Btw, no hurry, we have time enough. ;)

Bodmer commented 4 years ago

Added. Put

define MULTI_TFT_SUPPORT

in your setup file.

SunboX commented 4 years ago

Really great, thanks a lot!

Witchdoc59 commented 6 months ago

Could we create separate folders within the library folder then load the library from the different folders. Copy the TFT_eSPI files to a folder called TFT_eSPI_ILI9341 then when writing code that will use the ILI9341 you call the TFT_eSPI library from that folder? #include .\TFT_eSPI_ILI9341\TFT_eSPI.h ??