2021-03-21 10:28 PM
Thank you for helping.
environment:
board: custom
STM32TouchController :: sampleTouch () detects the touch and
Every time I press the button, it comes to the following if () and returns true.
The x and y coordinates are also valid values.
if (state.touchDetected)
{
x = state.touchX [0];
y = state.touchY [0];
return true;
}
However, it may or may not come inside the button's callback handler.
This is the part of n1_pushde () below.
xxxViewBase :: buttonCallbackHandler ()
{
if (& src == & BuzzerExitBtn)
{
application (). gotoMainScreenNoTransition ();
}
else if (& src == & n1button)
{
n1_pushed ();
}
}
What's wrong?
2021-03-22 10:49 PM
Hello Ebun.1,
I'm sorry but I don't understand your situation. Could you try to be more precise ?
However, it may or may not come inside the button's callback handler.
This is the part of n1_pushde () below.
Especially this part is blurry to me.
/Alexandre
2021-03-23 05:21 PM
Hi Alexandre RENOUX
environment:
Board: Custom
STM32CubeIDE Ver1.6.0
TouchGFX Ver4.16.1
Sorry for lack of explanation.
I pasted a button called n10button on the screen.
We have prepared images for Released image and Pressed image in No style.
With INTERACTIONS
Trigger: button is clicked
Choose clicked source: n10button
Action: Call new virtual function
Function Name: n10_pushed
Interaction Name: n10pushed
It is said.
Implemented n10_pushed () in XxxView class.
I try to make a sound inside this function so that I can tell if this function has been called.
When the button is pressed, sampleTouch () sets the values to x and y and always returns true.
Even if you press the button, the sound may or may not be heard.
Even if there is no sound, the button switches the image, so the system is reacting in some way.
Why is n10_pushed () called or not called when I press the button?
Thank you.
bool STM32TouchController :: sampleTouch (int32_t & x, int32_t & y)
{
if (bsp_ts_initialized)
{
TS_StateTypeDef state;
BSP_TS_GetState (& state);
if (state.touchDetected)
{
x = state.touchX [0];
y = state.touchY [0];
return true;
}
}
return false;
}
void XxxViewBase :: buttonCallbackHandler (const touchgfx :: AbstractButton & src)
{
if (& src == & BuzzerExitBtn)
{
// Interaction2
// When BuzzerExitBtn clicked change screen to Main
// Go to Main with no screen transition
application (). gotoMainScreenNoTransition ();
}
else if (& src == & n10button)
{
// n10pushed
// When n10button clicked call virtual function
// Call n10_pushed
n10_pushed ();
}
}
void XxxView :: n10_pushed ()
{
// Make a sound here
}
2021-03-23 05:34 PM
Hello,
From my understanding this should definitely work. If a button on the UI is pressed and you created an interaction that calls the virtual function n10_pushed(), n10_pushed will be executed every time you press the button, actually every time you release the button. In fact a button widget triggers an action upon the RELEASE event and not the PRESS event.
Instead of making a sound, you can try simply calling touchgx_printf("test\n") in your n10_pushed() function and see in the simulator if "test" is printed correctly.
But overall, your project should work for sure, there's nothing wrong in what you showed me so far.
/Alexandre
2021-03-25 06:37 PM
Hi Alexandre RENOUX
Thank you for your reply.
It should work without problems.
I will investigate various things.