cancel
Showing results for 
Search instead for 
Did you mean: 

Controlling PWM from UI with TouchGFX

scope_nh
Associate

I want to control a servo motor with the PWM and I want to have a slider on the GUI to control the position of the servo motor, 
So I created a TouchGFX project added the slider and the intraction to a virtual function and I generated the code 
I opened the project in the STM32CubeIDE folder and I configured the pin 
and I created a header and a source file to develop all the necessary functions to control the servo moto (ie: Init, update of frequency...) 

When I go back to the TouchGFX Designer to upload the code, I this error that the file is not found 

 

TouchGFX/gui/src/screen1_screen/Screen1View.cpp:4:10: fatal error: PWMSer.h: No such file or directory
#include "PWMSer.h"
^~~~~~~~~~
compilation terminated.

my question : how to properly add folders and source files to such project ? and if I am doing is the wrong way please show me the correct way to do it.

1 ACCEPTED SOLUTION

Accepted Solutions
Karl Yamashita
Principal

It depends on how you've created the header and source file.

If you've right clicked, lets say the Core folder in the Project tree and clicked New>Source file, then the file(s) are added to the Root>STM32CubeIDE>User>Core folder. But the IDE doesn't have the path to that folder.

However, the IDE path is actually pointing to Root>Core>Src folder. 

 

So the easiest thing to do is to move those new files to the Root>Core>Src/Inc folders respectfully.

Then in Windows Explorer, drag and drop the files to the your project tree and Link the files. And all the existing header files that aren't showing in the Project Tree, you can drag and drop those as well so they also show in the Project Tree.

Don't worry, I won't byte.
TimerCallback tutorial! | UART and DMA Idle tutorial!

If you find my solution useful, please click the Accept as Solution so others see the solution.

View solution in original post

2 REPLIES 2
Karl Yamashita
Principal

It depends on how you've created the header and source file.

If you've right clicked, lets say the Core folder in the Project tree and clicked New>Source file, then the file(s) are added to the Root>STM32CubeIDE>User>Core folder. But the IDE doesn't have the path to that folder.

However, the IDE path is actually pointing to Root>Core>Src folder. 

 

So the easiest thing to do is to move those new files to the Root>Core>Src/Inc folders respectfully.

Then in Windows Explorer, drag and drop the files to the your project tree and Link the files. And all the existing header files that aren't showing in the Project Tree, you can drag and drop those as well so they also show in the Project Tree.

Don't worry, I won't byte.
TimerCallback tutorial! | UART and DMA Idle tutorial!

If you find my solution useful, please click the Accept as Solution so others see the solution.
GaetanGodart
ST Employee

Hello @scope_nh ,

 

You could include your PWMSer.h or main.h in the Model.cpp to have access to the variables located in PWMSer.c or main.c.

Then all you have to do is to send your slider value from your screen to Model.cpp.

 

Regards,

Gaetan Godart
Software engineer at ST (TouchGFX)