]> git.rkrishnan.org Git - pihpsdr.git/commitdiff
Added Mute button. Added mute_rx_while_transmitting enable/disable to radio menu
authorJohn Melton G0ORX <john.d.melton@googlemail.com>
Thu, 5 Mar 2020 15:52:22 +0000 (15:52 +0000)
committerJohn Melton G0ORX <john.d.melton@googlemail.com>
Thu, 5 Mar 2020 15:52:22 +0000 (15:52 +0000)
12 files changed:
ext.c
ext.h
gpio.c
gpio.h
i2c.c
midi.h
midi2.c
midi3.c
radio.c
radio.h
radio_menu.c
receiver.c

diff --git a/ext.c b/ext.c
index 4c4f52253e1a1c6b6f55d20b769cd7940019f896..484be9d300a7205ce843cfeab02a49fcca1870cd 100644 (file)
--- a/ext.c
+++ b/ext.c
@@ -670,3 +670,9 @@ int ext_set_rx_filter(void *data) {
   return 0;
 }
 
+int ext_mute_update(void *data) {
+g_print("ext_mute_update: currently %d\n",active_receiver->mute_radio);
+  active_receiver->mute_radio=!active_receiver->mute_radio;
+  return 0;
+}
+
diff --git a/ext.h b/ext.h
index 8860e4c96ef9b7f9b3c1e5287a663a150c4b836d..f59aba7732f90d7e550e61029f5a82466939bb87 100644 (file)
--- a/ext.h
+++ b/ext.h
@@ -133,3 +133,4 @@ int ext_start_ps(void *data);
 int ext_set_rx_frequency(void *data);
 int ext_set_rx_mode(void *data);
 int ext_set_rx_filter(void *data);
+int ext_mute_update(void *data);
diff --git a/gpio.c b/gpio.c
index 690b36a09df1b29c791be213123895691b3d8247..2ab33d5792e3d81111e2d8f0fe2adefc1d5ee404 100644 (file)
--- a/gpio.c
+++ b/gpio.c
@@ -270,6 +270,7 @@ char *sw_string[SWITCH_ACTIONS] = {
   "DIV MENU",
   "PS MENU",
   "FUNCTION",
+  "MUTE"
 };
 
 int *sw_action=NULL;
@@ -366,7 +367,7 @@ static int vfo_function_released(void *data) {
 
 static int e_function_pressed(void *data) {
   int action=(int)data;
-//g_print("e_function_pressed: %d\n",action);
+g_print("e_function_pressed: %d\n",action);
   switch(action) {
     case TUNE:
       if(can_transmit) g_idle_add(ext_tune_update,NULL);
@@ -483,6 +484,9 @@ static int e_function_pressed(void *data) {
     case FUNCTION:
       g_idle_add(ext_function_update,NULL);
       break;
+    case MUTE:
+      g_idle_add(ext_mute_update,NULL);
+      break;
   }
   return 0;
 }
diff --git a/gpio.h b/gpio.h
index 49a373fe950b6fb62b050df6b43091058f278608..e99995065430ba801262c96243d45b9588d8dd0d 100644 (file)
--- a/gpio.h
+++ b/gpio.h
@@ -116,6 +116,7 @@ enum {
   MENU_DIVERSITY,
   MENU_PS,
   FUNCTION,
+  MUTE,
   SWITCH_ACTIONS
 };
 
diff --git a/i2c.c b/i2c.c
index cc1f032a5fd115cb256b186b641640c08e742db2..83724083c8b371bffee8fd3bf25d1a2b7f244dd0 100644 (file)
--- a/i2c.c
+++ b/i2c.c
@@ -260,6 +260,17 @@ void i2c_interrupt() {
             case MENU_DIVERSITY:
               g_idle_add(ext_diversity_update,GINT_TO_POINTER(1));
               break;
+            case MENU_PS:
+#ifdef PURESIGNAL
+              g_idle_add(ext_start_ps,NULL);
+#endif
+              break;
+            case FUNCTION:
+              g_idle_add(ext_function_update,NULL);
+              break;
+            case MUTE:
+              g_idle_add(ext_mute_update,NULL);
+              break;
           }
         }
       }
diff --git a/midi.h b/midi.h
index cdc9bdb4a48378a332baa3dcdee5bf07efe6a9ee..278caa8682fcfbc6b6c0d709543d56cc5fb5727b 100644 (file)
--- a/midi.h
+++ b/midi.h
@@ -102,6 +102,7 @@ enum MIDIaction {
   VOXLEVEL,            // VOXLEVEL:            adjust VOX threshold
   MIDI_XIT_CLEAR,      // XITCLEAR:            clear XIT value
   XIT_VAL,             // XITVAL:              change XIT value
+  MIDI_MUTE,           // MUTE:                toggle mute on/off
 };
 
 //
diff --git a/midi2.c b/midi2.c
index c77e3e974504e72ab41ed299896a8fffc4e9a57b..671a0448dcd6a9814f421fb619ff3b8fa671894c 100644 (file)
--- a/midi2.c
+++ b/midi2.c
@@ -155,6 +155,7 @@ static struct {
        { VOXLEVEL,             "VOXLEVEL"},
        { MIDI_XIT_CLEAR,       "XITCLEAR"},
        { XIT_VAL,              "XITVAL"},
+       { MIDI_MUTE,            "MUTE"},
         { ACTION_NONE,         "NONE"}
 };
 
