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 just display wrong data with ili9488 #46

Open
cho934 opened this issue Mar 23, 2023 · 10 comments
Open

touchscreen just display wrong data with ili9488 #46

cho934 opened this issue Mar 23, 2023 · 10 comments

Comments

@cho934
Copy link

cho934 commented Mar 23, 2023

I'm using teensy 4.0, and I connected only the touchscreen of the LCD 3.5" v1.0 (ili9488) by SPI in order to have a simple test.

I tested both examples with IRQ and without, in both cases, Data on the serial are displays strange number even if I didn't touch the screen.

3:22:44:     z1=0,z2=0      z=4095 p=4095,  0,0  0,0  0,0Pressure = 4095, x = 0, y = 0
23:22:45:     z1=0,z2=0      z=4095 p=4095,  0,0  0,0  0,0Pressure = 4095, x = 0, y = 0
23:22:45:     z1=0,z2=0      z=4095 p=4095,  0,0  0,0  0,0Pressure = 4095, x = 0, y = 0
23:22:45:     z1=0,z2=0      z=4095 p=4095,  0,0  0,0  0,0Pressure = 4095, x = 0, y = 0
23:22:45:     z1=0,z2=0      z=4095 p=4095,  0,0  0,0  0,0Pressure = 4095, x = 0, y = 0
23:22:45:     z1=24,z2=18      z=4101 p=4101,  0,0  0,0  0,0Pressure = 4101, x = 0, y = 0
23:22:45:     z1=0,z2=0      z=4095 p=4095,  0,0  0,0  0,0Pressure = 4095, x = 0, y = 0
23:22:45:     z1=24,z2=18      z=4101 p=4101,  26,18  26,18  26,0Pressure = 4101, x = 26, y = 18
23:22:45:     z1=0,z2=0      z=4095 p=4095,  0,0  0,0  0,0Pressure = 4095, x = 0, y = 0
23:22:45:     z1=24,z2=18      z=4101 p=4101,  26,18  26,18  26,0Pressure = 4101, x = 26, y = 18
23:22:45:     z1=0,z2=0      z=4095 p=4095,  0,0  0,0  0,0Pressure = 4095, x = 0, y = 0
23:22:45:     z1=24,z2=18      z=4101 p=4101,  26,18  26,18  26,0Pressure = 4101, x = 26, y = 18
23:22:45:     z1=0,z2=0      z=4095 p=4095,  0,0  0,0  0,0Pressure = 4095, x = 0, y = 0

If I tried exactly the same code with another LCD 2.8" v1.2 (ili9341), It works perfectly !

What's wrong with the ili9488 ? does the touch is different ?

Here is the code of the example with pin 6 as CS


#include <XPT2046_Touchscreen.h>
#include <SPI.h>

#define CS_PIN  6
// MOSI=11, MISO=12, SCK=13

// The TIRQ interrupt signal must be used for this example.
#define TIRQ_PIN  3
XPT2046_Touchscreen ts(CS_PIN, TIRQ_PIN);  // Param 2 - Touch IRQ Pin - interrupt enabled polling

void setup() {
  Serial.begin(38400);
  ts.begin();
  // ts.begin(SPI1); // use alternate SPI port
  ts.setRotation(1);
  while (!Serial && (millis() <= 6000));

}

void loop() {

  if (ts.touched()) {
	TS_Point p = ts.getPoint();
	Serial.print("Pressure = ");
	Serial.print(p.z);
	Serial.print(", x = ");
	Serial.print(p.x);
	Serial.print(", y = ");
	Serial.print(p.y);
	delay(30);
	Serial.println();
  }
  delay(100);

	/*
  // tirqTouched() is much faster than touched().  For projects where other SPI chips
  // or other time sensitive tasks are added to loop(), using tirqTouched() can greatly
  // reduce the delay added to loop() when the screen has not been touched.
  if (ts.tirqTouched()) {
    if (ts.touched()) {
      TS_Point p = ts.getPoint();
      Serial.print("Pressure = ");
      Serial.print(p.z);
      Serial.print(", x = ");
      Serial.print(p.x);
      Serial.print(", y = ");
      Serial.print(p.y);
      //
      delay(30);
      Serial.println();
    }
  }*/
}

