Skip to content

Commit

Permalink
Plane: Update airbrake channel assignment in set_control_channels() t…
Browse files Browse the repository at this point in the history
…o avoid expensive call in airbrake_update()
  • Loading branch information
samuelctabor authored and magicrub committed Sep 2, 2020
1 parent f1290a2 commit 590ebb1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions ArduPlane/Plane.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ class Plane : public AP_Vehicle {
RC_Channel *channel_pitch;
RC_Channel *channel_throttle;
RC_Channel *channel_rudder;
RC_Channel *channel_airbrake;

AP_Logger logger;

Expand Down
3 changes: 3 additions & 0 deletions ArduPlane/radio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ void Plane::set_control_channels(void)
SRV_Channels::set_angle(SRV_Channel::k_throttleRight, 100);
}

// update airbrake channel assignment
channel_airbrake = rc().find_channel_for_option(RC_Channel::AUX_FUNC::AIRBRAKE);

// update manual forward throttle channel assignment
quadplane.rc_fwd_thr_ch = rc().find_channel_for_option(RC_Channel::AUX_FUNC::FWD_THR);

Expand Down
8 changes: 3 additions & 5 deletions ArduPlane/servos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,11 +296,9 @@ void Plane::airbrake_update(void)
{
// Calculate any manual airbrake input from RC channel option.
int8_t manual_airbrake_percent = 0;

RC_Channel *airbrake_in_ch = rc().find_channel_for_option(RC_Channel::AUX_FUNC::AIRBRAKE);

if (airbrake_in_ch != nullptr && !failsafe.rc_failsafe && failsafe.throttle_counter == 0) {
manual_airbrake_percent = airbrake_in_ch->percent_input();

if (channel_airbrake != nullptr && !failsafe.rc_failsafe && failsafe.throttle_counter == 0) {
manual_airbrake_percent = channel_airbrake->percent_input();
}

// Calculate auto airbrake from negative throttle.
Expand Down

0 comments on commit 590ebb1

Please sign in to comment.