From cf27ba09d006752b79862a5de3e53a59d9b4ff60 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Thu, 19 Sep 2024 12:25:23 +1000 Subject: [PATCH] AP_IOMCU: use RC_Channel to populate IOMCU mappings --- libraries/AP_IOMCU/AP_IOMCU.cpp | 23 +++++++++++++---------- libraries/AP_IOMCU/AP_IOMCU.h | 3 +-- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/libraries/AP_IOMCU/AP_IOMCU.cpp b/libraries/AP_IOMCU/AP_IOMCU.cpp index 77617cdb02..e1c6f5d863 100644 --- a/libraries/AP_IOMCU/AP_IOMCU.cpp +++ b/libraries/AP_IOMCU/AP_IOMCU.cpp @@ -1208,7 +1208,7 @@ void AP_IOMCU::bind_dsm(uint8_t mode) setup for mixing. This allows fixed wing aircraft to fly in manual mode if the FMU dies */ -bool AP_IOMCU::setup_mixing(RCMapper *rcmap, int8_t override_chan, +bool AP_IOMCU::setup_mixing(int8_t override_chan, float mixing_gain, uint16_t manual_rc_mask) { if (!is_chibios_backend) { @@ -1229,16 +1229,19 @@ bool AP_IOMCU::setup_mixing(RCMapper *rcmap, int8_t override_chan, MIX_UPDATE(mixing.servo_function[i], c->get_function()); MIX_UPDATE(mixing.servo_reversed[i], c->get_reversed()); } - // update RCMap - MIX_UPDATE(mixing.rc_channel[0], rcmap->roll()); - MIX_UPDATE(mixing.rc_channel[1], rcmap->pitch()); - MIX_UPDATE(mixing.rc_channel[2], rcmap->throttle()); - MIX_UPDATE(mixing.rc_channel[3], rcmap->yaw()); + auto &xrc = rc(); + // note that if not all of these channels are specified correctly + // in parameters then these may be a "dummy" RC channel pointer. + // In that case c->ch() will be zero. + const RC_Channel *channels[] { + &xrc.get_roll_channel(), + &xrc.get_pitch_channel(), + &xrc.get_throttle_channel(), + &xrc.get_yaw_channel() + }; for (uint8_t i=0; i<4; i++) { - const RC_Channel *c = RC_Channels::rc_channel(mixing.rc_channel[i]-1); - if (!c) { - continue; - } + const auto *c = channels[i]; + MIX_UPDATE(mixing.rc_channel[i], c->ch()); MIX_UPDATE(mixing.rc_min[i], c->get_radio_min()); MIX_UPDATE(mixing.rc_max[i], c->get_radio_max()); MIX_UPDATE(mixing.rc_trim[i], c->get_radio_trim()); diff --git a/libraries/AP_IOMCU/AP_IOMCU.h b/libraries/AP_IOMCU/AP_IOMCU.h index 1d03debb9a..da6d55a03d 100644 --- a/libraries/AP_IOMCU/AP_IOMCU.h +++ b/libraries/AP_IOMCU/AP_IOMCU.h @@ -11,7 +11,6 @@ #if HAL_WITH_IO_MCU #include "iofirmware/ioprotocol.h" -#include #include #include @@ -151,7 +150,7 @@ public: void soft_reboot(); // setup for FMU failsafe mixing - bool setup_mixing(RCMapper *rcmap, int8_t override_chan, + bool setup_mixing(int8_t override_chan, float mixing_gain, uint16_t manual_rc_mask); // Check if pin number is valid and configured for GPIO