How to use TouchscreenCalibration.hpp ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-03-08 6: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.
- Labels:
-
STM32F7 Series
-
TouchGFX
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-03-08 5:09 PM
Hi @ikassma​,
TouchGFX HAL will call translatePoints() automatically as long as you set the calibration matrix (as you've done in your init() function. Try without translating it yourself in sampleTouch().
If sampleTouch() is returning true (without touch happening) then it must be a driver problem since that will only happen if state.touchDetected is true.
Best regards,
Martin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-03-08 6:39 AM
I used 8"(800x480) TFT LCD and Resistive Touch Screen(driver is MAX11801).
I succeeded in receiving the touch screen ADC value. And I got to the coordinates using TouchScreenCalibration Class provided by TouchGFX. However, using the TouchScreenCalibration Class, sampleTouch () periodically returns a value, but no event has occurred.
I'm looking for an example using TouchScreenCalibation Class from TouchGFX.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-03-08 5:09 PM
Hi @ikassma​,
TouchGFX HAL will call translatePoints() automatically as long as you set the calibration matrix (as you've done in your init() function. Try without translating it yourself in sampleTouch().
If sampleTouch() is returning true (without touch happening) then it must be a driver problem since that will only happen if state.touchDetected is true.
Best regards,
Martin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-03-09 12:17 PM
hi @Martin KJELDSEN​
Thanks for your mention it.
i will try your suggest.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-03-09 11:50 PM
wow work it now!! thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-03-11 1:02 AM
You're welcome! :)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-08-29 2:46 AM
Hi @Martin KJELDSEN​ ,
I have a very similar issue. I'm running a simple touchGfx application, the STM32F4TouchController::sampleTouch function output looks correct (true the boolean, while x and y change correctly on the basis of the pressed area), but the application doesn't recognize the pressed button as happens in touchgfx simulator.
Here's is the code, for this stage state.TouchDetected is always 1.
bool STM32F4TouchController::sampleTouch(int32_t& x, int32_t& y)
{
/* USER CODE BEGIN F4TouchController_sampleTouch */
TS_StateTypeDef state;
BSP_TS_GetState(&state);
if (state.TouchDetected)
{
x = state.X;
y = state.Y;
return true;
}
return false;
/* USER CODE END F4TouchController_sampleTouch */
}
Thanks in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-08-29 6:01 AM
It's always 1? Then there's something wrong with the drivers. How did you create this project? Looks like with CubeMX.
Which F4 board is this? Try creating the project using the Application Template from the designer and do some comparisons.
/Martin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-08-29 6:02 AM
Would you mind creating a new topic for this? This thread is about TouchCalibration, which is something entirely different. I'll keep an eye out for it.
Thanks!
/Martin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-08-29 6:10 AM
Yes, I started with F4 evaluation board but I'm using a different display (720x720) and a different controller.
The video output looks good, the interactions that doesn't involve any touch action work good, but it can't detect any touch.
I forced the touchDetected field to 1 to debug this issue, I cannot understand how the touchgfx core can ignore the "touch" when x, y and the boolean returned are correct.
Is there a touch register? Is there any way to debug how the output of the sampleTouch function is used?
Thank you