diff --git a/midi3.c b/midi3.c
index 96c444e2a4f905c2641387d98a64b6fec03a1477..634c9d5b342790c01016e20af5b8e7e912eefbae 100644 (file)
--- a/midi3.c
+++ b/midi3.c
@@ -800,6 +800,11 @@ void DoTheMidi(enum MIDIaction action, enum MIDItype type, int val) {
               g_idle_add(ext_vfo_update, NULL);
            }
             break;
+       /////////////////////////////////////////////////////////// "MUTE"
+        case MIDI_MUTE:
+            g_idle_add(ext_mute_update,NULL);
+            break;
+
        case ACTION_NONE:
            // No error message, this is the "official" action for un-used controller buttons.
            break;
diff --git a/radio.c b/radio.c
index eb7635f74aec285c87dd3416e5c3ef8efba42102..a26e8d110421c71aef89b5803782271451ad941c 100644 (file)
--- a/radio.c
+++ b/radio.c
@@ -303,6 +303,7 @@ double display_calibration=0.0;
 int can_transmit=0;
 
 gboolean duplex=FALSE;
+gboolean mute_rx_while_transmitting=FALSE;
 gint rx_height;
 
 void radio_stop() {
@@ -1299,6 +1300,9 @@ static void rxtx(int state) {
 
 void setMox(int state) {
   if(!can_transmit) return;
+#ifdef SOAPYSDR
+  if(!transmitter->local_microphone) return;
+#endif
   vox_cancel();  // remove time-out
   if(mox!=state) {
     if (state && vox) {
@@ -1374,6 +1378,7 @@ void setTune(int state) {
   int i;
 
   if(!can_transmit) return;
+  if(!transmitter->local_microphone) return;
 
   // if state==tune, this function is a no-op
 
@@ -1898,6 +1903,8 @@ g_print("radioRestoreState: %s\n",property_path);
     if(value) duplex=atoi(value);
     value=getProperty("sat_mode");
     if(value) sat_mode=atoi(value);
+    value=getProperty("mute_rx_while_transmitting");
+    if(value) mute_rx_while_transmitting=atoi(value);
 
 #ifdef SOAPYSDR
   if(device==SOAPYSDR_USB_DEVICE) {
@@ -2197,6 +2204,8 @@ g_print("radioSaveState: %s\n",property_path);
     setProperty("split",value);
     sprintf(value,"%d",sat_mode);
     setProperty("sat_mode",value);
+    sprintf(value,"%d",mute_rx_while_transmitting);
+    setProperty("mute_rx_while_transmitting",value);
 
     filterSaveState();
     bandSaveState();
diff --git a/radio.h b/radio.h
index cf79f01ada01cb7c1c98ee03cba874be5d2eebe1..818d991946644ba0ba4b0707fe9b9810f675e094 100644 (file)
--- a/radio.h
+++ b/radio.h
@@ -182,6 +182,7 @@ extern long long step;
 extern int rit_increment;
 
 extern gboolean duplex;
+extern gboolean mute_rx_while_transmitting;
 extern gint rx_height;
 
 extern int lt2208Dither;
index 1e5c93580bf02459b0e8604a4f5e20f27d86b1a2..daab5d41af5aa44b4fb75edfbfe8d35212ff58db 100644 (file)
@@ -54,6 +54,7 @@ static GtkWidget *rsat_b;
 static GtkWidget *receivers_1;
 static GtkWidget *receivers_2;
 static GtkWidget *duplex_b;
+static GtkWidget *mute_rx_b;
 
 static void cleanup() {
   if(dialog!=NULL) {
@@ -231,6 +232,10 @@ static void duplex_cb(GtkWidget *widget, gpointer data) {
   setDuplex();
 }
 
+static void mute_rx_cb(GtkWidget *widget, gpointer data) {
+  mute_rx_while_transmitting=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
+}
+
 static void sat_cb(GtkWidget *widget, gpointer data) {
   sat_mode=gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
   g_idle_add(ext_vfo_update, NULL);
@@ -731,6 +736,13 @@ void radio_menu(GtkWidget *parent) {
   gtk_grid_attach(GTK_GRID(grid),sat_combo,col,row,1,1);
   g_signal_connect(sat_combo,"changed",G_CALLBACK(sat_cb),NULL);
 
+  col++;
+
+  mute_rx_b=gtk_check_button_new_with_label("Mute RX when TX");
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (mute_rx_b), mute_rx_while_transmitting);
+  gtk_grid_attach(GTK_GRID(grid),mute_rx_b,col,row,1,1);
+  g_signal_connect(mute_rx_b,"toggled",G_CALLBACK(mute_rx_cb),NULL);
+
   row++;
 
   if(have_rx_gain) {
index ad0f5d3c494c9a31b82afcd089f1a6682cf43cd2..73bc1521b834ed40fdc0b129c82b930a0713fa67 100644 (file)
@@ -1227,7 +1227,7 @@ static void process_rx_buffer(RECEIVER *rx) {
   short left_audio_sample,right_audio_sample;
   int i;
   for(i=0;i<rx->output_samples;i++) {
-    if(isTransmitting() && !duplex) {
+    if(isTransmitting() && (!duplex || mute_rx_while_transmitting)) {
       left_sample=0.0;
       right_sample=0.0;
       left_audio_sample=0;
@@ -1240,7 +1240,7 @@ static void process_rx_buffer(RECEIVER *rx) {
     }
 
     if(rx->local_audio) {
-      if(rx!=active_receiver && rx->mute_when_not_active) {
+      if((rx!=active_receiver && rx->mute_when_not_active) || rx->mute_radio) {
         audio_write(rx,0.0F,0.0F);
       } else {
         switch(rx->audio_channel) {