26 lines
442 B
C
26 lines
442 B
C
#include "MyVoile.h"
|
|
|
|
|
|
void MyVoile_Init(){
|
|
MyTimer_Struct_TypeDef Tim_Conf_Servo = {
|
|
TIM4,
|
|
1199,
|
|
1199
|
|
};
|
|
MyTimer_Base_Init(&Tim_Conf_Servo);
|
|
MyTimer_PWM(TIM4,3);
|
|
MyTimer_Base_Start(TIM4);
|
|
}
|
|
|
|
void Set_Voile(uint16_t angle){
|
|
float k;
|
|
if(angle < 180.0){
|
|
k = (0.1- angle*M);
|
|
Set_Duty_Cycle(TIM4,3,k*Get_Max_Duty(TIM4));
|
|
}else{
|
|
k = (0.1 - (360.0 - angle)*M);
|
|
Set_Duty_Cycle(TIM4,3,k*Get_Max_Duty(TIM4));
|
|
}
|
|
}
|
|
|
|
|