28 #ifndef _LCDGFX_TOUCH_H_ 29 #define _LCDGFX_TOUCH_H_ 56 uint16_t screenWidth = 320;
57 uint16_t screenHeight = 240;
68 void apply(int16_t rawX, int16_t rawY, int16_t &outX, int16_t &outY)
const 76 int32_t spanX = (int32_t)xMax - xMin;
77 int32_t spanY = (int32_t)yMax - yMin;
78 int32_t x = spanX != 0 ? ((int32_t)(rawX - xMin) * (screenWidth - 1)) / spanX : 0;
79 int32_t y = spanY != 0 ? ((int32_t)(rawY - yMin) * (screenHeight - 1)) / spanY : 0;
80 if ( invertX ) x = (int32_t)(screenWidth - 1) - x;
81 if ( invertY ) y = (int32_t)(screenHeight - 1) - y;
83 else if ( x >= (int32_t)screenWidth ) x = screenWidth - 1;
85 else if ( y >= (int32_t)screenHeight ) y = screenHeight - 1;
void apply(int16_t rawX, int16_t rawY, int16_t &outX, int16_t &outY) const
Apply the calibration to a pair of raw ADC samples.
Linear calibration mapping raw ADC counts from a resistive touch panel into screen pixel coordinates...