For debugging purposes I connected up the touchscreen controller only to the HSPI bus, not the ILI93141. This didn't make any difference.
I have set it up like so:
spi.setup(1, spi.MASTER, spi.CPOL_LOW, spi.CPHA_LOW, 8, 16, spi.FULLDUPLEX)
--xpt2046.init(cs_pin, irq_pin, height, width)
xpt2046.init(0,2,320,240)
I have an interrupt set up to pin 2, the IRQ pin of the touchscreen
gpio.trig(2, "down", function()
print(tmr.now(), xpt2046.getRaw())
end)
The interrupt works as intended but
getPositionAvg() often returns -1 for x or y
getRaw() often returns 2048
I did verify the screen does definitely have an XPT2046 just now with a loupe. Other than that I'm all out of ideas. I don't have a logic analyser or another module to try unfortunately.
Some example getPositionAvg() output that should range from (0,0) to (320,240)
-1 -1
90 110
-1 -1
49 103
91 140
53 127
49 125
-1 -1
49 125
49 125
-1 -1
84 144
-1 -1
-1 -1
84 143
-1 -1
-1 -1
57 122
-1 -1
55 121
-1 -1
-1 -1
-1 -1
56 123
-1 -1
80 116
102 100
103 71
20 40
-1 -1
-1 -1
22 42
21 40
-1 -1