2020-05-13 04:25 AM
Hi!
I have to start / stop the engine with one button. How to set the button in TouchGFX? What program to add in View, Presenter and Model?
Andrzej
2020-05-13 08:19 AM
Hi,
Here is a project I created for F746G-Disco using the TouchGFX Designer that contains a way to implement a button that will call a C routine defined in main.c to turn on or off the engine using low-level functions.
It contains a button with an interaction (set in the designer) that call toggleEngine() method.
Following the MVP approach the presenter then call a toggleEngine() function that will finally call the system C function mentioned above.
Once called the Model will then propagate the result of this function back to the presenter to signal the engine status change.
Finally the presenter will signal the view (responsible of the actual screen layout) and the button and below text will be udpated.
All the modifications are done in the "gui" folder files, "generated" folder files are read-only.
You may launch the simulator directly from the TouchGFX Designer project STM32F746Disco_StartEngine\TouchGFX\STM32F746Disco_StartEngine.touchgfx and then open the CubeIDE project from STM32F746Disco_StartEngine\STM32CubeIDE.
I then invite you to follow the flow from the Screen1Presenter::toggleEngine() method that is called when the button is pressed (Screen1Presenter.cpp file).
Of course this is only a proposed implementation to explain practically how to achieve your goal you need to adapt it to your need and contraints.
Best regards,
Nicolas
2020-05-13 10:56 AM
Hey!
Thank you. Tomorrow I will graduate thoroughly.
Can this be done so that the engine is turned on only for the time of touch? When the touch is gone, the engine is to be turned off.
Best regards
Andrzej
2020-05-14 03:59 AM
Yes, you can create a "long press" type button with a custom handler that does this. Take a look at the source code for Button and AbstractButton for inspiration. Hint: Instead of sending a callback on pressed or released you want to send one for both events - so a sort of parameterized button handler that tells the engine to turn on or off)
/Martin
2020-05-14 07:41 AM
Where is the source code for Button and AbstractButton?
Andrzej
2020-05-14 12:39 PM
Hi,
AD�?b (Community Member)
Apart from that, you can able look at pre-build demo in TouchGFX
Hope the helps.
--
karan
2020-05-14 01:14 PM
touchgfx/widgets
2020-05-15 07:02 AM
2020-05-15 10:18 AM
Hi,
Are you doing changes in ScreenWorkViewBase.cpp ?
Please visualize your problem .
--
Karan
2020-05-15 10:37 AM
Hi!
I do not want to change in this file. He is generated by TouchGFX.
In TouchGFX Designer in "Execute C ++ code" I set Intereaction (ScreenWork). I want if ButtonOffOn and at the same time ButtonUp are enabled the screen did not switch with the BACK button.
Uploads a TouchGFX Designer file.
Andrzej