PiTFT capacitive calibration for vertical layout

PiTFT capacitive doesn't require calibration according to Adafruit, but for some reason I couldn't make it work properly with vertical layout and the default values suggsted here [1].

The default values are:

320 65536 0 -65536 0 15728640 65536

I needed to use the screen with Adafruit logo at the bottom [fbtft_device.rotate=90] and with the default /etc/pointercal values I had x axis swapped with y axis.

Explanation how the pointercal values works is here [2]. Some matrix math:

pointercal_equation.png

where:

x,y - the touchscreen coordinates returned by the kernel driver

a,b,c,d,e,f,s - pointercal values

u,v - the screen coordinates

The above equation converts to:

u = (x*a + y*b +1*c)/s

v = (x*d + y*e +1*f)/s

For the default values:

a = 320, b = 65536, c = 0 d = -65536, e = 0, f = 15728640, s = 65536

u = (x*320 + y*65536 + 0) / 65536

v = (x*(-65536) + y*0 + 15728640) / 65536

I wanted to flip x<->y, so

u = (x*(-65536) + y*0 + 15728640) / 65536

v = (x*320 + y*65536 + 0) / 65536

and now a = -65536, b = 0, c = 15728640 d = 320, e =65536 , f = 0,  s = 65536.

However when I tried to use those values in the pointercal file:

-65536 0 15728640 320 65536 0 65536

I found out that x axis is OK, but y axis is still flipped. To fix it we have to change sign of v and add a shift.

v = -(x*320 + y*65536 + 0) / 65536 +320

v = (x*(-320) + y*(-65536) +0)/65536 + 320

v= (x*(-320) + y*(-65536) +0)/65536 + 320*65536/65536

v= (x*(-320) + y*(-65536) +320*65536)/65536

v= (x*(-320) + y*(-65536) + 20971520)/65536

so d = -320, e = -65536 and f = 20971520

Proper pointercal values for vertical layout [fbtft_device.rotate=90] are:

-65536 0 15728640 -320 -65536 20971520 65536


They posted on the same topic

Trackback URL : http://blog.firszt.eu/index.php?trackback/31

This post's comments feed