Skip to content

Commit

Permalink
ArduPlane: add inflight airspeed cal rc switch
Browse files Browse the repository at this point in the history
  • Loading branch information
Hwurzburg authored and peterbarker committed Nov 25, 2020
1 parent f37d8e5 commit 3cdcce2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ArduPlane/ArduPlane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ const AP_Scheduler::Task Plane::scheduler_tasks[] = {
SCHED_TASK(one_second_loop, 1, 400),
SCHED_TASK(check_long_failsafe, 3, 400),
SCHED_TASK(rpm_update, 10, 100),
#if AP_AIRSPEED_AUTOCAL_ENABLE
SCHED_TASK(airspeed_ratio_update, 1, 100),
#endif // AP_AIRSPEED_AUTOCAL_ENABLE
#if HAL_MOUNT_ENABLED
SCHED_TASK_CLASS(AP_Mount, &plane.camera_mount, update, 50, 100),
#endif // HAL_MOUNT_ENABLED
Expand Down Expand Up @@ -318,6 +320,7 @@ void Plane::efi_update(void)
#endif
}

#if AP_AIRSPEED_AUTOCAL_ENABLE
/*
once a second update the airspeed calibration ratio
*/
Expand Down Expand Up @@ -346,7 +349,7 @@ void Plane::airspeed_ratio_update(void)
const Vector3f &vg = gps.velocity();
airspeed.update_calibration(vg, aparm.airspeed_max);
}

#endif // AP_AIRSPEED_AUTOCAL_ENABLE

/*
read the GPS and update position
Expand Down
2 changes: 2 additions & 0 deletions ArduPlane/Plane.h
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,9 @@ class Plane : public AP_Vehicle {
void afs_fs_check(void);
#endif
void one_second_loop(void);
#if AP_AIRSPEED_AUTOCAL_ENABLE
void airspeed_ratio_update(void);
#endif
void compass_save(void);
void update_logging1(void);
void update_logging2(void);
Expand Down
18 changes: 18 additions & 0 deletions ArduPlane/RC_Channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ void RC_Channel_Plane::init_aux_function(const RC_Channel::aux_func_t ch_option,
case AUX_FUNC::Q_ASSIST:
case AUX_FUNC::SOARING:
case AUX_FUNC::AIRMODE:
#if AP_AIRSPEED_AUTOCAL_ENABLE
case AUX_FUNC::ARSPD_CALIBRATE:
#endif
do_aux_function(ch_option, ch_flag);
break;

Expand Down Expand Up @@ -277,6 +280,21 @@ void RC_Channel_Plane::do_aux_function(const aux_func_t ch_option, const AuxSwit
}
break;

case AUX_FUNC::ARSPD_CALIBRATE:
#if AP_AIRSPEED_AUTOCAL_ENABLE
switch (ch_flag) {
case AuxSwitchPos::HIGH:
plane.airspeed.set_calibration_enabled(true);
break;
case AuxSwitchPos::MIDDLE:
break;
case AuxSwitchPos::LOW:
plane.airspeed.set_calibration_enabled(false);
break;
}
#endif
break;

case AUX_FUNC::LANDING_FLARE:
do_aux_function_flare(ch_flag);
break;
Expand Down

0 comments on commit 3cdcce2

Please sign in to comment.