TP du Voilier de 4A IR SI
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

MyVoile.c 442B

1234567891011121314151617181920212223242526
  1. #include "MyVoile.h"
  2. void MyVoile_Init(){
  3. MyTimer_Struct_TypeDef Tim_Conf_Servo = {
  4. TIM4,
  5. 1199,
  6. 1199
  7. };
  8. MyTimer_Base_Init(&Tim_Conf_Servo);
  9. MyTimer_PWM(TIM4,3);
  10. MyTimer_Base_Start(TIM4);
  11. }
  12. void Set_Voile(uint16_t angle){
  13. float k;
  14. if(angle < 180.0){
  15. k = (0.1- angle*M);
  16. Set_Duty_Cycle(TIM4,3,k*Get_Max_Duty(TIM4));
  17. }else{
  18. k = (0.1 - (360.0 - angle)*M);
  19. Set_Duty_Cycle(TIM4,3,k*Get_Max_Duty(TIM4));
  20. }
  21. }