2015-06-01 02:04:25 -03:00
|
|
|
#include "Tracker.h"
|
|
|
|
|
2014-10-06 08:45:07 -03:00
|
|
|
/*
|
2016-07-25 15:52:50 -03:00
|
|
|
* GCS controlled servo test mode
|
2014-10-06 08:45:07 -03:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* servo_test_set_servo - sets the yaw or pitch servo pwm directly
|
|
|
|
* servo_num are 1 for yaw, 2 for pitch
|
|
|
|
*/
|
2015-06-01 02:04:25 -03:00
|
|
|
bool Tracker::servo_test_set_servo(uint8_t servo_num, uint16_t pwm)
|
2014-10-06 08:45:07 -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;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ensure we are in servo test mode
|
|
|
|
if (control_mode != SERVO_TEST) {
|
|
|
|
set_mode(SERVO_TEST);
|
|
|
|
}
|
|
|
|
|
|
|
|
// set yaw servo pwm and send output to servo
|
|
|
|
if (servo_num == CH_YAW) {
|
2017-01-08 18:30:37 -04:00
|
|
|
SRV_Channels::set_output_pwm(SRV_Channel::k_tracker_yaw, pwm);
|
|
|
|
SRV_Channels::constrain_pwm(SRV_Channel::k_tracker_yaw);
|
2014-10-06 08:45:07 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
// set pitch servo pwm and send output to servo
|
|
|
|
if (servo_num == CH_PITCH) {
|
2017-01-08 18:30:37 -04:00
|
|
|
SRV_Channels::set_output_pwm(SRV_Channel::k_tracker_pitch, pwm);
|
|
|
|
SRV_Channels::constrain_pwm(SRV_Channel::k_tracker_pitch);
|
2014-10-06 08:45:07 -03:00
|
|
|
}
|
|
|
|
|
2017-01-06 22:51:56 -04:00
|
|
|
SRV_Channels::calc_pwm();
|
|
|
|
SRV_Channels::output_ch_all();
|
|
|
|
|
2014-10-06 08:45:07 -03:00
|
|
|
// return success
|
|
|
|
return true;
|
|
|
|
}
|