cancel
Showing results for 
Search instead for 
Did you mean: 

buttonCallbackHandler not trigger if touchgfx::Button is clicked

giacomopan
Associate II

Hello,

I'm working with STM32H7A3, STM32CubeIDE Version: 1.14.1 and TouchGFX Designer 4.23.2.

If I add a simple button to my project, when I press the button on the touch screen I see the image change but the buttonCallbackHandlerdoes not trigger, while if I add for example a toggle button the callback triggers correctly

I attach part of the code generated by TouchGFX Designer.

void Working_menuViewBase::buttonCallbackHandler(const touchgfx::AbstractButton& src)
{
    if (&src== &toggleButton1)
    {
        //Interaction1
        //When toggleButton1 clicked execute C++ code
        //Execute C++ code
        static int i;
        i++;
    }
    if (&src== &button1)
    {
        //Interaction2
        //When button1 clicked execute C++ code
        //Execute C++ code
        static int i;
        i++;
    }
}

 

class Working_menuViewBase : public touchgfx::View<Working_menuPresenter>
{
public:
    Working_menuViewBase();
    virtual ~Working_menuViewBase();
    virtual void setupScreen();

protected:
    FrontendApplication& application() {
        return *static_cast<FrontendApplication*>(touchgfx::Application::getInstance());
    }

    /*
     * Member Declarations
     */
    touchgfx::Box __background;
    touchgfx::Image imgBack;
    touchgfx::ToggleButton toggleButton1;
    touchgfx::Button button1;

private:

    /*
     * Callback Declarations
     */
    touchgfx::Callback<Working_menuViewBase, const touchgfx::AbstractButton&> buttonCallback;

    /*
     * Callback Handler Declarations
     */
    void buttonCallbackHandler(const touchgfx::AbstractButton& src);

};

Any suggestions?

Thank you 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Hello

Ok, can you show the touch panel interrupt handler and also stm32touchcontroller::sampletouch. I mean how you have connect the thouch information to the sampletouch routine since it is readed based on interrupt. 

I would probably test first I2C reading  without inteterrupt (HAL_I2C_Master_Receive) to see does it affect anything.

Br JTP

View solution in original post

4 REPLIES 4
JTP1
Lead

Hello

Sounds weird, for me it seem to work straight out when I add some code execution to the interaction of button-widget. (Certainly not tested with STM32H7A3, just simulator though).

Can you share also the constructor function of base class ? Or even the  complete project (rar or 7zip packet).

BTW are you having this issue with target board and/or with simulator ?

Br JTP

I tried with the simulator and it works. The problem is only in the application. I'm running the touch with interrupt that triggers every 10ms if pressed and therefore an I2C communication takes place ( a HAL_I2C_Master_Transmit() and a HAL_I2C_Master_Receive_IT() ). Could this be the problem? I don't see any other critical points currently, the project is very simple and only has 2 test pages and the touch screen task for now

Hello

Ok, can you show the touch panel interrupt handler and also stm32touchcontroller::sampletouch. I mean how you have connect the thouch information to the sampletouch routine since it is readed based on interrupt. 

I would probably test first I2C reading  without inteterrupt (HAL_I2C_Master_Receive) to see does it affect anything.

Br JTP

giacomopan
Associate II

Hello,

I solved, it was caused by some issue on the I2C of the touchscreen.

I don't know why the button was showing animation but not triggering interrupts. However, it works correctly on the bus without any problems.

Thank you