From 4dac9baa0950f22c5ac5be0390edfd5204b9d4a3 Mon Sep 17 00:00:00 2001 From: giacomo892 Date: Thu, 27 May 2021 17:47:27 +0200 Subject: [PATCH] AP_SmartAudio: Add configuration_finished and configuration_pending functions --- libraries/AP_VideoTX/AP_SmartAudio.cpp | 13 +++++++++---- libraries/AP_VideoTX/AP_SmartAudio.h | 5 ++++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/libraries/AP_VideoTX/AP_SmartAudio.cpp b/libraries/AP_VideoTX/AP_SmartAudio.cpp index f7a6e2ab47..88c6a58a5a 100644 --- a/libraries/AP_VideoTX/AP_SmartAudio.cpp +++ b/libraries/AP_VideoTX/AP_SmartAudio.cpp @@ -68,6 +68,8 @@ bool AP_SmartAudio::init() void AP_SmartAudio::loop() { + AP_VideoTX &vtx = AP::vtx(); + while (!hal.scheduler->is_system_initialized()) { hal.scheduler->delay(100); } @@ -141,13 +143,15 @@ void AP_SmartAudio::loop() if (AP::vtx().have_params_changed() ||_vtx_power_change_pending || _vtx_freq_change_pending || _vtx_options_change_pending) { update_vtx_params(); - _vtx_gcs_pending = true; + set_configuration_pending(true); + vtx.set_configuration_finished(false); // we've tried to udpate something, re-request the settings so that they // are reflected correctly request_settings(); - } else if (_vtx_gcs_pending) { + } else if (is_configuration_pending()) { AP::vtx().announce_vtx_settings(); - _vtx_gcs_pending = false; + set_configuration_pending(false); + vtx.set_configuration_finished(true); } } } @@ -237,9 +241,10 @@ void AP_SmartAudio::update_vtx_params() break; } } + } else { + vtx.set_configuration_finished(true); } } - /** * Sends an SmartAudio Command to the vtx, waits response on the update event * @param frameBuffer frameBuffer to send over the wire diff --git a/libraries/AP_VideoTX/AP_SmartAudio.h b/libraries/AP_VideoTX/AP_SmartAudio.h index 690a41448e..9c9966932d 100644 --- a/libraries/AP_VideoTX/AP_SmartAudio.h +++ b/libraries/AP_VideoTX/AP_SmartAudio.h @@ -191,7 +191,7 @@ private: bool _vtx_freq_change_pending; // a vtx command has been issued but not confirmed by a vtx broadcast frame bool _vtx_power_change_pending; bool _vtx_options_change_pending; - bool _vtx_gcs_pending; + bool _vtx_changes_pending; bool _vtx_use_set_freq; // should frequency set by band/channel or frequency // value for current baud adjust @@ -265,5 +265,8 @@ private: // change baud automatically when request-response fails many times void update_baud_rate(); + + void set_configuration_pending(bool pending) { _vtx_changes_pending = pending; } + bool is_configuration_pending(){ return _vtx_changes_pending;} }; #endif