Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
sm_servo.cpp
- Committer:
- GaspardD
- Date:
- 2019-09-29
- Revision:
- 3:1b7eb426247e
- Parent:
- 2:e9d928fd327a
- Child:
- 4:efa207509f63
File content as of revision 3:1b7eb426247e:
#include "sm_servo.h"
PwmOut pwm_Servo(PE_9);
E_STATE_SERVO e_stateServo;
bool directionCheck = false;
void init_sm_servo()
{
e_stateServo = SERVO_INIT;
}
void update_sm_servo()
{
E_STATE_SERVO next_state = e_stateServo;
switch(e_stateServo) {
case SERVO_INIT:
if(directionCheck) {
next_state = SERVO_COMMAND;
}
break;
case SERVO_COMMAND:
break;
default:
break;
}
e_stateServo = next_state;
return;
}
void output_sm_servo()
{
switch(e_stateServo) {
case SERVO_INIT:
wait(1);
pc.printf("init servo with pulse %d us\n",SERVO_PULSE_MIDDLE_US);
pwm_Servo.period_ms(SERVO_PERIOD_DURATION_MS);
pwm_Servo.pulsewidth_us(SERVO_PULSE_MIDDLE_US);
wait(1);
pc.printf("send pulse 1600 to servo\n");
pwm_Servo.pulsewidth_us(1600);
wait(1);
pc.printf("send pulse 1300 to servo\n");
pwm_Servo.pulsewidth_us(1300);
wait(1);
pc.printf("send pulse 1500 to servo\n");
pwm_Servo.pulsewidth_us(1500);
wait(1);
directionCheck = true;
break;
case SERVO_COMMAND:
break;
default:
break;
}
return;
}