cancel
Showing results for 
Search instead for 
Did you mean: 

Why not call buttonCallbackHandler in touchGFX?

EHay.1
Associate III

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);
}

1 ACCEPTED SOLUTION

Accepted Solutions
EHay.1
Associate III

Hello,

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

Best regards!

/Evgeny

View solution in original post

2 REPLIES 2
Alexandre RENOUX
Principal

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
Associate III

Hello,

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

Best regards!

/Evgeny