Skip to main content
Kneepatch
Senior
Dec 14, 2022 2:14 AM UTC
Solved

TouchGFX and ClickListener Debounce/Delay

I am having trouble with the ClickListener. I am trying to debounce the click event somehow. My first instinct is to delay and then check to see if the click is still present, but I am not sure it will work with this function because it seems that the click is an event that is triggered. For example, here is one of my click hander calls:

void MainView::circleClickHandler(const touchgfx::Circle& c, const ClickEvent& evt)
{

Any suggestions on what the proper way to debounce a ClickListener object is? The buttons that are built-in widgets seem to do this with no additional code. Thanks in advance!

P.S. - programming with the STM32F469I-DISCO board. 

This topic has been closed for replies.
Kneepatch
KneepatchBest answer
Senior
Dec 15, 2022 3:33 AM UTC

OK, so I figured out how to make this work:

void MainView::circleClickHandler(const touchgfx::Circle& c, const ClickEvent& evt)
{
 
	if(evt.getType() == touchgfx::ClickEvent::PRESSED){
 
	 if (&c == &headCircle)
	 {..}
}

Thanks for the tip to use the click event type!

-Kneepatch

6 replies

Osman SOYKURT
ST Technical Moderator
Dec 14, 2022 10:59 AM UTC

Hello Kneepatch,

I'm not sure to have understood what do you mean by "debounce" the click event. Can you clarify this?

Do you want to get the click status?

/Osman

ST Software Developer | TouchGFX
Kneepatch
KneepatchAuthor
Senior
Dec 14, 2022 12:16 PM UTC

Yes, I think that click status might do the trick! Whenever I pressed a button, it would seem to "unclick" itself, and I think that's because it was triggering whenever I RELEASED. I'll try it and come back if that doesn't work, thanks!

-Kneepatch
Osman SOYKURT
ST Technical Moderator
Dec 16, 2022 1:31 PM UTC

You're welcome!

ST Software Developer | TouchGFX
Kneepatch
KneepatchAuthorBest answer
Senior
Dec 15, 2022 3:33 AM UTC

OK, so I figured out how to make this work:

void MainView::circleClickHandler(const touchgfx::Circle& c, const ClickEvent& evt)
{
 
	if(evt.getType() == touchgfx::ClickEvent::PRESSED){
 
	 if (&c == &headCircle)
	 {..}
}

Thanks for the tip to use the click event type!

-Kneepatch
Osman SOYKURT
ST Technical Moderator
Dec 16, 2022 1:32 PM UTC

Great to hear you succeed ;)

/Osman

ST Software Developer | TouchGFX