From ff66741d2cba8aec136b9a33ce06e8e2e4b651e8 Mon Sep 17 00:00:00 2001 From: Yury MonZon Date: Mon, 9 Dec 2024 21:42:57 +0100 Subject: [PATCH] AP_Tuning: Update OSD on 5 percent change --- libraries/AP_Tuning/AP_Tuning.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/libraries/AP_Tuning/AP_Tuning.cpp b/libraries/AP_Tuning/AP_Tuning.cpp index 8b0c6f7fde922..87bbf15a13e8c 100644 --- a/libraries/AP_Tuning/AP_Tuning.cpp +++ b/libraries/AP_Tuning/AP_Tuning.cpp @@ -218,6 +218,7 @@ void AP_Tuning::check_input(uint8_t flightmode) last_channel_value = chan_value; float new_value; + static float old_value; if (chan_value > 0) { new_value = linear_interpolate(center_value, range*center_value, chan_value, 0, 1); } else { @@ -227,11 +228,14 @@ void AP_Tuning::check_input(uint8_t flightmode) need_revert |= (1U << current_parm_index); set_value(current_parm, new_value); - GCS_SEND_TEXT(MAV_SEVERITY_INFO, - "Tuning %s%s%0.5f", - get_tuning_name(current_parm), - ((chan_value < dead_zone) && (chan_value > -dead_zone)) ? "> " : ": ", - (double)(new_value)); + if ( fabsf(new_value-old_value) > (0.05 * old_value) ) { + old_value = new_value; + GCS_SEND_TEXT(MAV_SEVERITY_INFO, + "Tuning %s%s%0.4f", + get_tuning_name(current_parm), + ((chan_value < dead_zone) && (chan_value > -dead_zone)) ? "> " : ": ", + (double)(new_value)); + } #if HAL_LOGGING_ENABLED Log_Write_Parameter_Tuning(new_value);