From f1eee860c0afa50d6f94a50b50c0b3d8f614794a Mon Sep 17 00:00:00 2001 From: Andy Piper Date: Tue, 9 Mar 2021 19:35:34 +0000 Subject: [PATCH] AP_RCTelemetry: don't process VTX frames when VTX support is disabled --- libraries/AP_RCTelemetry/AP_CRSF_Telem.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/libraries/AP_RCTelemetry/AP_CRSF_Telem.cpp b/libraries/AP_RCTelemetry/AP_CRSF_Telem.cpp index ea14a1d7b9..68b768663b 100644 --- a/libraries/AP_RCTelemetry/AP_CRSF_Telem.cpp +++ b/libraries/AP_RCTelemetry/AP_CRSF_Telem.cpp @@ -392,7 +392,12 @@ void AP_CRSF_Telem::process_vtx_frame(VTXFrame* vtx) { vtx->is_in_pitmode, vtx->power, vtx->pitmode); AP_VideoTX& apvtx = AP::vtx(); - apvtx.set_enabled(vtx->is_vtx_available); + // the user may have a VTX connected but not want AP to control it + // (for instance because they are using myVTX on the transmitter) + if (!apvtx.get_enabled()) { + return; + } + apvtx.set_band(vtx->band); apvtx.set_channel(vtx->channel); if (vtx->is_in_user_frequency_mode) { @@ -428,12 +433,17 @@ void AP_CRSF_Telem::process_vtx_frame(VTXFrame* vtx) { _vtx_power_change_pending = _vtx_freq_change_pending = _vtx_options_change_pending = false; } -void AP_CRSF_Telem::process_vtx_telem_frame(VTXTelemetryFrame* vtx) { +void AP_CRSF_Telem::process_vtx_telem_frame(VTXTelemetryFrame* vtx) +{ vtx->frequency = be16toh(vtx->frequency); debug("VTXTelemetry: Freq: %d, PitMode: %d, Power: %d", vtx->frequency, vtx->pitmode, vtx->power); AP_VideoTX& apvtx = AP::vtx(); + if (!apvtx.get_enabled()) { + return; + } + apvtx.set_frequency_mhz(vtx->frequency); AP_VideoTX::VideoBand band; @@ -550,6 +560,10 @@ void AP_CRSF_Telem::update_vtx_params() { AP_VideoTX& vtx = AP::vtx(); + if (!vtx.get_enabled()) { + return; + } + _vtx_freq_change_pending = vtx.update_band() || vtx.update_channel() || vtx.update_frequency() || _vtx_freq_change_pending; _vtx_power_change_pending = vtx.update_power() || _vtx_power_change_pending; _vtx_options_change_pending = vtx.update_options() || _vtx_options_change_pending;