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

Touchscreen SPI seems hardcoded (ESP32) #1431

Closed
daxliniere opened this issue Nov 16, 2021 · 19 comments
Closed

Touchscreen SPI seems hardcoded (ESP32) #1431

daxliniere opened this issue Nov 16, 2021 · 19 comments

Comments

@daxliniere
Copy link

I have just finished chasing my tail, trying to get the touch screen of an ILI9488 working on ESP32 (DevKitC v4 38-pin).
I had chosen non-standard SPI pins and customised them in User_Setup.h. The display was working perfectly, but when I tried any touchscreen sketches, the calibration phase would race through without being touched and obviously the touch didn't work once the main sketch loaded.

For other reasons, I ended up switching to standard SPI pins (18, 19, 23) and miraculously, the touch stuff all works now.

Is it possible that the SPI pins for the touch screen are hard-coded to the defaults rather than referencing the pins specified for the TFT?

All the best,
Dax Liniere.

@daxliniere daxliniere changed the title Touchscreen MOSI seems hardcoded (ESP32) Touchscreen SPI seems hardcoded (ESP32) Nov 16, 2021
@Bodmer
Copy link
Owner

Bodmer commented Nov 17, 2021

The touch SPI code uses the same SPI pins as the display for the interface so it is not hardcoded to a default port.

As reported here the ILI9488 SPI output ( SDO/MISO) does not go tristate and this cannot be circumvented, so do not connect the SDO/MISO pins on an ILI9488 if other SPI devices are on the same SPI bus.

You can use the "Test_Touch_Controller" diagnostic sketch to see if the touch screen can be read.

@daxliniere
Copy link
Author

Hey @Bodmer, thanks for the reply. Yes, I had already read about that and your clever fix to the diode, but in my case I never had ILI9488's SPI output connected to anything.

Any thoughts now that you know this?

@Bodmer
Copy link
Owner

Bodmer commented Nov 18, 2021

Run the Test_Touch_Controller sketch to see if communications are working with the touch controller when alternative pins have been allocated.

Run Read_User_Setup to check pin allocations are being correctly picked up by the compiler. List the pins you were trying to use.

@Bodmer
Copy link
Owner

Bodmer commented Nov 27, 2021

Assumed resolved.

@Bodmer Bodmer closed this as completed Nov 27, 2021
@fungreenfox
Copy link

fungreenfox commented Jan 19, 2022

I am having 3x ili9488 at 3.5" with touch. Only one of these are working in touch using standard setup wiring. Only change of rst to pin 4, but it doesnt matter how i set the wiring, even moving it all to pin 12, 13 and 14 for miso and miso and clk works.
There is a fault in the display and i ordered 2 new, each from different seller. Only difference from the first one, are some banes at the backside of the display are going downwards, instead of upwards. The 2 displays are having touch_cs shortcutted, and i have tried any combination with no luck.
The display that is working, is version V2.0 and the other two with shortcuts are V1.0.
V2.0 is slightly darker red color in the chassis, and the pinholder is black, where at V1.0 is yellow color.

It is also seen, that one customer expressing that its a parralel display indicating to be SPI. Im not sure about this.
reference: https://www.aliexpress.com/item/1005002926880241.html?spm=a2g0o.9042311.0.0.7aa94c4dW2IJSz

@Bodmer
Copy link
Owner

Bodmer commented Jan 19, 2022

The link has a bad description, this suggests it is a SPI display, but some pictures show parallel boards. It is not clear to me which display boards you have.

The touch function requires a chip select for the TFT and one for the touch controller.

@fungreenfox
Copy link

fungreenfox commented Jan 19, 2022

I have this one, as it says: 3.5 inch TFT LCD Module with Touch Panel ILI9488 Driver 320x480 SPI port serial interface (9 IO) Touch ic XPT2046 for ard stm32
My setup is
#define T_DO 12
#define T_DIN 23
#define T_CS 5//5 set in User_setup.h
#define T_CLK 18
#define TP_IRQ 13
//For the M5Stack module use these #define lines
#define TFT_MISO 19//19
#define TFT_MOSI 23//23
#define TFT_SCLK 18//18
#define TFT_CS 5 //Chip select control pin
#define TFT_DC 2 // Data Command control pin
#define TFT_RST 4 // Reset pin (could connect to Arduino RESET pin)
#define TFT_BL 25 // LED back-light (required for M5Stack)
#define TOUCH_CS 5 // Chip select pin (T_CS) of touch screen

Can you specify chip select for TFT and one for the touch controller? is this a chip needed to be added or a wiring?

@Bodmer
Copy link
Owner

Bodmer commented Jan 19, 2022

The chip select pins for the TFT and touch controller MUST be different. Do not connect TFT MISO as it does not go tristate on the ILI9488. See here:
#898

@fungreenfox
Copy link

fungreenfox commented Jan 20, 2022

The link will show a picture of the V1.
https://www.dropbox.com/s/apfze1hanbz83lq/ili9488V1.jpg?dl=0

The ILI9341 SPI 3.5" and 9488 SPI 5" TFT display being V2.0 is working without any modification (removing miso will take the picture). Working setup with active Touch_CS is on V2:
#define T_DO 19
#define T_DIN 23
#define T_CS 13
#define T_CLK 18
//#define TP_IRQ 34//Not in use.
//For the M5Stack module use these #define lines
#define TFT_MISO 19
#define TFT_MOSI 23
#define TFT_SCLK 18
#define TFT_CS 15 // Chip select control pin
#define TFT_DC 2 // Data Command control pin
#define TFT_RST 4 // Reset pin (could connect to Arduino RESET pin)
#define TFT_BL 25 // LED back-light (required for M5Stack)
#define TOUCH_CS 5 // Chip select pin (T_CS) of touch screen

