void RA8875::touchReadAdc(uint16_t *x, uint16_t *y)
{
uint16_t tx,ty;
readTouchADC(&tx,&ty);
if (_calibrated) {
#if (defined(TOUCSRCAL_XLOW) && (TOUCSRCAL_XLOW != 0)) || (defined(TOUCSRCAL_XHIGH) && (TOUCSRCAL_XHIGH != 0))
*x = map(tx,_tsAdcMinX,_tsAdcMaxX,0,1024);
#else
*x = tx;
#endif
#if (defined(TOUCSRCAL_YLOW) && (TOUCSRCAL_YLOW != 0)) || (defined(TOUCSRCAL_YHIGH) && (TOUCSRCAL_YHIGH != 0))
*y = map(ty,_tsAdcMinY,_tsAdcMaxY,0,1024);
#else
*y = ty;
#endif
} else {
*x = tx;
*y = ty;
}
_checkInterrupt(2);
}
/**************************************************************************/
/*!
Returns pixel x,y data with SCREEN scale (screen width, screen Height)
Parameters:
x: out 0...screen width (pixels)
Y: out 0...screen Height (pixels)
Check for out-of-bounds here as touches near the edge of the screen
can be safely mapped to the nearest point of the screen.
If the screen is rotated, then the min and max will be modified elsewhere
so that this always corresponds to screen pixel coordinates.
/M.SANDERSCROCK added constrain
*/
/**************************************************************************/
void RA8875::touchReadPixel(uint16_t *x, uint16_t *y)
{
uint16_t tx,ty;
readTouchADC(&tx,&ty);
if (_calibrated) {
*x = constrain(map(tx,_tsAdcMinX,_tsAdcMaxX,0,_width-1),0,_width-1);
//*y = map(ty,_tsAdcMinY,_tsAdcMaxY,0,_height-1);
*y = constrain(map(ty,_tsAdcMinY,_tsAdcMaxY,0,_height-1),0,_height-1);
//*x = map(tx,_tsAdcMinX,_tsAdcMaxX,0,_width-1);
} else {
*x = tx;
//*y = map(ty,_tsAdcMinY,_tsAdcMaxY,0,_height-1);
*y = ty;
}
_checkInterrupt(2);
}