From 5090b05c16b10cbb19652337416d039629a0a409 Mon Sep 17 00:00:00 2001 From: John Melton G0ORX Date: Thu, 5 Mar 2020 15:52:22 +0000 Subject: [PATCH] Added Mute button. Added mute_rx_while_transmitting enable/disable to radio menu --- ext.c | 6 ++++++ ext.h | 1 + gpio.c | 6 +++++- gpio.h | 1 + i2c.c | 11 +++++++++++ midi.h | 1 + midi2.c | 1 + midi3.c | 5 +++++ radio.c | 9 +++++++++ radio.h | 1 + radio_menu.c | 12 ++++++++++++ receiver.c | 4 ++-- 12 files changed, 55 insertions(+), 3 deletions(-) diff --git a/ext.c b/ext.c index 4c4f522..484be9d 100644 --- 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 8860e4c..f59aba7 100644 --- 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 690b36a..2ab33d5 100644 --- 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 49a373f..e999950 100644 --- 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 cc1f032..8372408 100644 --- 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 cdc9bdb..278caa8 100644 --- 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 c77e3e9..671a044 100644 --- 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 96c444e..634c9d5 100644 --- 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 eb7635f..a26e8d1 100644 --- 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 cf79f01..818d991 100644 --- 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; diff --git a/radio_menu.c b/radio_menu.c index 1e5c935..daab5d4 100644 --- a/radio_menu.c +++ b/radio_menu.c @@ -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) { diff --git a/receiver.c b/receiver.c index ad0f5d3..73bc152 100644 --- a/receiver.c +++ b/receiver.c @@ -1227,7 +1227,7 @@ static void process_rx_buffer(RECEIVER *rx) { short left_audio_sample,right_audio_sample; int i; for(i=0;ioutput_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) { -- 2.45.2