However, the V2.0 board has some wrong registrations in touch_CS area where it points a cm from the edge when the edge is
touched, so a new display was needed, but a V.1 was sent instead. (Fabrication fault in this case for my v2.0 - the V2.0 should generaly work ok ).
How i get the two other V1.0 to work with touch_CS , is still a myth for me.
It appears, there is difference from v1 to v2, that v2 can be setup without any further investigation.
It has been difficult to find a seller of this V2.0 https://www.dropbox.com/s/ipp4kv30hk00s7d/ii9488V2.0.jpg?dl=0

@Sampozzo
Copy link

Sampozzo commented Apr 9, 2022

Hello, i have the same issue, i have two ILI9488 marked v1.0 without the diode described there: #898

I can't get them working, with or without MISO connected. The calibration test example will autopress the corners and give the result:

// Use this calibration code in setup():
  uint16_t calData[5] = { 1, 1, 1, 1, 0 };
  tft.setTouch(calData);

Any help on this? @fungreenfox have you solved?

@fungreenfox
Copy link

fungreenfox commented Apr 10, 2022

Sampozzo, I have returned the issue to the seller, and he is happy to return 20% of my cost, if I send the display back. So thats a no go. I bought two more (9488 and 5"), and they are fortunately version 2, and they are working correct, even if placing the touch_cs on another pin. Pins used are:
For this suggestion, do only define pins in user_setup.h, so there are no repeating or overlapping.

#define TFT_MISO 19
#define TFT_MOSI 23
#define TFT_SCLK 18
#define TFT_CS 15 // Chip select control pin
#define TFT_DC 2 // Data Command control pin
#define TFT_RST 4 // Reset pin (could connect to Arduino RESET pin)
#define TFT_BL 25 // LED back-light (required for M5Stack)
#define TOUCH_CS 5 // Chip select pin (T_CS) of touch screen


void setup()
{
//Connect the display to 3.3volt, if trouble with brigtness etc.
//Turn on the Backlight with
// Check for backlight pin if not connected to VCC
#ifndef TFT_BL
Serial.println("No TFT backlight pin defined");
#else
pinMode(TFT_BL, OUTPUT);
digitalWrite(TFT_BL, HIGH);
#endif
}


User_Setup_Select.h:
#ifndef USER_SETUP_LOADED
#include <User_Setup.h>
#include <User_Setups/Setup21_ILI9488.h>


In Setup21_ILI9488.h
#define TFT_BACKLIGHT_ON HIGH // Level to turn ON back-light (HIGH or LOW) and no other pins repeated.
This of my suggestion can go down, if pins are defined in more places like setup and the Setup21_ILI9488.h itself.
Optionally, load all the mentioned fonts.
#define SPI_FREQUENCY 27000000
#define SPI_READ_FREQUENCY 16000000
#define SPI_TOUCH_FREQUENCY 2500000
Actually this runs, with a calibration that saves the result to SPIFF, and does not need to be commented in setup, but i got this result that works for a 5" 9488 (can vary from display to another)
uint16_t calData[5] = { 417, 3503, 341, 3516, 3 }; // and should not be just 1's.

The display worked for a weeks with no trouble, though the breadboard project was paused for a month, and turning back , the display did this act of shortcutting the touch_cs. I ripped all wires off the board and placed them again. Re-calibrated the savefile, and made sure, that there were no incorrect pins in use. (try disconnect all but display until it works).

But again, version 1 was a no-go for me. I asked 4-5 sellers, if they have the version 2, and nobody even knows of it. But the two ordered displays are version 2.
And the miso pin? yes, its connected with no conflicts.

@Sampozzo
Copy link

Hi @fungreenfox, thank you very much for your detailed reply, i will try your code, but @Bodmer said it is not pin related but hardware. So no solution...

@Bodmer
Copy link
Owner

Bodmer commented Apr 10, 2022

@Sampozzo provide a link to each of the displays you have and list all connections between the ESP32 and each display type. I am not sure where I said it is pin related!

@Sampozzo
Copy link

@Bodmer you said it is NOT pin related but hardware, in your first reply on this post :)

@Bodmer
Copy link
Owner

Bodmer commented Apr 10, 2022

Must be a misunderstanding there!

Here are example pin connections. Note that the display SDO MUST be left disconnected.

image

@Sampozzo
Copy link

YESSSSSSSSSSSS!!!!!!
I left unconnected T_DO and SDO, looking at your picture now, i connected T_DO and it works!!!!!!

Thank you very much @Bodmer

@Olivierdemoustier
Copy link

I have bought a very nice Development Board with touch screen and ESP32 , all in one.
But SPI for display use different pins as SPI for touch. How can I configure this in User_Setup.h ?

@MichaelSaan
Copy link

I have the following question about this, GPIO21 is also required for the I2C bus (SDA). After connecting the display, can I still use the I2C bus for additional I2C slaves on the ESP32?

@Bodmer
Copy link
Owner

Bodmer commented May 19, 2023

The GPIO pins connected to the display cannot be used for I2C as well. Use a different GPIO for TOUCH_CS and update the setup file accordingly.

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

6 participants