cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F746G-DISCO, TouchGFX, STM32CubeIDE, FreeRTOS, engine control

AD�?b
Senior

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

15 REPLIES 15
N. SANTINI
ST Employee

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

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

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

Where is the source code for Button and AbstractButton?

Andrzej

Karan 123
Senior

Hi,

AD�?b (Community Member)

Apart from that, you can able look at pre-build demo in TouchGFX

0693W000001cIQHQA2.png

Hope the helps.

--

karan

touchgfx/widgets

Hey!

Thank you. I modified the concept a little.

It will be better to use the toggle buttons.

Now I have another problem.

I want to prevent the screen from changing (BACK) when OFF / ON and UP is selected.

By sending the file ".. Base.cpp"

Andrzej

Hi,

Are you doing changes in ScreenWorkViewBase.cpp ?

Please visualize your problem .

--

Karan

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