Solved
How to use TouchscreenCalibration.hpp ?
#include <bsp/OTM8009TouchController.hpp>
#include <touchgfx/transforms/TouchCalibration.hpp>
extern "C"
{
#include "stm32f769i_discovery.h"
#include "stm32f769i_discovery_ts.h"
}
using namespace touchgfx;
using touchgfx::TouchCalibration;
TouchCalibration tsCalibration;
static touchgfx::Point lcdCalibPoints[3] = /* Display size is 800x480 */
{
{ 20, 20 }, /* 10%, 10% */
{ 780, 20 }, /* 90%, 50% */
{ 780, 460 }, /* 50%, 90% */
};
//calibration ADC 12 bit values
static touchgfx::Point touchCalibPoints[3] =
{
{ 200, 370 }, /* ADC values read when clicking in 80,48 */
{ 3927, 341 }, /* ADC values read when clicking in 720,240 */
{ 3919, 3807 }, /* ADC values read when clicking in 400,432 */
};
void OTM8009TouchController::init()
{
BSP_TS_Init(BSP_LCD_GetXSize(), BSP_LCD_GetYSize());
tsCalibration.setCalibrationMatrix(lcdCalibPoints, touchCalibPoints);
}
bool OTM8009TouchController::sampleTouch(int32_t& x, int32_t& y)
{
touchgfx::Point tsPos;
uint8_t status;
TS_StateTypeDef state;
BSP_TS_GetState(&state);
if (state.touchDetected)
{
tsPos.x = state.touchX[0];
tsPos.y = state.touchY[0];
tsCalibration.translatePoint(*&tsPos);
x = (uint16_t)tsPos.x;
y = (uint16_t)tsPos.y;
if ((x > 800) || (y > 480))
{
return false;
}
return true;
}
return false;
}I wrote the code above and the data I checked with the debugger was correct.
but button is not work...
