forked from ArduPilot/ardupilot
-
Notifications
You must be signed in to change notification settings - Fork 25
/
mode_servotest.cpp
38 lines (31 loc) · 998 Bytes
/
mode_servotest.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include "Tracker.h"
/*
* GCS controlled servo test mode
*/
/*
* set_servo - sets the yaw or pitch servo pwm directly
* servo_num are 1 for yaw, 2 for pitch
*/
bool ModeServoTest::set_servo(uint8_t servo_num, uint16_t pwm)
{
// convert servo_num from 1~2 to 0~1 range
servo_num--;
// exit immediately if servo_num is invalid
if (servo_num != CH_YAW && servo_num != CH_PITCH) {
return false;
}
// set yaw servo pwm and send output to servo
if (servo_num == CH_YAW) {
SRV_Channels::set_output_pwm(SRV_Channel::k_tracker_yaw, pwm);
SRV_Channels::constrain_pwm(SRV_Channel::k_tracker_yaw);
}
// set pitch servo pwm and send output to servo
if (servo_num == CH_PITCH) {
SRV_Channels::set_output_pwm(SRV_Channel::k_tracker_pitch, pwm);
SRV_Channels::constrain_pwm(SRV_Channel::k_tracker_pitch);
}
SRV_Channels::calc_pwm();
SRV_Channels::output_ch_all();
// return success
return true;
}