2019-03-08 06:38 AM
#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...
Solved! Go to Solution.
2019-08-29 06:25 AM
As suggested I opened a new thread "Touchgfx can't detect any touch"
2019-08-29 06:30 AM
Thanks! I'll head over there now :)
2019-08-29 06:32 AM
Hmm, i don't see it. Can you post the link? Maybe it doesn't show up in the TouchGFX feed.
2019-08-29 06:40 AM
2019-08-29 06:40 AM
TouchGFX won't ignore it. I'm not sure what's going on because i don't have your project or board.
TouchGFX at its core does not really care about touch. It offers a handle that you can implement and use your own drivers (ST-drivers in this case, since its an eval board). We have to look to the project and version of drivers, etc. The touch registers are read by the driver through a protocol like I2C. You can't inspect it directly.
Can you please try to create your project through the designer? And which F4 board is this?
/Martin
2019-08-29 06:41 AM
Thanks!