Skip to main content
AD�?b
Senior
February 20, 2020
Question

STM32F746G-DISCO, Button

  • February 20, 2020
  • 13 replies
  • 2565 views

How can I disable the TRIGGER / Click button by switching the TRIGGER / Toggle button?

This topic has been closed for replies.

13 replies

Karl Yamashita
Principal
February 20, 2020

I believe it's setTouchable() for a regular button

For example to disable the touch on a toggle button

toggleButton1.setTouchable(false);

If a reply has proven helpful, click on Accept as Solution so that it'll show at top of the post.CAN Jammer an open source CAN bus hacking toolCANableV3 Open Source
AD�?b
AD�?bAuthor
Senior
February 21, 2020

Hello thank you!

I have a "ButtonOffOn" toggle button. I have a "ButtonNext" button that changes the screen. I want the button "ButtonNext" to be locked while the "ButtonOffOn" button is switched on until the "ButtonOffOn" button is switched again.

I checked your suggestion but disables the "ButtonOffOn" button.

"ButtonOffOn" = On -> "ButtonNext" closed

"ButtonOffOn" = Off -> "ButtonNext" is active

How to do it?

Romain DIELEMAN
ST Employee
February 21, 2020

I suppose you could do something like this: in Designer you create 2 interactions. The first one calls a new function when the button "ButtonNext" is clicked. The other interaction changes the screen when an hardware button is clicked. This is a fake button we use in order to generate the go to screen 2 transition function and use it in our code.0690X00000DC603QAD.png

Then I added this in Screen1View.cpp

void Screen1View::functionNextOrStay()
{
 if (ButtonOnOff.getState() == TRUE) // getState returns TRUE when On 
 {
 application().gotoScreen2ScreenNoTransition();
 }
}

Tell me if this enough for what you need, I did not need to use setTouchable() since it does not influence the result.

0690X00000DC63qQAD.gif

/Romain

Karl Yamashita
Principal
February 21, 2020

I made a quick tutorial for what you want now that i know exactly what you're trying to do. https://youtu.be/CSQkVLIN22k

There is a link to another video i made before for those who are interested. The toggle button on screen1 disables a button on screen2.

If a reply has proven helpful, click on Accept as Solution so that it'll show at top of the post.CAN Jammer an open source CAN bus hacking toolCANableV3 Open Source
AD�?b
AD�?bAuthor
Senior
February 21, 2020

Hi Karl!

Yes, this is it. I still have to check how it will work when the OFF / ON button is Flex Button.

Karl Yamashita
Principal
February 21, 2020

Well a flex button doesn't have a on/off state but you can still trigger off that button. So for that flex button, the C++ code will check the current touchable state of the buttonNext and toggle the touchable state to the opposite.

if(buttonNext.isTouchable() == true)
{
 buttonNext.setTouchable(false);
 buttonNext.setLabelColor(touchgfx::Color::getColorFrom24BitRGB(255,0,0));
 buttonNext.setLabelColorPressed(touchgfx::Color::getColorFrom24BitRGB(255,0,0));
 buttonNext.invalidate();
}
else
{
 buttonNext.setTouchable(true);
 buttonNext.setLabelColor(touchgfx::Color::getColorFrom24BitRGB(255,255,255));
 buttonNext.setLabelColorPressed(touchgfx::Color::getColorFrom24BitRGB(255,255,255));
 buttonNext.invalidate();
}

If a reply has proven helpful, click on Accept as Solution so that it'll show at top of the post.CAN Jammer an open source CAN bus hacking toolCANableV3 Open Source
Karl Yamashita
Principal
February 24, 2020

Hi AD,

I'm having a hard time understanding what you're trying to ask for? Maybe rephrase it again?

I think i got the first paragraph. You have an image of an engine that rotates while the button is pressed and when the button is released the image of the engine stops rotating. Is that correct? I have no idea what you mean in the second paragraph.

If a reply has proven helpful, click on Accept as Solution so that it'll show at top of the post.CAN Jammer an open source CAN bus hacking toolCANableV3 Open Source
AD�?b
AD�?bAuthor
Senior
February 24, 2020

What you wrote is OK.

In the second paragraph I wrote as I did now. I don't want to.