Thanks in advance,

@koattila
Copy link

koattila commented Sep 5, 2023

Is there any solution for this? I have the same problem, it does not work for ili9488.

@PaulStoffregen
Copy link
Owner

What's wrong with the ili9488 ? does the touch is different ?

On most displays the touch interface is made with a separate chip. Only the company who sold this display can answer regarding which hardware it really has.

You didn't even give a link to the product or photo of the display. How can you except anyone to be able to answer this sort of question? Any answer with zero information about the actual display would be blind guessing!

@koattila
Copy link

koattila commented Sep 5, 2023

Sorry sir, here's my information.

This is the display I'm using, ILI9488 480x320.
Display (Color: LCD With Touch)

This is the schematic I'm using. For the XPT2046, i'm using the VSPI pins of the ESP32.

image

I tested the display with TFT_eSPI library, using the ESP32_PARALLEL (Setup16_ILI9488_Parallel.h) setup, and it was working perfectly.

This library does not have a touch capability unfortunately, so that's why I wanted to use your library.

This is the code which I tried:

#include <XPT2046_Touchscreen.h> 

#define CS_PIN  5
#define _sclk              18
#define _mosi              23 
#define _miso              19
XPT2046_Touchscreen ts(CS_PIN);
uint16_t x, y, z;


void setup() {
  Serial.begin( 115200 );
  ts.setRotation(1);
  SPI.begin();
  //SPI.setFrequency( 60000000 );
  ts.begin();

}

void loop() {
  // put your main code here, to run repeatedly:
  
  //ts.readData(&x, &y, &z);
  TS_Point p = ts.getPoint();
  
  Serial.print("x = ");
  Serial.print(p.x);
  Serial.print(", y = ");
  Serial.print(p.y);
  Serial.print(", z = ");
  Serial.println(p.z);
}

I just get x = 0, y = 0, z = 4095, no matter if I touch the screen or not.

Thank you for looking into the issue.

@PaulStoffregen
Copy link
Owner

Tech info is minimal on that page, but the 40 pin product appears to have no touch controller chip like XPT2046.

Documentation says touch connection is raw signals on pins 1-4.

screenshot

Hopefully you can understand how this library can not work if the hardware you use does not have the XPT2046 chip?!

Again, you could ask the vendor who sold this display for support. Only they can answer technical questions about the hardware, specifically which touch chip (if any) is on the hardware.

But you should understand many displays have no touch chip. They simply give the raw signals. It is less expensive because no extra chip is used to make the display. If you have this type of display, obviously this library can not help.

@koattila
Copy link

koattila commented Sep 5, 2023

Hi,
I know it's just the raw display, but I put an external XPT2046 chip on the schematic (see above).

I recreated thier circuit, because I needed to use 8bit communication instead of SPI due to speed limitations.

So the circuit does have a controll chip.

image

@PaulStoffregen
Copy link
Owner

Maybe try with a board like Arduino Uno?

@PaulStoffregen
Copy link
Owner

ESP has complex issues with SPI. I do not use ESP, so can not help. But simple boards like Uno R3 are known to work well and easy to use, with simple SPI. Better to test with simple first.

@koattila
Copy link

koattila commented Sep 5, 2023

Okay, I give it a try, thank you!

@koattila
Copy link

koattila commented Sep 5, 2023

Before started to rewire everything, I tried this library as the last resort, and it was working perfectly.

Bodmer TFT touch

just live it here in case anyone have similar problem.

@gdcircuit
Copy link

I had the same issue and I believe that it was simply due to the fact that I was using a hardware uart for the display driver, and just daisy chaining the serial data to the touch chip. So whenever I would do a touch request it was using the same speed as the display was using which is too fast for the touch chip. Touch chip is around 2mhz. When you use the Bodmer lib, its using a separate soft uart, so the speed is much less. I think you can get around this by using the spi set clock command, but it works fine by just having a separate soft spi bus to the touch chip.

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

4 participants