 Hello and welcome to this presentation. My name is Bedardin and in this video we will learn how to use the slider widget control of PWM output. I will start by launching .gfx designer give a name to my application stm32 h7be pwm and slider. For the application template I will use the stm32 h7be template for the discovery board. I will go with a blank UI and now I can click on create. Now the application template gets downloaded. Here I have my canvas. I will start by placing background image in the canvas. Pick an image widget and then from image here I will select background image from my hard drive. Next I will place a text widget here and in the text area here I will type in stm32 gfx and the title of today's video how to use the slider widget to control a PDF output. Place it the center here and then I will change the color to something like this. Okay then I place a slider widget click on slider and then close this one. I will go with custom widget no style here I will select no style and then for the background image I will select a background image from my hard drive and place it down here and for the background filled image place another png file here and then for the indicator I will place this knob image and place it down here and center it. Then for the background position for the x I will place it at 14 for the y 14 and then here for the max value I will type in 999 that's the the maximum value we'll use later with the timer and therefore start value and start from a duty cycle of 50% meaning 500 here and then I will go to interactions I'll add an interaction here and the trigger source is whenever this the slider value change and then from the slider I have only one slider and then for the action I'll call newverted function and for the name of the function is set duty cycle okay then I will click on generate code here the code is getting generated and here I have the log of the of the build next I will buy out to the touch gfx files by clicking on browse code down here I have my touch gfx files here and go up by one level here and double click on STM32 h7b IUC file STM32 kubemax opens up here if I go to the clock configuration I see that the timer clock is 140 megahertz and in today's video we'll use timer 5 channel 1 for this schematic we have timer 5 channel 1 connected to page 10 pen and it's very low on a connector 11 of Arduino connector on the STM32 h7b discovery board okay so I'll go ahead with timer 5 channel 1 configuration I go to the timer timer is default timer 5 and then timer 1 I select PWM generation okay see here pH 10 setup as timer 5 channel 1 okay I will set the prescalar to 140 I'll type 140 minus 1 to show that a prescalar value of 139 actually means the clock is divided by 140 so this means that the counter will increment every one microsecond I will set the period counter period to 1000 minus 1 this means the counter will overflow every 1000 ticks or every one millisecond this will give us a timer PWM frequency of 1 kilohertz I will set the pulse value to 500 to start with initial duty cycle of 50% now I'm ready to generate the code and I'll open the project we'll use a new workspace here I have my STM32 Qo by D project open I'll close the information center and expand the project here application user and I'll go to GUI so I'll start by the generated to show you the the virtual function that we create in the gfx designer here so we'll see here where this function was created so if we go to screen one screen one view base and if we go to the header file you will see that the set duty cycle is created here as virtual and we will override it and then scan one dot cpp so we go here screen one view dot cpp and a GUI folder and we'll create a set duty cycle method we'll create the prototype here as virtual void set duty cycle and then we go to the present so from here from the screen view we call the presenter to set the duty cycle of the timer we go to the presenter and from the presenter we call the model to set the duty cycle and we need to call or define the the prototype of the method we do it's a void method okay and now from the model we need to create or call a set duty cycle go to the model and in the model we call or define a new method set duty cycle which calls the hull driver to set the compare value of channel one in time of five so we need to define the method here in the model header file and set it as void here we go back to the model dot cpp here we still need to so that to define the handler for timer five so we it's already defined in main dot c here but we need to make it extra so we go back to the model and we do external handler of timer five we need to call or include stm32 h7 hull dot h and then we need to start the timer we go to main dot c here and then in the timer and it function here we have the initialization code we have the prescalar 140 minus one we have the period 1000 minus one and we have the pulse value this is for the duty cycle and here we will start the timer counter and for that we use the api hull timer start pwm start timer five and then channel one I think that's it I think we can we can build the project click on build here build finished successfully now I'm ready to download the code I click on debug and do remember my decision and then switch to the no perspective okay download verified successfully now I'm ready to start the the execution I click on resume or f8 okay now I will start my salie chase analyzer so I already have my salie connected to the timer I have my salie connected to timer five channel while g6 span and then I'll start the capture so here I see my pwm signal one millisecond period and 500 microsecond for the pulse duration start again I will move the slider to the left we see the pulse value going down decreases and move the slider to the right and then I see other pulse value increases thank you for joining me in this video and we hope that you enjoyed learning how to use the slider widget to control the pwm output