gboolean preamp;
gint attenuation;
gboolean enable_step_attenuation;
+ gdouble gain;
+ gdouble min_gain;
+ gdouble max_gain;
#ifdef SOAPYSDR
- gint *rx_gain;
gboolean agc;
#endif
} ADC;
typedef struct _dac {
gint antenna;
- gint *tx_gain;
+ double gain;
} DAC;
#endif
case SMETER:
{
if(have_rx_gain) {
- level=value+rx_gain_calibration-adc_attenuation[rx->adc];
+ level=value+rx_gain_calibration-adc[rx->adc].attenuation;
} else {
- level=value+(double)adc_attenuation[rx->adc];
+ level=value+(double)adc[rx->adc].attenuation;
}
#ifdef SOAPYSDR
if(protocol==SOAPYSDR_PROTOCOL) {
- level-=rx->rf_gain;
+ level-=adc[rx->id].gain;
}
#endif
if (filter_board == CHARLY25) {
text_location=10;
offset=5.0;
if(have_rx_gain) {
- level=value+rx_gain_calibration-adc_attenuation[rx->adc];
+ level=value+rx_gain_calibration-adc[rx->adc].attenuation;
} else {
- level=value+(double)adc_attenuation[rx->adc];
+ level=value+(double)adc[rx->adc].attenuation;
}
#ifdef SOAPYSDR
if(protocol==SOAPYSDR_PROTOCOL) {
- level-=rx->rf_gain;
+ level-=adc[rx->id].gain;
}
#endif
if (filter_board == CHARLY25) {
}
break;
case MIDI_TYPE_WHEEL:
- dnew=adc_attenuation[active_receiver->adc] + val;
+ dnew=adc[active_receiver->adc].attenuation + val;
if(have_rx_gain) {
if(dnew < -12.0) {
dnew = -12.0;
if (type == MIDI_TYPE_KNOB) {
dnew=-12.0 + 0.6*val;
} else if (type == MIDI_TYPE_WHEEL) {
- dnew=active_receiver->rf_gain+val;
+ dnew=adc[active_receiver->adc].gain+val;
}
if (dnew < -12.0) dnew = -12.0;
if (dnew > 48.0) dnew = 48.0;
high_priority_buffer_to_radio[1443]=transmitter->attenuation;
high_priority_buffer_to_radio[1442]=31;
} else {
- high_priority_buffer_to_radio[1443]=adc_attenuation[0];
+ high_priority_buffer_to_radio[1443]=adc[0].attenuation;
if (diversity_enabled) {
- high_priority_buffer_to_radio[1442]=adc_attenuation[0]; // DIVERSITY: ADC0 att value for ADC1 as well
+ high_priority_buffer_to_radio[1442]=adc[0].attenuation; // DIVERSITY: ADC0 att value for ADC1 as well
} else {
- high_priority_buffer_to_radio[1442]=adc_attenuation[1];
+ high_priority_buffer_to_radio[1442]=adc[1].attenuation;
}
}
// is stored in rx_gain_slider. The firmware uses bit 6
// of C4 to determine this case.
//
- int rxgain = adc_attenuation[active_receiver->adc]+12; // -12..48 to 0..60
+ int rxgain = adc[active_receiver->adc].gain+12; // -12..48 to 0..60
if (rxgain < 0) rxgain=0;
if (rxgain > 60) rxgain=60;
// encode all 6 bits of RXgain in ATT value and set bit6
if (isTransmitting()) {
output_buffer[C4]=0x20 | (transmitter->attenuation & 0x1F);
} else {
- output_buffer[C4]=0x20 | (adc_attenuation[0] & 0x1F);
+ output_buffer[C4]=0x20 | (adc[0].attenuation & 0x1F);
}
}
command=5;
} else {
// if diversity is enabled, use RX1 att value for RX2
if (diversity_enabled) {
- output_buffer[C1]=0x20 | (adc_attenuation[receiver[0]->adc] & 0x1F);
+ output_buffer[C1]=0x20 | (adc[0].attenuation & 0x1F);
} else {
- output_buffer[C1]=0x20 | (adc_attenuation[receiver[1]->adc] & 0x1F);
+ output_buffer[C1]=0x20 | (adc[1].attenuation & 0x1F);
}
}
}
}
#endif
- adc_attenuation[0]=0;
- adc_attenuation[1]=0;
-
- if(have_rx_gain) {
- adc_attenuation[0]=14;
- adc_attenuation[1]=14;
- }
-
adc[0].antenna=ANTENNA_1;
adc[0].filters=AUTOMATIC;
adc[0].hpf=HPF_13;
adc[0].dither=FALSE;
adc[0].random=FALSE;
adc[0].preamp=FALSE;
- adc[0].attenuation=0;
+ if(have_rx_gain) {
+ adc[0].attenuation=14;
+ } else {
+ adc[0].attenuation=0;
+ }
#ifdef SOAPYSDR
adc[0].antenna=0;
if(device==SOAPYSDR_USB_DEVICE) {
- adc[0].rx_gain=malloc(radio->info.soapy.rx_gains*sizeof(gint));
- for (size_t i = 0; i < radio->info.soapy.rx_gains; i++) {
- adc[0].rx_gain[i]=0;
+ adc[0].gain=0;
+ if(radio->info.soapy.rx_gains>0) {
+ adc[0].min_gain=radio->info.soapy.rx_range[0].minimum;
+ adc[0].max_gain=radio->info.soapy.rx_range[0].maximum;;
+ } else {
+ adc[0].min_gain=0.0;
+ adc[0].max_gain=100.0;
}
adc[0].agc=FALSE;
dac[0].antenna=1;
- dac[0].tx_gain=malloc(radio->info.soapy.tx_gains*sizeof(gint));
- for (size_t i = 0; i < radio->info.soapy.tx_gains; i++) {
- dac[0].tx_gain[i]=0;
- }
+ dac[0].gain=0;
}
#endif
+
adc[1].antenna=ANTENNA_1;
adc[1].filters=AUTOMATIC;
adc[1].hpf=HPF_9_5;
adc[1].dither=FALSE;
adc[1].random=FALSE;
adc[1].preamp=FALSE;
- adc[1].attenuation=0;
+ if(have_rx_gain) {
+ adc[0].attenuation=14;
+ } else {
+ adc[1].attenuation=0;
+ }
#ifdef SOAPYSDR
adc[1].antenna=0;
if(device==SOAPYSDR_USB_DEVICE) {
- adc[1].rx_gain=malloc(radio->info.soapy.rx_gains*sizeof(gint));
- for (size_t i = 0; i < radio->info.soapy.rx_gains; i++) {
- adc[1].rx_gain[i]=0;
+ adc[1].gain=0;
+ if(radio->info.soapy.rx_gains>0) {
+ adc[1].min_gain=radio->info.soapy.rx_range[0].minimum;
+ adc[1].max_gain=radio->info.soapy.rx_range[0].maximum;;
+ } else {
+ adc[1].min_gain=0.0;
+ adc[1].max_gain=100.0;
}
+ adc[1].max_gain=0;
adc[1].agc=FALSE;
-
- dac[1].tx_gain=malloc(radio->info.soapy.tx_gains*sizeof(gint));
- for (size_t i = 0; i < radio->info.soapy.tx_gains; i++) {
- dac[1].tx_gain[i]=0;
- }
+ dac[1].antenna=1;
+ dac[1].gain=0;
}
radio_sample_rate=radio->info.soapy.sample_rate;
if(can_transmit) {
soapy_protocol_create_transmitter(transmitter);
soapy_protocol_set_tx_antenna(transmitter,dac[0].antenna);
-/*
- for(int i=0;i<radio->info.soapy.tx_gains;i++) {
- soapy_protocol_set_tx_gain_element(transmitter,radio->info.soapy.tx_gain[i],dac[0].tx_gain[i]);
- }
-*/
soapy_protocol_set_tx_gain(transmitter,transmitter->drive);
soapy_protocol_set_tx_frequency(transmitter);
soapy_protocol_start_transmitter(transmitter);
}
soapy_protocol_set_rx_antenna(rx,adc[0].antenna);
-/*
- for(int i=0;i<radio->info.soapy.rx_gains;i++) {
- soapy_protocol_set_gain_element(rx,radio->info.soapy.rx_gain[i],adc[0].rx_gain[i]);
- }
-*/
-
soapy_protocol_set_rx_frequency(rx,VFO_A);
soapy_protocol_set_automatic_gain(rx,adc[0].agc);
- for(int i=0;i<radio->info.soapy.rx_gains;i++) {
- soapy_protocol_set_gain_element(rx,radio->info.soapy.rx_gain[i],adc[0].rx_gain[i]);
- }
if(vfo[0].ctun) {
setFrequency(vfo[0].ctun_frequency);
soapy_protocol_start_receiver(rx);
//g_print("radio: set rf_gain=%f\n",rx->rf_gain);
- soapy_protocol_set_gain(rx,rx->rf_gain);
+ soapy_protocol_set_gain(rx);
}
#endif
break;
#ifdef SOAPYSDR
case SOAPYSDR_PROTOCOL:
- soapy_protocol_set_gain(active_receiver,value * 1.0);
+ soapy_protocol_set_gain_element(active_receiver,radio->info.soapy.rx_gain[0],(int)adc[0].gain);
break;
#endif
}
value=getProperty("mute_rx_while_transmitting");
if(value) mute_rx_while_transmitting=atoi(value);
-#ifdef SOAPYSDR
+ value=getProperty("radio.adc[0].filters");
+ if(value) adc[0].filters=atoi(value);
+ value=getProperty("radio.adc[0].hpf");
+ if(value) adc[0].hpf=atoi(value);
+ value=getProperty("radio.adc[0].lpf");
+ if(value) adc[0].lpf=atoi(value);
+ value=getProperty("radio.adc[0].antenna");
+ if(value) adc[0].antenna=atoi(value);
+ value=getProperty("radio.adc[0].dither");
+ if(value) adc[0].dither=atoi(value);
+ value=getProperty("radio.adc[0].random");
+ if(value) adc[0].random=atoi(value);
+ value=getProperty("radio.adc[0].preamp");
+ if(value) adc[0].preamp=atoi(value);
+ value=getProperty("radio.adc[0].attenuation");
+ if(value) adc[0].attenuation=atoi(value);
+ value=getProperty("radio.adc[0].enable_step_attenuation");
+ if(value) adc[0].enable_step_attenuation=atoi(value);
+ value=getProperty("radio.adc[0].gain");
+ if(value) adc[0].gain=atof(value);
+ value=getProperty("radio.adc[0].min_gain");
+ if(value) adc[0].min_gain=atof(value);
+ value=getProperty("radio.adc[0].max_gain");
+ if(value) adc[0].max_gain=atof(value);
+
+#ifdef SOAPYSDR
if(device==SOAPYSDR_USB_DEVICE) {
- char name[128];
- for(int i=0;i<radio->info.soapy.rx_gains;i++) {
- sprintf(name,"radio.adc[0].rx_gain.%s",radio->info.soapy.rx_gain[i]) ;
- value=getProperty(name);
- if(value!=NULL) adc[0].rx_gain[i]=atoi(value);
- }
value=getProperty("radio.adc[0].agc");
- if(value!=NULL) adc[0].agc=atoi(value);
- value=getProperty("radio.adc[0].antenna");
- if(value!=NULL) adc[0].antenna=atoi(value);
-
- value=getProperty("radio.dac[0].antenna");
- if(value!=NULL) dac[0].antenna=atoi(value);
- for(int i=0;i<radio->info.soapy.tx_gains;i++) {
- sprintf(name,"radio.dac[0].tx_gain.%s",radio->info.soapy.tx_gain[i]);
- value=getProperty(name);
- if(value!=NULL) dac[0].tx_gain[i]=atoi(value);
- }
+ if(value) adc[0].agc=atoi(value);
}
#endif
+ value=getProperty("radio.dac[0].antenna");
+ if(value) dac[0].antenna=atoi(value);
+ value=getProperty("radio.dac[0].gain");
+ if(value) dac[0].gain=atof(value);
+
+ if(receivers>1) {
+ value=getProperty("radio.adc[1].filters");
+ if(value) adc[1].filters=atoi(value);
+ value=getProperty("radio.adc[1].hpf");
+ if(value) adc[1].hpf=atoi(value);
+ value=getProperty("radio.adc[1].lpf");
+ if(value) adc[1].lpf=atoi(value);
+ value=getProperty("radio.adc[1].antenna");
+ if(value) adc[1].antenna=atoi(value);
+ value=getProperty("radio.adc[1].dither");
+ if(value) adc[1].dither=atoi(value);
+ value=getProperty("radio.adc[1].random");
+ if(value) adc[1].random=atoi(value);
+ value=getProperty("radio.adc[1].preamp");
+ if(value) adc[1].preamp=atoi(value);
+ value=getProperty("radio.adc[1].attenuation");
+ if(value) adc[1].attenuation=atoi(value);
+ value=getProperty("radio.adc[1].enable_step_attenuation");
+ if(value) adc[1].enable_step_attenuation=atoi(value);
+ value=getProperty("radio.adc[1].gain");
+ if(value) adc[1].gain=atof(value);
+ value=getProperty("radio.adc[1].min_gain");
+ if(value) adc[1].min_gain=atof(value);
+ value=getProperty("radio.adc[1].max_gain");
+ if(value) adc[1].max_gain=atof(value);
+
+
+#ifdef SOAPYSDR
+ if(device==SOAPYSDR_USB_DEVICE) {
+ value=getProperty("radio.adc[1].agc");
+ if(value) adc[1].agc=atoi(value);
+ }
+#endif
+ value=getProperty("radio.dac[1].antenna");
+ if(value) dac[1].antenna=atoi(value);
+ value=getProperty("radio.dac[1].gain");
+ if(value) dac[1].gain=atof(value);
+
+ }
#ifdef MIDI
midi_restore_state();
sprintf(value,"%d",rx_gain_calibration);
setProperty("rx_gain_calibration",value);
-#ifdef SOAPYSDR
+ sprintf(value,"%d", adc[0].filters);
+ setProperty("radio.adc[0].filters",value);
+ sprintf(value,"%d", adc[0].hpf);
+ setProperty("radio.adc[0].hpf",value);
+ sprintf(value,"%d", adc[0].lpf);
+ setProperty("radio.adc[0].lpf",value);
+ sprintf(value,"%d", adc[0].antenna);
+ setProperty("radio.adc[0].antenna",value);
+ sprintf(value,"%d", adc[0].dither);
+ setProperty("radio.adc[0].dither",value);
+ sprintf(value,"%d", adc[0].random);
+ setProperty("radio.adc[0].random",value);
+ sprintf(value,"%d", adc[0].preamp);
+ setProperty("radio.adc[0].preamp",value);
+ sprintf(value,"%d", adc[0].attenuation);
+ setProperty("radio.adc[0].attenuation",value);
+ sprintf(value,"%d", adc[0].enable_step_attenuation);
+ setProperty("radio.adc[0].enable_step_attenuation",value);
+ sprintf(value,"%f", adc[0].gain);
+ setProperty("radio.adc[0].gain",value);
+ sprintf(value,"%f", adc[0].min_gain);
+ setProperty("radio.adc[0].min_gain",value);
+ sprintf(value,"%f", adc[0].max_gain);
+ setProperty("radio.adc[0].max_gain",value);
+
+#ifdef SOAPYSDR
if(device==SOAPYSDR_USB_DEVICE) {
- char name[128];
- for(int i=0;i<radio->info.soapy.rx_gains;i++) {
- sprintf(name,"radio.adc[0].rx_gain.%s",radio->info.soapy.rx_gain[i]);
- sprintf(value,"%d", adc[0].rx_gain[i]);
- setProperty(name,value);
- }
- sprintf(name,"radio.adc[0].agc");
sprintf(value,"%d", soapy_protocol_get_automatic_gain(receiver[0]));
- setProperty(name,value);
- sprintf(name,"radio.adc[0].antenna");
- sprintf(value,"%d", adc[0].antenna);
- setProperty(name,value);
-
- sprintf(name,"radio.dac[0].antenna");
- sprintf(value,"%d", dac[0].antenna);
- setProperty(name,value);
+ setProperty("radio.adc[0].agc",value);
+ }
+#endif
- for(int i=0;i<radio->info.soapy.tx_gains;i++) {
- sprintf(name,"radio.dac[0].tx_gain.%s",radio->info.soapy.tx_gain[i]);
- sprintf(value,"%d", dac[0].tx_gain[i]);
- setProperty(name,value);
- }
+ sprintf(value,"%d", dac[0].antenna);
+ setProperty("radio.dac[0].antenna",value);
+ sprintf(value,"%f", dac[0].gain);
+ setProperty("radio.dac[0].gain",value);
- for(int i=0;i<radio->info.soapy.rx_gains;i++) {
- sprintf(name,"radio.adc[1].rx_gain.%s",radio->info.soapy.rx_gain[i]);
- sprintf(value,"%d", adc[1].rx_gain[i]);
- setProperty(name,value);
- }
- sprintf(name,"radio.adc[1].agc");
- sprintf(value,"%d", soapy_protocol_get_automatic_gain(receiver[1]));
- setProperty(name,value);
- sprintf(name,"radio.adc[1].antenna");
+ if(receivers>1) {
+ sprintf(value,"%d", adc[1].filters);
+ setProperty("radio.adc[1].filters",value);
+ sprintf(value,"%d", adc[1].hpf);
+ setProperty("radio.adc[1].hpf",value);
+ sprintf(value,"%d", adc[1].lpf);
+ setProperty("radio.adc[1].lpf",value);
sprintf(value,"%d", adc[1].antenna);
- setProperty(name,value);
-
- sprintf(name,"radio.dac[1].antenna");
- sprintf(value,"%d", dac[1].antenna);
- setProperty(name,value);
-
- for(int i=0;i<radio->info.soapy.tx_gains;i++) {
- sprintf(name,"radio.dac[1].tx_gain.%s",radio->info.soapy.tx_gain[i]);
- sprintf(value,"%d", dac[1].tx_gain[i]);
- setProperty(name,value);
+ setProperty("radio.adc[1].antenna",value);
+ sprintf(value,"%d", adc[1].dither);
+ setProperty("radio.adc[1].dither",value);
+ sprintf(value,"%d", adc[1].random);
+ setProperty("radio.adc[1].random",value);
+ sprintf(value,"%d", adc[1].preamp);
+ setProperty("radio.adc[1].preamp",value);
+ sprintf(value,"%d", adc[1].attenuation);
+ setProperty("radio.adc[1].attenuation",value);
+ sprintf(value,"%d", adc[1].enable_step_attenuation);
+ setProperty("radio.adc[1].enable_step_attenuation",value);
+ sprintf(value,"%f", adc[1].gain);
+ setProperty("radio.adc[1].gain",value);
+ sprintf(value,"%f", adc[1].min_gain);
+ setProperty("radio.adc[1].min_gain",value);
+ sprintf(value,"%f", adc[1].max_gain);
+ setProperty("radio.adc[1].max_gain",value);
+
+#ifdef SOAPYSDR
+ if(device==SOAPYSDR_USB_DEVICE) {
+ sprintf(value,"%d", soapy_protocol_get_automatic_gain(receiver[1]));
+ setProperty("radio.adc[1].agc",value);
}
- }
#endif
+ sprintf(value,"%d", dac[1].antenna);
+ setProperty("radio.dac[1].antenna",value);
+ sprintf(value,"%f", dac[1].gain);
+ setProperty("radio.dac[1].gain",value);
+ }
sprintf(value,"%d",receivers);
setProperty("receivers",value);
extern ADC adc[2];
extern DAC dac[2];
-extern int adc_attenuation[2];
extern int locked;
#ifdef SOAPYSDR
static void rf_gain_value_changed_cb(GtkWidget *widget, gpointer data) {
ADC *adc=(ADC *)data;
- active_receiver->rf_gain=gtk_spin_button_get_value(GTK_SPIN_BUTTON(widget));
+ adc->gain=gtk_spin_button_get_value(GTK_SPIN_BUTTON(widget));
if(radio->device==SOAPYSDR_USB_DEVICE) {
- soapy_protocol_set_gain(receiver[0],active_receiver->rf_gain);
+ soapy_protocol_set_gain(receiver[0]);
}
/*
max=73.0;
}
GtkWidget *rf_gain_b=gtk_spin_button_new_with_range(0.0,max,1.0);
- gtk_spin_button_set_value(GTK_SPIN_BUTTON(rf_gain_b),active_receiver->rf_gain);
+ gtk_spin_button_set_value(GTK_SPIN_BUTTON(rf_gain_b),adc[active_receiver->id].gain);
gtk_grid_attach(GTK_GRID(grid),rf_gain_b,col,row,1,1);
g_signal_connect(rf_gain_b,"value_changed",G_CALLBACK(rf_gain_value_changed_cb),&adc[0]);
sprintf(name,"receiver.%d.volume",rx->id);
sprintf(value,"%f",rx->volume);
setProperty(name,value);
- sprintf(name,"receiver.%d.rf_gain",rx->id);
- sprintf(value,"%f",rx->rf_gain);
- setProperty(name,value);
+ //sprintf(name,"receiver.%d.rf_gain",rx->id);
+ //sprintf(value,"%f",rx->rf_gain);
+ //setProperty(name,value);
sprintf(name,"receiver.%d.agc",rx->id);
sprintf(value,"%d",rx->agc);
setProperty(name,value);
sprintf(name,"receiver.%d.volume",rx->id);
value=getProperty(name);
if(value) rx->volume=atof(value);
- sprintf(name,"receiver.%d.rf_gain",rx->id);
- value=getProperty(name);
- if(value) rx->rf_gain=atof(value);
+ //sprintf(name,"receiver.%d.rf_gain",rx->id);
+ //value=getProperty(name);
+ //if(value) rx->rf_gain=atof(value);
sprintf(name,"receiver.%d.agc",rx->id);
value=getProperty(name);
if(value) rx->agc=atoi(value);
rx->panadapter_step=20;
rx->volume=5.0;
- rx->rf_gain=50.0;
rx->squelch_enable=0;
rx->squelch=0;
rx->waterfall_automatic=1;
rx->volume=0.1;
- rx->rf_gain=50.0;
rx->dither=0;
rx->random=0;
void receiver_change_sample_rate(RECEIVER *rx,int sample_rate) {
-//
-// For the PS_RX_FEEDBACK receiver we have to change
-// the number of pixels in the display (needed for
-// conversion from higher sample rates to 48K such
-// that the central part can be displayed in the TX panadapter
-//
-
g_mutex_lock(&rx->mutex);
rx->sample_rate=sample_rate;
rx->hz_per_pixel=(double)rx->sample_rate/(double)rx->width;
g_print("receiver_change_sample_rate: id=%d rate=%d scale=%d buffer_size=%d output_samples=%d\n",rx->id,sample_rate,scale,rx->buffer_size,rx->output_samples);
+
#ifdef PURESIGNAL
- if (rx->id == PS_RX_FEEDBACK) {
- if (protocol == ORIGINAL_PROTOCOL) {
- rx->pixels = 2* scale * rx->width;
- } else {
- // We should never arrive here, since the sample rate of the
- // PS feedback receiver is fixed.
- rx->pixels = 8 * rx->width;
- }
+ //
+ // In the old protocol, the RX_FEEDBACK sample rate is tied
+ // to the radio's sample rate and therefore may vary.
+ // Since there is no downstream WDSP receiver her, the only thing
+ // we have to do here is to adapt the spectrum display of the
+ // feedback and must then return (rx->id is not a WDSP channel!)
+ //
+ if (rx->id == PS_RX_FEEDBACK && protocol == ORIGINAL_PROTOCOL) {
+ rx->pixels = 2* scale * rx->width;
g_free(rx->pixel_samples);
rx->pixel_samples=g_new(float,rx->pixels);
init_analyzer(rx);
- fprintf(stderr,"PS FEEDBACK change sample rate:id=%d rate=%d buffer_size=%d output_samples=%d\n",
- rx->id, rx->sample_rate, rx->buffer_size, rx->output_samples);
+ g_print("%s: PS FEEDBACK: id=%d rate=%d buffer_size=%d output_samples=%d\n",
+ __FUNCTION__,rx->id, rx->sample_rate, rx->buffer_size, rx->output_samples);
g_mutex_unlock(&rx->mutex);
return;
}
gint adc;
gdouble volume;
- gdouble rf_gain;
gint agc;
gdouble agc_gain;
// agc
if(rx->agc!=AGC_OFF) {
- double knee_y=rx->agc_thresh+(double)adc_attenuation[rx->adc];
+ double knee_y=rx->agc_thresh+(double)adc[rx->adc].attenuation;
if (filter_board == ALEX && rx->adc == 0) knee_y += (double)(10*rx->alex_attenuation);
knee_y = floor((rx->panadapter_high - knee_y)
* (double) display_height
/ (rx->panadapter_high - rx->panadapter_low));
- double hang_y=rx->agc_hang+(double)adc_attenuation[rx->adc];
+ double hang_y=rx->agc_hang+(double)adc[rx->adc].attenuation;
if (filter_board == ALEX && rx->adc == 0) hang_y += (double)(10*rx->alex_attenuation);
hang_y = floor((rx->panadapter_high - hang_y)
* (double) display_height
samples[pan]=-200.0;
samples[display_width-1+pan]=-200.0;
if(have_rx_gain) {
- s1=(double)samples[pan]+rx_gain_calibration-adc_attenuation[rx->adc];
+ s1=(double)samples[pan]+rx_gain_calibration-adc[rx->adc].attenuation;
} else {
- s1=(double)samples[pan]+(double)adc_attenuation[rx->adc];
+ s1=(double)samples[pan]+(double)adc[rx->adc].attenuation;
}
cairo_move_to(cr, 0.0, s1);
if (filter_board == ALEX && rx->adc == 0) s1 += (double)(10*rx->alex_attenuation);
}
#ifdef SOAPYSDR
if(protocol==SOAPYSDR_PROTOCOL) {
- s1-=rx->rf_gain;
+ s1-=adc[rx->adc].gain;
}
#endif
cairo_move_to(cr, 0.0, s1);
for(i=1;i<display_width;i++) {
if(have_rx_gain) {
- s2=(double)samples[i+pan]+rx_gain_calibration-adc_attenuation[rx->adc];
+ s2=(double)samples[i+pan]+rx_gain_calibration-adc[rx->adc].attenuation;
} else {
- s2=(double)samples[i+pan]+(double)adc_attenuation[rx->adc];
+ s2=(double)samples[i+pan]+(double)adc[rx->adc].attenuation;
}
if (filter_board == ALEX && rx->adc == 0) s2 += (double)(10*rx->alex_attenuation);
if (filter_board == CHARLY25) {
}
#ifdef SOAPYSDR
if(protocol==SOAPYSDR_PROTOCOL) {
- s2-=rx->rf_gain;
+ s2-=adc[rx->adc].gain;
}
#endif
s2 = floor((rx->panadapter_high - s2)
if (filter_board == CHARLY25) {
update_att_preamp();
} else {
- gtk_range_set_value (GTK_RANGE(attenuation_scale),(double)adc_attenuation[active_receiver->adc]);
+ gtk_range_set_value (GTK_RANGE(attenuation_scale),(double)adc[active_receiver->adc].attenuation);
}
char title[64];
if (have_rx_gain) {
}
static void attenuation_value_changed_cb(GtkWidget *widget, gpointer data) {
- adc_attenuation[active_receiver->adc]=(int)gtk_range_get_value(GTK_RANGE(attenuation_scale));
+ adc[active_receiver->adc].attenuation=(int)gtk_range_get_value(GTK_RANGE(attenuation_scale));
#ifdef CLIENT_SERVER
if(radio_is_remote) {
- send_attenuation(client_socket,active_receiver->id,(int)adc_attenuation[active_receiver->adc]);
+ send_attenuation(client_socket,active_receiver->id,(int)adc[active_receiver->adc].attenuation);
} else {
#endif
- set_attenuation(adc_attenuation[active_receiver->adc]);
+ set_attenuation(adc[active_receiver->adc].attenuation);
#ifdef CLIENT_SERVER
}
#endif
}
void set_attenuation_value(double value) {
- adc_attenuation[active_receiver->adc]=(int)value;
- set_attenuation(adc_attenuation[active_receiver->adc]);
+ adc[active_receiver->adc].attenuation=(int)value;
+ set_attenuation(adc[active_receiver->adc].attenuation);
if(display_sliders) {
if (have_rx_gain) {
- gtk_range_set_value (GTK_RANGE(attenuation_scale),(double)adc_attenuation[active_receiver->adc]);
+ gtk_range_set_value (GTK_RANGE(attenuation_scale),(double)adc[active_receiver->adc].attenuation);
} else {
- gtk_range_set_value (GTK_RANGE(attenuation_scale),(double)adc_attenuation[active_receiver->adc]);
+ gtk_range_set_value (GTK_RANGE(attenuation_scale),(double)adc[active_receiver->adc].attenuation);
}
} else {
if(scale_status!=ATTENUATION) {
attenuation_scale=gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL,0.0, 31.0, 1.00);
}
gtk_widget_set_size_request (attenuation_scale, 400, 30);
- gtk_range_set_value (GTK_RANGE(attenuation_scale),(double)adc_attenuation[active_receiver->adc]);
+ gtk_range_set_value (GTK_RANGE(attenuation_scale),(double)adc[active_receiver->adc].attenuation);
gtk_widget_show(attenuation_scale);
gtk_container_add(GTK_CONTAINER(content),attenuation_scale);
scale_timer=g_timeout_add(2000,scale_timeout_cb,NULL);
gtk_dialog_run(GTK_DIALOG(scale_dialog));
} else {
g_source_remove(scale_timer);
- gtk_range_set_value (GTK_RANGE(attenuation_scale),(double)adc_attenuation[active_receiver->adc]);
+ gtk_range_set_value (GTK_RANGE(attenuation_scale),(double)adc[active_receiver->adc].attenuation);
scale_timer=g_timeout_add(2000,scale_timeout_cb,NULL);
}
}
active_receiver->alex_attenuation=0;
active_receiver->preamp=0;
active_receiver->dither=0;
- adc_attenuation[active_receiver->adc] = 0;
+ adc[active_receiver->adc].attenuation = 0;
}
sprintf(id, "%d", active_receiver->alex_attenuation);
- adc_attenuation[active_receiver->adc] = 12*active_receiver->alex_attenuation;
+ adc[active_receiver->adc].attenuation = 12*active_receiver->alex_attenuation;
gtk_combo_box_set_active_id(GTK_COMBO_BOX(c25_att_combobox), id);
sprintf(id, "%d", active_receiver->preamp + active_receiver->dither);
gtk_combo_box_set_active_id(GTK_COMBO_BOX(c25_preamp_combobox), id);
if (active_receiver->adc == 0) {
// this button is only valid for the first receiver
// store attenuation, such that in meter.c the correct level is displayed
- adc_attenuation[active_receiver->adc] = 12*val;
+ adc[active_receiver->adc].attenuation = 12*val;
set_alex_attenuation(val);
} else {
// always show "0 dB" on the button if the second RX is active
}
static void rf_gain_value_changed_cb(GtkWidget *widget, gpointer data) {
- active_receiver->rf_gain=gtk_range_get_value(GTK_RANGE(af_gain_scale));
+ adc[active_receiver->adc].gain=gtk_range_get_value(GTK_RANGE(af_gain_scale));
#ifdef SOAPYSDR
if(protocol==SOAPYSDR_PROTOCOL) {
- soapy_protocol_set_gain(active_receiver,active_receiver->rf_gain);
+ soapy_protocol_set_gain(active_receiver);
}
#endif
}
void update_rf_gain() {
- set_rf_gain(active_receiver->id,active_receiver->rf_gain);
+ set_rf_gain(active_receiver->id,adc[active_receiver->id].gain);
}
void set_rf_gain(int rx,double value) {
- receiver[rx]->rf_gain=value;
+ adc[receiver[rx]->adc].gain=value;
#ifdef SOAPYSDR
if(protocol==SOAPYSDR_PROTOCOL) {
- soapy_protocol_set_gain(active_receiver,active_receiver->rf_gain);
+ soapy_protocol_set_gain(active_receiver);
}
#endif
if(display_sliders) {
- gtk_range_set_value (GTK_RANGE(attenuation_scale),receiver[rx]->rf_gain);
+ gtk_range_set_value (GTK_RANGE(rf_gain_scale),adc[receiver[rx]->id].gain);
} else {
if(scale_status!=RF_GAIN || scale_rx!=rx) {
if(scale_status!=NO_FUNCTION) {
GtkWidget *content=gtk_dialog_get_content_area(GTK_DIALOG(scale_dialog));
rf_gain_scale=gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL,0.0, 100.0, 1.00);
gtk_widget_set_size_request (rf_gain_scale, 400, 30);
- gtk_range_set_value (GTK_RANGE(rf_gain_scale),receiver[rx]->rf_gain);
+ gtk_range_set_value (GTK_RANGE(rf_gain_scale),adc[receiver[rx]->id].gain);
gtk_widget_show(rf_gain_scale);
gtk_container_add(GTK_CONTAINER(content),rf_gain_scale);
scale_timer=g_timeout_add(2000,scale_timeout_cb,NULL);
gtk_dialog_run(GTK_DIALOG(scale_dialog));
} else {
g_source_remove(scale_timer);
- gtk_range_set_value (GTK_RANGE(rf_gain_scale),receiver[rx]->rf_gain);
+ gtk_range_set_value (GTK_RANGE(rf_gain_scale),adc[receiver[rx]->id].gain);
scale_timer=g_timeout_add(2000,scale_timeout_cb,NULL);
}
}
if (have_rx_gain) {
attenuation_scale=gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL,-12.0, 48.0, 1.0);
- gtk_range_set_value (GTK_RANGE(attenuation_scale),adc_attenuation[active_receiver->adc]);
+ gtk_range_set_value (GTK_RANGE(attenuation_scale),adc[active_receiver->adc].attenuation);
} else {
attenuation_scale=gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL,0.0, 31.0, 1.0);
- gtk_range_set_value (GTK_RANGE(attenuation_scale),adc_attenuation[active_receiver->adc]);
+ gtk_range_set_value (GTK_RANGE(attenuation_scale),adc[active_receiver->adc].attenuation);
}
gtk_range_set_increments (GTK_RANGE(attenuation_scale),1.0,1.0);
}
}
-void soapy_protocol_set_gain(RECEIVER *rx,double gain) {
+void soapy_protocol_set_gain(RECEIVER *rx) {
int rc;
//fprintf(stderr,"soapy_protocol_set_gain: adc=%d gain=%f\n",gain);
- rc=SoapySDRDevice_setGain(soapy_device,SOAPY_SDR_RX,rx->adc,gain);
+ rc=SoapySDRDevice_setGain(soapy_device,SOAPY_SDR_RX,rx->adc,adc[rx->adc].gain);
if(rc!=0) {
fprintf(stderr,"soapy_protocol: SoapySDRDevice_setGain failed: %s\n",SoapySDR_errToStr(rc));
}
void soapy_protocol_set_rx_frequency(RECEIVER *rx,int v);
void soapy_protocol_set_rx_antenna(RECEIVER *rx,int ant);
void soapy_protocol_set_lna_gain(RECEIVER *rx,int gain);
-void soapy_protocol_set_gain(RECEIVER *rx,double gain);
+void soapy_protocol_set_gain(RECEIVER *rx);
void soapy_protocol_set_gain_element(RECEIVER *rx,char *name,int gain);
int soapy_protocol_get_gain_element(RECEIVER *rx,char *name);
void soapy_protocol_change_sample_rate(RECEIVER *rx);
for(i=0;i<width;i++) {
if(have_rx_gain) {
- sample=samples[i+pan]+(float)(rx_gain_calibration-adc_attenuation[rx->adc]);
+ sample=samples[i+pan]+(float)(rx_gain_calibration-adc[rx->adc].attenuation);
} else {
- sample=samples[i+pan]+(float)adc_attenuation[rx->adc];
+ sample=samples[i+pan]+(float)adc[rx->adc].attenuation;
}
average+=(int)sample;
if(sample<(float)rx->waterfall_low) {