This is the David Smart RA8875 Library with mods for working with FRDM-K64F
Diff: RA8875_Touch.cpp
- Revision:
- 181:0032d1b8f5d4
- Parent:
- 178:ae472eb22740
- Child:
- 183:808f272e481e
--- a/RA8875_Touch.cpp Thu Aug 01 22:35:29 2019 +0000 +++ b/RA8875_Touch.cpp Fri Aug 02 02:12:26 2019 +0000 @@ -69,7 +69,7 @@ touchSample = 0; touchState = no_cal; //touchTicker.attach_us(callback(this, &RA8875::_TouchTicker), TOUCH_TICKER_uS); - #if (MBED_MAJOR_VERSION >= 5) || (MBED_LIBRARY_VERSION > 128) // Is this the right version? + #if (MBED_MAJOR_VERSION >= 5) || (MBED_LIBRARY_VERSION > 127) touchTicker.attach_us(callback(this, &RA8875::_TouchTicker), TOUCH_TICKER_uS); #else touchTicker.attach_us(this, &RA8875::_TouchTicker, TOUCH_TICKER_uS); @@ -113,7 +113,7 @@ touchState = no_cal; if (bTpEnable == TP_ENABLE) { //touchTicker.attach_us(callback(this, &RA8875::_TouchTicker), TOUCH_TICKER_uS); - #if (MBED_MAJOR_VERSION >= 5) || (MBED_LIBRARY_VERSION > 128) // Is this the right version? + #if (MBED_MAJOR_VERSION >= 5) || (MBED_LIBRARY_VERSION > 127) touchTicker.attach_us(callback(this, &RA8875::_TouchTicker), TOUCH_TICKER_uS); #else touchTicker.attach_us(this, &RA8875::_TouchTicker, TOUCH_TICKER_uS); @@ -334,7 +334,7 @@ if (panelTouched == true) { panelTouched = false; if (TouchPoint) { - *TouchPoint = touchInfo[0].coordinates; + *TouchPoint = TranslateOrientation(touchInfo[0].coordinates); ts = touchInfo[0].touchCode; INFO("Touch[0] %2d (%4d,%4d)", touchInfo[0].touchCode, touchInfo[0].coordinates.x, touchInfo[0].coordinates.y); @@ -356,14 +356,15 @@ { if (channel >= TouchChannels()) channel = 0; - return touchInfo[channel].touchCode; + INFO("TouchCode[%d] = %d", channel, touchInfo[channel].touchCode); + return touchInfo[channel].touchCode; } point_t RA8875::TouchCoordinates(uint8_t channel) { if (channel >= TouchChannels()) channel = 0; - return touchInfo[channel].coordinates; + return TranslateOrientation(touchInfo[channel].coordinates); } TouchCode_t RA8875::TouchPanelGet(point_t * TouchPoint) @@ -383,6 +384,35 @@ return t; } +point_t RA8875::TranslateOrientation(point_t rawPoint) +{ + point_t newPoint = rawPoint; + + #if 0 + switch (screen_orientation) { + default: + case rotate_0: + newPoint = rawPoint; + break; + case rotate_90: + newPoint.x = rawPoint.y; + newPoint.y = height() - rawPoint.x; + break; + case rotate_180: + newPoint.x = width() - rawPoint.x; + newPoint.y = height() - rawPoint.y; + break; + case rotate_270: + newPoint.x = height() - rawPoint.y; + newPoint.y = rawPoint.x; + break; + } + INFO("Translate(%3d x %3d) => (%3d x %3d)", rawPoint.x, rawPoint.y, newPoint.x, newPoint.y); + #endif + return newPoint; +} + + // Below here are primarily "helper" functions. While many are accessible // to the user code, they usually don't need to be called. @@ -784,7 +814,7 @@ m_i2c->write(m_addr, (const char *)®, 1); m_i2c->read(m_addr, &val, 1); - HexDump("FT5206_Read", (uint8_t *)&val, 1); + //INFO("ReadReg %02X, Val %02X", reg, val); return (uint8_t)val; }