From e6b09473938a85f16569d585b8e9cb3f6311c126 Mon Sep 17 00:00:00 2001 From: yaapu Date: Mon, 19 Sep 2022 12:36:46 +0200 Subject: [PATCH] AP_MSP: move arming status to MSP telemetry base class --- libraries/AP_MSP/AP_MSP_Telem_Backend.cpp | 10 ++++++++++ libraries/AP_MSP/AP_MSP_Telem_Backend.h | 6 ++---- libraries/AP_MSP/AP_MSP_Telem_DJI.cpp | 7 +------ 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/libraries/AP_MSP/AP_MSP_Telem_Backend.cpp b/libraries/AP_MSP/AP_MSP_Telem_Backend.cpp index fe7c485fd9..943ad6318f 100644 --- a/libraries/AP_MSP/AP_MSP_Telem_Backend.cpp +++ b/libraries/AP_MSP/AP_MSP_Telem_Backend.cpp @@ -577,6 +577,16 @@ void AP_MSP_Telem_Backend::msp_handle_airspeed(const MSP::msp_airspeed_data_mess #endif } +uint32_t AP_MSP_Telem_Backend::get_osd_flight_mode_bitmask(void) +{ + // Note: we only set the BOXARM bit (bit 0) which is the same for BF, INAV and DJI VTX + // When armed we simply return 1 (1 == 1 << 0) + if (hal.util->get_soft_armed()) { + return 1U; + } + return 0U; +} + MSPCommandResult AP_MSP_Telem_Backend::msp_process_out_api_version(sbuf_t *dst) { const struct { diff --git a/libraries/AP_MSP/AP_MSP_Telem_Backend.h b/libraries/AP_MSP/AP_MSP_Telem_Backend.h index 88e2ea58c5..8136ecdfd2 100644 --- a/libraries/AP_MSP/AP_MSP_Telem_Backend.h +++ b/libraries/AP_MSP/AP_MSP_Telem_Backend.h @@ -184,11 +184,9 @@ protected: void msp_handle_airspeed(const MSP::msp_airspeed_data_message_t &pkt); // implementation specific helpers + // we only set arming status // custom masks are needed for vendor specific settings - virtual uint32_t get_osd_flight_mode_bitmask(void) - { - return 0; - } + virtual uint32_t get_osd_flight_mode_bitmask(void); virtual bool is_scheduler_enabled() const = 0; // only osd backends should allow a push type telemetry virtual bool use_msp_thread() const {return true;}; // is this backend hanlded by the MSP thread? diff --git a/libraries/AP_MSP/AP_MSP_Telem_DJI.cpp b/libraries/AP_MSP/AP_MSP_Telem_DJI.cpp index 211e05964e..fcb3108c71 100644 --- a/libraries/AP_MSP/AP_MSP_Telem_DJI.cpp +++ b/libraries/AP_MSP/AP_MSP_Telem_DJI.cpp @@ -69,14 +69,9 @@ void AP_MSP_Telem_DJI::hide_osd_items(void) uint32_t AP_MSP_Telem_DJI::get_osd_flight_mode_bitmask(void) { - uint32_t mode_mask = 0; + uint32_t mode_mask = AP_MSP_Telem_Backend::get_osd_flight_mode_bitmask(); const AP_Notify& notify = AP::notify(); - // set arming status - if (notify.flags.armed) { - BIT_SET(mode_mask, DJI_FLAG_ARM); - } - // check failsafe if (notify.flags.failsafe_battery || notify.flags.failsafe_gcs || notify.flags.failsafe_radio || notify.flags.ekf_bad ) { BIT_SET(mode_mask, DJI_FLAG_FS);