GUIslice icon indicating copy to clipboard operation
GUIslice copied to clipboard

Is it possible to get the SPI instance that is being used by the display for other devices

Open Jonathan-0101 opened this issue 1 year ago • 6 comments

I'm working on a project with a custom ESP32-S3 board and multiple SPI devices sharing the bus and I was wondering how I can the SPI instance that is used by the library and pass it to other devices.

(Have a ST7796 display using TFT_eSPI with XPT2046 internal touch controller).

Thanks in advance.

Jonathan-0101 avatar Apr 19 '25 15:04 Jonathan-0101

@Jonathan-0101 This is all handled within the TFT_eSPI library.
You might want to ask on TFT-eSPI's issue forum. As far as I can see spi for esp32's is handled inside Processors\TFT_eSPI_ESP32.c

The only thing I can think of is to edit TFT_eSPI.h like so:

//#if !defined (TFT_PARALLEL_8_BIT) && !defined (RP2040_PIO_INTERFACE)
  static   SPIClass& getSPIinstance(void); // Get SPI class handle
//#endif

Then call GUIslice api:

TFT_eSPI display = (TFT_eSPI)gslc_DrvGetDriverDisp(&m_gui);
 SPIClass my_spi = display.getSPIinstance());

Although I have no idea if thats useful or not. I also don't know if there is an easier way. Paul--

Pconti31 avatar Apr 22 '25 16:04 Pconti31

@Jonathan-0101 Oh! You would also need to edit TFT_eSPI.cpp to match the header... Paul--

Pconti31 avatar Apr 22 '25 17:04 Pconti31

@Pconti31 Thank you for the suggestion. I was looking through the files and assumed that this might be the case, but thought it was worth checking first as it feels like something that would have previously been encountered. Will have a look there and give it a go.

Jonathan-0101 avatar Apr 22 '25 17:04 Jonathan-0101

@Pconti31 On an unrelated note, the touch on the program I'm working on only works intermittently (tested with multiple displays) and have tried calibrating and adjusting sensitivity with no luck. Half the time when the program loads no touch will register and the rest of the time, touch will eventually stop working. Any suggestions on how to fix this? Thanks.

Jonathan-0101 avatar Apr 22 '25 17:04 Jonathan-0101

@Jonathan-0101 I would suggest using PaulStoffregen/XPT2046_Touchscreen If you do don't forget to edit User_Setup.h and comment out TOUCH_CS and change GUIslice config from esp-tftespi-default-xpt2046_int.h to esp-tftespi-default-xpt2046.h

Paul--

Pconti31 avatar Apr 22 '25 22:04 Pconti31

@Jonathan-0101 If PaulStoffregen's library also fails you might have a conflict or noise on your spi bus or you are running the bus at too high a speed. Paul--

Pconti31 avatar Apr 22 '25 22:04 Pconti31