Open amirgon opened 6 years ago
I have tested with the same display couple of months ago, and the touch was quite reliable.
After calibrating with tpcalib.py
the demo application components/micropython/esp32/modules_examples/tft/paint.py
was running without issues.
I'll check if I've introduced some bug in the latest versions.
I have similar issue with a red ILI9341 module with XPT module. It seems this is a software issue since examples from the following arduino library works fine: https://github.com/Bodmer/TFT_eSPI
I managed to get meaningful raw (z, x, y) values by following change (orientation is messed up though...). https://github.com/taitix/MicroPython_ESP32_psRAM_LoBo/commit/d93202b1795f84f6ff5a4f681154f0e73c908419 Because this is the only touch device I own, I'm not sure if this is device specific behavior or some bug which affect all the device.
I think, there is a problem in tftpspi.c. The bits returning from xpr2046 are in big endian order, so you have to swap the bytes. I have made folling changes and it work for me:
@@ -604,8 +607,9 @@ int touch_get_data(uint8_t type) esp_err_t ret = spi_transfer_data_nodma(ts_spi, &t); if (ret != ESP_OK) return 0;
return res; }
I think, there is a problem in tftpspi.c. The bits returning from xpr2046 are in big endian order, so you have to swap the bytes. I have made folling changes and it work for me:
@@ -604,8 +607,9 @@ int touch_get_data(uint8_t type) esp_err_t ret = spi_transfer_data_nodma(ts_spi, &t); if (ret != ESP_OK) return 0;
uint16_t res = (uint16_t)(buf >> 8);
uint16_t res = ((buf>>16)&0xff)+(buf&0xff00);
res=(res>>3) & 0xfff;
return res; }
Do you mean a XPT2046? How are you initializating the display and callibrating it? I'm trying your changes, but I can't seem to get any touch response.
I'm using a TFT ILI9341 module with XPT2066 touch controller, like this one:
While the display works fine and a touch can be detected, the touch coordiates do not make sense and are not reliable.
This is not a calibration issue - a press on the same spot returns totally different results, sometimes with X and Y coordinates swapped.
In the example below I touched the same spot after each call to
tft.gettouch
. Every touch causedtft.gettouch
to return a result, but the returned coordinates do not make sense:To make sure this is not a hardware issue I tried this with two different modules. The result was the same.