From: Ramakrishnan Muthukrishnan Date: Sat, 22 Jan 2022 12:17:32 +0000 (+0530) Subject: add a new S-meter toggle widget on whether to include rx gain in meter level X-Git-Url: https://git.rkrishnan.org/Site/Content/simplejson/status?a=commitdiff_plain;h=ded5a489c138cd376fcb8250316b49f75109e1b3;p=pihpsdr.git add a new S-meter toggle widget on whether to include rx gain in meter level --- diff --git a/meter.c b/meter.c index f36d6c0..c9e54de 100644 --- a/meter.c +++ b/meter.c @@ -192,11 +192,12 @@ if(analog_meter) { switch(meter_type) { case SMETER: { - if(have_rx_gain) { - level=value+rx_gain_calibration-adc[rx->adc].attenuation; - } else { - level=value+(double)adc[rx->adc].attenuation; - } + double offset = with_gain ? 0 : adc[rx->adc].gain; + if(have_rx_gain) { + level = value + rx_gain_calibration - adc[rx->adc].attenuation - offset; + } else { + level=value + (double)adc[rx->adc].attenuation; + } #ifdef SOAPYSDR if(protocol==SOAPYSDR_PROTOCOL) { //level-=rx->rf_gain; diff --git a/meter_menu.c b/meter_menu.c index 393c7c6..3a9667d 100644 --- a/meter_menu.c +++ b/meter_menu.c @@ -66,6 +66,10 @@ static void analog_cb(GtkToggleButton *widget, gpointer data) { analog_meter=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); } +static void with_gain_cb(GtkToggleButton *widget, gpointer data) { + with_gain = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); +} + void meter_menu (GtkWidget *parent) { parent_window=parent; @@ -139,6 +143,11 @@ void meter_menu (GtkWidget *parent) { row++; col=0; + GtkWidget *with_gain_b=gtk_check_button_new_with_label("With Gain"); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (with_gain_b), with_gain); + gtk_grid_attach(GTK_GRID(grid),with_gain_b,col,row,1,1); + g_signal_connect(with_gain_b,"toggled",G_CALLBACK(with_gain_cb),NULL); + col++; GtkWidget *alc_gain=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(alc_peak),"ALC Gain"); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (alc_gain), alc==TXA_ALC_GAIN); diff --git a/radio.c b/radio.c index 7646807..9a6221b 100644 --- a/radio.c +++ b/radio.c @@ -301,6 +301,7 @@ int OCmemory_tune_time = 550; // ms long long tune_timeout; int analog_meter = 0; +gboolean with_gain = FALSE; int smeter = RXA_S_AV; int local_audio = 0; diff --git a/radio.h b/radio.h index 6a7513f..4e723a5 100644 --- a/radio.h +++ b/radio.h @@ -272,6 +272,7 @@ extern int OCmemory_tune_time; extern long long tune_timeout; extern int analog_meter; +extern int with_gain; extern int smeter; extern int alc;