AP_HAL_ChibiOS: added NxtPX4v2
[ardupilot.git] / AntennaTracker / mode_servotest.cpp
blob06b77a956c0b91b3846e8b0e4c4faec0d6e8a78a
1 #include "Tracker.h"
3 /*
4 * GCS controlled servo test mode
5 */
7 /*
8 * set_servo - sets the yaw or pitch servo pwm directly
9 * servo_num are 1 for yaw, 2 for pitch
11 bool ModeServoTest::set_servo(uint8_t servo_num, uint16_t pwm)
13 // convert servo_num from 1~2 to 0~1 range
14 servo_num--;
16 // exit immediately if servo_num is invalid
17 if (servo_num != CH_YAW && servo_num != CH_PITCH) {
18 return false;
21 // set yaw servo pwm and send output to servo
22 if (servo_num == CH_YAW) {
23 SRV_Channels::set_output_pwm(SRV_Channel::k_tracker_yaw, pwm);
24 SRV_Channels::constrain_pwm(SRV_Channel::k_tracker_yaw);
27 // set pitch servo pwm and send output to servo
28 if (servo_num == CH_PITCH) {
29 SRV_Channels::set_output_pwm(SRV_Channel::k_tracker_pitch, pwm);
30 SRV_Channels::constrain_pwm(SRV_Channel::k_tracker_pitch);
33 SRV_Channels::calc_pwm();
34 SRV_Channels::output_ch_all();
36 // return success
37 return true;