2019-06-18 15:28:39 -03:00
|
|
|
#include "Tracker.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* GCS controlled servo test mode
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2019-09-13 12:41:55 -03:00
|
|
|
* set_servo - sets the yaw or pitch servo pwm directly
|
2019-06-18 15:28:39 -03:00
|
|
|
* servo_num are 1 for yaw, 2 for pitch
|
|
|
|
*/
|
2019-09-13 12:41:55 -03:00
|
|
|
bool ModeServoTest::set_servo(uint8_t servo_num, uint16_t pwm)
|
2019-06-18 15:28:39 -03:00
|
|
|
{
|
|
|
|
// 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;
|
|
|
|
}
|