From c1408af000613b8373c745016129bff80faabc9f Mon Sep 17 00:00:00 2001 From: Ramakrishnan Muthukrishnan Date: Sun, 21 Aug 2022 15:28:43 +0530 Subject: [PATCH] save/restore nb menu values --- nb_menu.c | 8 ++++---- radio.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/nb_menu.c b/nb_menu.c index d5d100a..1aa0918 100644 --- a/nb_menu.c +++ b/nb_menu.c @@ -34,10 +34,10 @@ static GtkWidget *menu_b = NULL; static GtkWidget *dialog = NULL; // all the time are in ms -double nb_lag_time = 0.01; -double nb_lead_time = 0.01; -double nb_transition_time = 0.01; -double nb_threshold_value = 20.0; +double nb_lag_time = 0.001; +double nb_lead_time = 0.001; +double nb_transition_time = 0.001; +double nb_threshold_value = 18.0; void nb_changed() { SetEXTANBHangtime(0, nb_lag_time); diff --git a/radio.c b/radio.c index 1a6dc23..1dc6dd0 100644 --- a/radio.c +++ b/radio.c @@ -133,6 +133,12 @@ static GtkWidget *audio_waterfall; // RX and TX calibration long long calibration = 0LL; +// nb values defined in nb_menu.c +extern double nb_lag_time; +extern double nb_lead_time; +extern double nb_transition_time; +extern double nb_threshold_value; + /* #ifdef GPIO static GtkWidget *encoders; @@ -2400,6 +2406,23 @@ void radioRestoreState() { listen_port = atoi(value); #endif + // restore NB values + value = getProperty("nb_lead_time"); + if (value) + nb_lead_time = atof(value); + + value = getProperty("nb_lag_time"); + if (value) + nb_lag_time = atof(value); + + value = getProperty("nb_transition_time"); + if (value) + nb_transition_time = atof(value); + + value = getProperty("nb_threshold_value"); + if (value) + nb_threshold_value = atof(value); + g_mutex_unlock(&property_mutex); } @@ -2741,6 +2764,16 @@ void radioSaveState() { midi_save_state(); #endif + // nb values + sprintf(value, "%f", nb_lag_time); + setProperty("nb_lag_time", value); + sprintf(value, "%f", nb_lead_time); + setProperty("nb_lead_time", value); + sprintf(value, "%f", nb_transition_time); + setProperty("nb_transition_time", value); + sprintf(value, "%f", nb_threshold_value); + setProperty("nb_threshold_value", value); + saveProperties(property_path); g_mutex_unlock(&property_mutex); } -- 2.45.2