From: Ramakrishnan Muthukrishnan Date: Sun, 21 Aug 2022 10:27:11 +0000 (+0530) Subject: nb2 mode enable via menu X-Git-Url: https://git.rkrishnan.org/%5B/%5D%20/file/$top_link?a=commitdiff_plain;h=9552160201e9205b779cabe7ce0594f59a36443a;p=pihpsdr.git nb2 mode enable via menu --- diff --git a/nb_menu.c b/nb_menu.c index 6f2703b..3b070ed 100644 --- a/nb_menu.c +++ b/nb_menu.c @@ -26,6 +26,7 @@ #include #include "new_menu.h" +#include "noise_menu.h" #include @@ -38,13 +39,8 @@ double nb_lag_time = 0.001; double nb_lead_time = 0.001; double nb_transition_time = 0.001; double nb_threshold_value = 18.0; +int nb2_mode = 0; // 0, 1, 2, 3, 4 -void update_nb() { - SetEXTANBHangtime(0, nb_lag_time); - SetEXTANBAdvtime(0, nb_lead_time); - SetEXTANBTau(0, nb_transition_time); - SetEXTANBThreshold(0, nb_threshold_value); -} void nb_changed() { update_nb(); } @@ -91,6 +87,11 @@ static void nb_threshold_value_changed_cb(GtkWidget *widget, gpointer data) { nb_changed(); } +static void nb2_mode_changed_cb(GtkWidget *widget, gpointer data) { + nb2_mode = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget)); + nb_changed(); +} + void nb_menu(GtkWidget *parent) { parent_window = parent; @@ -164,6 +165,12 @@ void nb_menu(GtkWidget *parent) { gtk_grid_attach(GTK_GRID(grid),nb_threshold_value_b,1,4,1,1); g_signal_connect(nb_threshold_value_b,"value_changed",G_CALLBACK(nb_threshold_value_changed_cb),NULL); + GtkWidget *nb2_mode_b=gtk_spin_button_new_with_range(0, 5, 1); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(nb2_mode_b),(int)nb2_mode); + gtk_widget_show(nb2_mode_b); + gtk_grid_attach(GTK_GRID(grid),nb2_mode_b,1,5,1,1); + g_signal_connect(nb2_mode_b,"value_changed",G_CALLBACK(nb2_mode_changed_cb),NULL); + gtk_container_add(GTK_CONTAINER(content),grid); sub_menu=dialog; gtk_widget_show_all(dialog); diff --git a/nb_menu.h b/nb_menu.h index 28fe262..f4f0b30 100644 --- a/nb_menu.h +++ b/nb_menu.h @@ -19,4 +19,9 @@ */ extern void nb_menu(GtkWidget *parent); -extern void update_nb(); + +extern double nb_lag_time; +extern double nb_lead_time; +extern double nb_transition_time; +extern double nb_threshold_value; +extern int nb2_mode; diff --git a/noise_menu.c b/noise_menu.c index e56759d..2cf97a3 100644 --- a/noise_menu.c +++ b/noise_menu.c @@ -62,8 +62,25 @@ static gboolean delete_event(GtkWidget *widget, GdkEvent *event, gpointer user_d return FALSE; } +void update_nb() { + SetEXTANBHangtime(active_receiver->id, nb_lag_time); + SetEXTANBAdvtime(active_receiver->id, nb_lead_time); + SetEXTANBTau(active_receiver->id, nb_transition_time); + SetEXTANBThreshold(active_receiver->id, nb_threshold_value); +} + +void update_nb2() { + SetEXTNOBMode(active_receiver->id, nb2_mode); + + SetEXTNOBHangtime(active_receiver->id, nb_lag_time); + SetEXTNOBAdvtime(active_receiver->id, nb_lead_time); + SetEXTNOBTau(active_receiver->id, nb_transition_time); + SetEXTNOBThreshold(active_receiver->id, nb_threshold_value); +} + void set_noise() { update_nb(); + update_nb2(); SetEXTANBRun(active_receiver->id, active_receiver->nb); SetEXTNOBRun(active_receiver->id, active_receiver->nb2); diff --git a/noise_menu.h b/noise_menu.h index a145076..be535b4 100644 --- a/noise_menu.h +++ b/noise_menu.h @@ -21,3 +21,4 @@ extern void noise_menu(GtkWidget *parent); extern void update_noise(); extern void set_noise(); +extern void update_nb(); diff --git a/radio.c b/radio.c index 1dc6dd0..1252e27 100644 --- a/radio.c +++ b/radio.c @@ -43,6 +43,7 @@ #include "filter.h" #include "main.h" #include "mode.h" +#include "nb_menu.h" #include "new_menu.h" #include "new_protocol.h" #include "old_protocol.h" @@ -133,12 +134,6 @@ 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; @@ -2423,6 +2418,10 @@ void radioRestoreState() { if (value) nb_threshold_value = atof(value); + value = getProperty("nb2_mode"); + if (value) + nb2_mode = atoi(value); + g_mutex_unlock(&property_mutex); } @@ -2771,9 +2770,12 @@ void radioSaveState() { setProperty("nb_lead_time", value); sprintf(value, "%f", nb_transition_time); setProperty("nb_transition_time", value); - sprintf(value, "%f", nb_threshold_value); + sprintf(value, "%f", (nb_threshold_value/0.165)); setProperty("nb_threshold_value", value); + sprintf(value, "%d", nb2_mode); + setProperty("nb2_mode", value); + saveProperties(property_path); g_mutex_unlock(&property_mutex); }