]> git.rkrishnan.org Git - pihpsdr.git/commitdiff
nb2 mode enable via menu
authorRamakrishnan Muthukrishnan <ram@rkrishnan.org>
Sun, 21 Aug 2022 10:27:11 +0000 (15:57 +0530)
committerRamakrishnan Muthukrishnan <ram@rkrishnan.org>
Sun, 21 Aug 2022 10:27:11 +0000 (15:57 +0530)
nb_menu.c
nb_menu.h
noise_menu.c
noise_menu.h
radio.c

index 6f2703bd0ee7f68e42458fc4399777d855aade8b..3b070ed40ee4aa537a2be6b5361b8d6f6ab4f976 100644 (file)
--- a/nb_menu.c
+++ b/nb_menu.c
@@ -26,6 +26,7 @@
 #include <string.h>
 
 #include "new_menu.h"
+#include "noise_menu.h"
 
 #include <wdsp.h>
 
@@ -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);
index 28fe26212d5d865a9f3b9a8f86faaa2c3991e3fc..f4f0b3058bf4f624344cbd53dd87e160ed2f8ebf 100644 (file)
--- 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;
index e56759d6e42f6bf114b819676e5a87b3e0efe8db..2cf97a35201a63d065712e9c4fe4c2bf8c485a99 100644 (file)
@@ -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);
index a145076cadf7af614448ef63ff889a5e23072f70..be535b424007e2ee80851af78b5788c110ad55e1 100644 (file)
@@ -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 1dc6dd049d2daf0ca5caa0416739a9494f1f53d7..1252e2758674cd2787081ba17751a9a555b5c3f4 100644 (file)
--- 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);
 }