AP_MSP: move arming status to MSP telemetry base class

This commit is contained in:
yaapu 2022-09-19 12:36:46 +02:00 committed by Andrew Tridgell
parent 25e0edc54b
commit 5cad520acf
3 changed files with 13 additions and 10 deletions

View File

@ -577,6 +577,16 @@ void AP_MSP_Telem_Backend::msp_handle_airspeed(const MSP::msp_airspeed_data_mess
#endif #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) MSPCommandResult AP_MSP_Telem_Backend::msp_process_out_api_version(sbuf_t *dst)
{ {
const struct { const struct {

View File

@ -184,11 +184,9 @@ protected:
void msp_handle_airspeed(const MSP::msp_airspeed_data_message_t &pkt); void msp_handle_airspeed(const MSP::msp_airspeed_data_message_t &pkt);
// implementation specific helpers // implementation specific helpers
// we only set arming status
// custom masks are needed for vendor specific settings // custom masks are needed for vendor specific settings
virtual uint32_t get_osd_flight_mode_bitmask(void) virtual uint32_t get_osd_flight_mode_bitmask(void);
{
return 0;
}
virtual bool is_scheduler_enabled() const = 0; // only osd backends should allow a push type telemetry 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? virtual bool use_msp_thread() const {return true;}; // is this backend hanlded by the MSP thread?

View File

@ -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 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(); const AP_Notify& notify = AP::notify();
// set arming status
if (notify.flags.armed) {
BIT_SET(mode_mask, DJI_FLAG_ARM);
}
// check failsafe // check failsafe
if (notify.flags.failsafe_battery || notify.flags.failsafe_gcs || notify.flags.failsafe_radio || notify.flags.ekf_bad ) { if (notify.flags.failsafe_battery || notify.flags.failsafe_gcs || notify.flags.failsafe_radio || notify.flags.ekf_bad ) {
BIT_SET(mode_mask, DJI_FLAG_FS); BIT_SET(mode_mask, DJI_FLAG_FS);