My code to get x/y/z values is below
#define SPI_SETTING SPISettings(2000000, MSBFIRST, SPI_MODE0)
void XPT2046_Touchscreen::update()
{
SPI.beginTransaction(SPI_SETTING);
digitalWrite(csPin, LOW);
SPI.transfer( 0b10110001); //z1
int16_t z1 = SPI.transfer16(0b11000001) >> 3; //z2
int16_t z2 = SPI.transfer16(0b11010001) >> 3; //x
int16_t x = SPI.transfer16(0b11010001) >> 3; //x
int16_t x2= SPI.transfer16(0b10010001) >> 3; //y
int16_t y = SPI.transfer16(0b10010001) >> 3; //y
int16_t y2= SPI.transfer16(0) >> 3;
digitalWrite(csPin, HIGH);
SPI.endTransaction();
Serial.printf("z1,z2, x,x, y,y = %d,%d, %d,%d, %d,%d", z1, z2, x, x2, y, y2);
}
Typical output looks like this:
z1,z2, x,x, y,y = 2579,2342, 2431,1559, 1512,16
The z2 and x1 values are always close to each other, as are x2 and y1. The y2 value remains orders of magnitudes off.
Any ideas what's going wrong?