Skip to main content
EHay.1
Associate II
September 1, 2020
Solved

Why not call buttonCallbackHandler in touchGFX?

  • September 1, 2020
  • 2 replies
  • 1085 views

Hello! In project i am get in interrupt touch coordinate and handled in STM32TouchController::sampleTouch:

bool STM32TouchController::sampleTouch(int32_t& x, int32_t& y)
{
 /**
 * By default sampleTouch returns false,
 * return true if a touch has been detected, otherwise false.
 *
 * Coordinates are passed to the caller by reference by x and y.
 *
 * This function is called by the TouchGFX framework.
 * By default sampleTouch is called every tick, this can be adjusted by HAL::setTouchSampleRate(int8_t);
 *
 */
 if (ft_initialized)
 {
 if (ft5206.touchDetected)
 {
 x = ft5206.touchCoordinatesX[0];
 y = ft5206.touchCoordinatesY[0];
 ft5206.touchDetected = 0;
 return true;
 }
 }
 return false;
}

But function Screen1ViewBase::buttonCallbackHandler never call:

void TestViewBase::buttonCallbackHandler(const touchgfx::AbstractButton& src)
{
 if (&src == &button1)
 {
 //Interaction1
 //When button1 clicked change color of box1
 //Set RGB color R:255, G:0, B:0 on box1
 box1.setColor(touchgfx::Color::getColorFrom24BitRGB(255,0,0));
 box1.invalidate();
 }
}
TestViewBase::TestViewBase() :
 buttonCallback(this, &TestViewBase::buttonCallbackHandler)
{
 
 box1.setPosition(0, 0, 800, 480);
 box1.setColor(touchgfx::Color::getColorFrom24BitRGB(63, 59, 107));
 
 button1.setXY(315, 210);
 button1.setBitmaps(touchgfx::Bitmap(BITMAP_BLUE_BUTTONS_ROUND_EDGE_SMALL_ID), touchgfx::Bitmap(BITMAP_BLUE_BUTTONS_ROUND_EDGE_SMALL_PRESSED_ID));
 button1.setAction(buttonCallback);
 
 add(box1);
 add(button1);
}

This topic has been closed for replies.
Best answer by EHay.1

Hello,

Thank you for answer. I fixed this problem. My software touch driver has swapped X and Y coordinates.

Best regards!

/Evgeny

2 replies

Alexandre RENOUX
Visitor II
September 8, 2020

Hello,

Have you tried debugging and see if any touch event is detected in your sampleTouch function ?

Also, when you are posting something please provide more information such as the board you are using, MCU, display, display interface, etc.

/Alexandre

EHay.1
EHay.1AuthorBest answer
Associate II
September 9, 2020

Hello,

Thank you for answer. I fixed this problem. My software touch driver has swapped X and Y coordinates.

Best regards!

/Evgeny