xperiments-in / xtouch

Other
576 stars 54 forks source link

xtouch_touch_setup() calibration in touch.h is incorrect #88

Open gknops opened 6 months ago

gknops commented 6 months ago

The calibration is performed by drawing crosses with their center inset 10px. However the calibration calculation incorrectly uses the width of the entire cross.

So around line 140 the code should be (40 replaced with 20, 20 replaced with 10):

        int16_t xDist = 320 - 20;
        int16_t yDist = 240 - 20;

        x_touch_touchConfig.xCalM = (float)xDist / (float)(x2 - x1);
        x_touch_touchConfig.xCalC = 10.0 - ((float)x1 * x_touch_touchConfig.xCalM);
        // y
        x_touch_touchConfig.yCalM = (float)yDist / (float)(y2 - y1);
        x_touch_touchConfig.yCalC = 10.0 - ((float)y1 * x_touch_touchConfig.yCalM);

        xtouch_saveTouchConfig(x_touch_touchConfig);

        loadScreen(-1);