From 74c74f732f652b4905b1f80f927b49521ec654cb Mon Sep 17 00:00:00 2001 From: John Melton G0ORX Date: Sun, 6 Oct 2019 18:11:56 +0100 Subject: [PATCH] Fixed transmitter references for RTL-SDR (no tranmit) --- ant_menu.c | 26 +++++------ audio.c | 5 ++- discovered.h | 2 + discovery.c | 3 +- ext.c | 40 ++++++++++------- midi.h | 20 ++++----- midi2.c | 20 ++++----- midi3.c | 22 +++++----- radio.c | 55 ++++++++++++++++------- radio.h | 2 + radio_menu.c | 44 ++++++++++--------- soapy_discovery.c | 31 ++++++++++--- soapy_protocol.c | 10 +++-- transmitter.c | 1 + vfo.c | 108 ++++++++++++++++++++++++++++------------------ 15 files changed, 240 insertions(+), 149 deletions(-) diff --git a/ant_menu.c b/ant_menu.c index b6bb7ec..d7ac9f7 100644 --- a/ant_menu.c +++ b/ant_menu.c @@ -417,19 +417,21 @@ g_print("rx_antennas=%d\n",radio->info.soapy.rx_antennas); gtk_grid_attach(GTK_GRID(grid),adc0_antenna_combo_box,1,1,1,1); } - g_print("tx_antennas=%d\n",radio->info.soapy.tx_antennas); - if(radio->info.soapy.tx_antennas>0) { - GtkWidget *antenna_label=gtk_label_new("TX Antenna:"); - gtk_grid_attach(GTK_GRID(grid),antenna_label,0,2,1,1); - dac0_antenna_combo_box=gtk_combo_box_text_new(); - - for(i=0;iinfo.soapy.tx_antennas;i++) { - gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(dac0_antenna_combo_box),NULL,radio->info.soapy.tx_antenna[i]); + if(can_transmit) { + g_print("tx_antennas=%d\n",radio->info.soapy.tx_antennas); + if(radio->info.soapy.tx_antennas>0) { + GtkWidget *antenna_label=gtk_label_new("TX Antenna:"); + gtk_grid_attach(GTK_GRID(grid),antenna_label,0,2,1,1); + dac0_antenna_combo_box=gtk_combo_box_text_new(); + + for(i=0;iinfo.soapy.tx_antennas;i++) { + gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(dac0_antenna_combo_box),NULL,radio->info.soapy.tx_antenna[i]); + } + + gtk_combo_box_set_active(GTK_COMBO_BOX(dac0_antenna_combo_box),dac[0].antenna); + g_signal_connect(dac0_antenna_combo_box,"changed",G_CALLBACK(dac0_antenna_cb),&dac[0]); + gtk_grid_attach(GTK_GRID(grid),dac0_antenna_combo_box,1,2,1,1); } - - gtk_combo_box_set_active(GTK_COMBO_BOX(dac0_antenna_combo_box),dac[0].antenna); - g_signal_connect(dac0_antenna_combo_box,"changed",G_CALLBACK(dac0_antenna_cb),&dac[0]); - gtk_grid_attach(GTK_GRID(grid),dac0_antenna_combo_box,1,2,1,1); } } diff --git a/audio.c b/audio.c index 70e1600..2028e32 100644 --- a/audio.c +++ b/audio.c @@ -371,7 +371,10 @@ int audio_write(RECEIVER *rx,short left_sample,short right_sample) { snd_pcm_sframes_t delay; long rc; long trim; - int mode=transmitter->mode; + int mode=modeUSB; + if(can_transmit) { + mode=transmitter->mode; + } // // We have to stop the stream here if a CW side tone may occur. // This might cause underflows, but we cannot use audio_write diff --git a/discovered.h b/discovered.h index 3309f88..fcff683 100644 --- a/discovered.h +++ b/discovered.h @@ -93,6 +93,7 @@ struct _DISCOVERED { int supported_receivers; int supported_transmitters; int adcs; + int dacs; double frequency_min; double frequency_max; union { @@ -107,6 +108,7 @@ struct _DISCOVERED { } network; #ifdef SOAPYSDR struct soapy { + char version[128]; int rtlsdr_count; int sample_rate; size_t rx_channels; diff --git a/discovery.c b/discovery.c index 5252bdd..6f7c800 100644 --- a/discovery.c +++ b/discovery.c @@ -298,8 +298,7 @@ fprintf(stderr,"%p Protocol=%d name=%s\n",d,d->protocol,d->name); break; #ifdef SOAPYSDR case SOAPYSDR_PROTOCOL: - sprintf(text,"%s SOAPY_SDR v%d.%d.%d USB", - d->name,d->software_version/100,(d->software_version%100)/10,d->software_version%10); + sprintf(text,"%s (Protocol SOAPY_SDR %s) on USB",d->name,d->info.soapy.version); break; #endif #ifdef STEMLAB_DISCOVERY diff --git a/ext.c b/ext.c index 34464a8..93ffaf0 100644 --- a/ext.c +++ b/ext.c @@ -186,8 +186,10 @@ int ext_sliders_update(void *data) { #ifdef PURESIGNAL int ext_tx_set_ps(void *data) { - int state=(GPOINTER_TO_INT(data) - tx_set_ps(transmitter, state); + if(can_tranmit) { + int state=(GPOINTER_TO_INT(data) + tx_set_ps(transmitter, state); + } return 0; } #endif @@ -220,7 +222,9 @@ int ext_set_drive(void *data) { } int ext_set_compression(void *data) { - set_compression(transmitter); + if(can_transmit) { + set_compression(transmitter); + } return 0; } @@ -260,18 +264,22 @@ int ext_set_attenuation_value(void *data) { #ifdef PURESIGNAL int ext_ps_update(void *data) { - if(transmitter->puresignal==0) { - tx_set_ps(transmitter,1); - } else { - tx_set_ps(transmitter,0); + if(can_transmit) { + if(transmitter->puresignal==0) { + tx_set_ps(transmitter,1); + } else { + tx_set_ps(transmitter,0); + } } return 0; } #endif int ext_two_tone(void *data) { - int state=transmitter->twotone?0:1; - tx_set_twotone(transmitter,state); + if(can_transmit) { + int state=transmitter->twotone?0:1; + tx_set_twotone(transmitter,state); + } return 0; } @@ -453,13 +461,15 @@ int ext_agc_update(void *data) { } int ext_split_update(void *data) { - split=split==1?0:1; - if(split) { - tx_set_mode(transmitter,vfo[VFO_B].mode); - } else { - tx_set_mode(transmitter,vfo[VFO_A].mode); - } + if(can_transmit) { + split=split==1?0:1; + if(split) { + tx_set_mode(transmitter,vfo[VFO_B].mode); + } else { + tx_set_mode(transmitter,vfo[VFO_A].mode); + } vfo_update(); + } return 0; } diff --git a/midi.h b/midi.h index 50915a7..e21cab2 100644 --- a/midi.h +++ b/midi.h @@ -48,32 +48,32 @@ // enum MIDIaction { ACTION_NONE=0, // No-Op (unassigned key) - AGC, // AGC level + MIDI_AGC, // AGC level AGCATTACK, // AGC ATTACK (cycle fast/med/slow etc.) ATT, // Step attenuator or Programmable attenuator AF_GAIN, // AF gain BAND_DOWN, // cycle through bands downwards BAND_UP, // cycle through bands upwards COMPRESS, // TX compressor value - CTUN, // CTUN on/off + MIDI_CTUN, // CTUN on/off FILTER_UP, // cycle through filters upwards FILTER_DOWN, // cycle through filters downwards MIC_VOLUME, // MIC gain - LOCK, // disable frequency changes + MIDI_LOCK, // disable frequency changes MODE_UP, // cycle through modes upwards MODE_DOWN, // cycle through modes downwards - MOX, // toggle "mox" state - NB, // cycle through NoiseBlanker states (none, NB, NB2) - NR, // cycle through NoiseReduction states (none, NR, NR2) + MIDI_MOX, // toggle "mox" state + MIDI_NB, // cycle through NoiseBlanker states (none, NB, NB2) + MIDI_NR, // cycle through NoiseReduction states (none, NR, NR2) PRE, // preamp on/off PAN_HIGH, // "high" value of current panadapter PAN_LOW, // "low" value of current panadapter - PS, // PURESIGNAL on/off - RIT_CLEAR, // clear RIT value + MIDI_PS, // PURESIGNAL on/off + MIDI_RIT_CLEAR, // clear RIT value RIT_VAL, // change RIT value - SPLIT, // Split on/off + MIDI_SPLIT, // Split on/off SWAP_VFO, // swap VFO A/B frequency - TUNE, // toggle "tune" state + MIDI_TUNE, // toggle "tune" state TX_DRIVE, // RF output power VFO, // change VFO frequency VFO_A2B, // VFO A -> B diff --git a/midi2.c b/midi2.c index b23e2c5..c8f81f9 100644 --- a/midi2.c +++ b/midi2.c @@ -92,31 +92,31 @@ static struct { const char *str; } ActionTable[] = { { AF_GAIN, "AFGAIN"}, - { AGC, "AGC"}, + { MIDI_AGC, "AGC"}, { AGCATTACK, "AGCATTACK"}, { ATT, "ATT"}, { BAND_DOWN, "BANDDOWN"}, { BAND_UP, "BANDUP"}, { COMPRESS, "COMPRESS"}, - { CTUN, "CTUN"}, + { MIDI_CTUN, "CTUN"}, { FILTER_DOWN, "FILTERDOWN"}, { FILTER_UP, "FILTERUP"}, - { LOCK, "LOCK"}, + { MIDI_LOCK, "LOCK"}, { MIC_VOLUME, "MICGAIN"}, { MODE_DOWN, "MODEDOWN"}, { MODE_UP, "MODEUP"}, - { MOX, "MOX"}, - { NB, "NOISEBLANKER"}, - { NR, "NOISEREDUCTION"}, + { MIDI_MOX, "MOX"}, + { MIDI_NB, "NOISEBLANKER"}, + { MIDI_NR, "NOISEREDUCTION"}, { PAN_HIGH, "PANHIGH"}, { PAN_LOW, "PANLOW"}, { PRE, "PREAMP"}, - { PS, "PURESIGNAL"}, - { RIT_CLEAR, "RITCLEAR"}, + { MIDI_PS, "PURESIGNAL"}, + { MIDI_RIT_CLEAR,"RITCLEAR"}, { RIT_VAL, "RITVAL"}, - { SPLIT, "SPLIT"}, + { MIDI_SPLIT, "SPLIT"}, { SWAP_VFO, "SWAPVFO"}, - { TUNE, "TUNE"}, + { MIDI_TUNE, "TUNE"}, { TX_DRIVE, "RFPOWER"}, { VFO, "VFO"}, { VFO_A2B, "VFOA2B"}, diff --git a/midi3.c b/midi3.c index d96cd79..7bb8f0c 100644 --- a/midi3.c +++ b/midi3.c @@ -40,13 +40,13 @@ void DoTheMidi(enum MIDIaction action, enum MIDItype type, int val) { g_idle_add(ext_vfo_step, GINT_TO_POINTER(val)); } break; - case TUNE: // only key supported + case MIDI_TUNE: // only key supported if (type == MIDI_KEY) { new = !tune; g_idle_add(ext_tune_update, GINT_TO_POINTER(new)); } break; - case MOX: // only key supported + case MIDI_MOX: // only key supported if (type == MIDI_KEY) { new = !mox; g_idle_add(ext_mox_update, GINT_TO_POINTER(new)); @@ -77,7 +77,7 @@ void DoTheMidi(enum MIDIaction action, enum MIDItype type, int val) { *dp=dnew; g_idle_add(ext_set_mic_gain, (gpointer) dp); break; - case AGC: // knob or wheel supported + case MIDI_AGC: // knob or wheel supported if (type == MIDI_KNOB) { dnew = -20.0 + 1.4*val; } else if (type == MIDI_WHEEL) { @@ -155,7 +155,7 @@ void DoTheMidi(enum MIDIaction action, enum MIDItype type, int val) { } } break; - case RIT_CLEAR: // only key supported + case MIDI_RIT_CLEAR: // only key supported if (type == MIDI_KEY) { // this clears the RIT value and disables RIT vfo[active_receiver->id].rit = new; @@ -217,7 +217,7 @@ void DoTheMidi(enum MIDIaction action, enum MIDItype type, int val) { if (filter_board == ALEX && active_receiver->adc == 0) { new=active_receiver->alex_attenuation + 1; if (new > 3) new=0; - g_idle_add(ext_set_alex_attenuation, GINT_TO_PONTER(new)); + g_idle_add(ext_set_alex_attenuation, GINT_TO_POINTER(new)); g_idle_add(ext_update_att_preamp, NULL); } break; @@ -254,7 +254,7 @@ void DoTheMidi(enum MIDIaction action, enum MIDItype type, int val) { if (dnew > 0.5) transmitter->compressor=1; g_idle_add(ext_set_compression, NULL); break; - case NB: + case MIDI_NB: // cycle through NoiseBlanker settings if (active_receiver->nb) { active_receiver->nb = 0; @@ -268,7 +268,7 @@ void DoTheMidi(enum MIDIaction action, enum MIDItype type, int val) { } g_idle_add(ext_vfo_update, NULL); break; - case NR: + case MIDI_NR: // cycle through NoiseReduction settings if (active_receiver->nr) { active_receiver->nr = 0; @@ -287,7 +287,7 @@ void DoTheMidi(enum MIDIaction action, enum MIDItype type, int val) { vox_enabled = !vox_enabled; g_idle_add(ext_vfo_update, NULL); break; - case CTUN: + case MIDI_CTUN: // toggle CTUN new=active_receiver->id; if(!vfo[new].ctun) { @@ -300,14 +300,14 @@ void DoTheMidi(enum MIDIaction action, enum MIDItype type, int val) { set_offset(active_receiver,vfo[new].offset); g_idle_add(ext_vfo_update, NULL); break; - case PS: + case MIDI_PS: #ifdef PURESIGNAL // toggle PURESIGNAL new=!(transmitter->puresignal); g_idle_add(ext_tx_set_ps,GINT_TO_POINTER(new)); #endif break; - case SPLIT: + case MIDI_SPLIT: // toggle split mode if(!split) { split=1; @@ -324,7 +324,7 @@ void DoTheMidi(enum MIDIaction action, enum MIDItype type, int val) { case VFO_B2A: g_idle_add(ext_vfo_b_to_a, NULL); break; - case LOCK: + case MIDI_LOCK: locked=!locked; g_idle_add(ext_vfo_update, NULL); break; diff --git a/radio.c b/radio.c index affa912..46f9382 100644 --- a/radio.c +++ b/radio.c @@ -313,6 +313,8 @@ double div_phase=0.0; // phase for diversity (in degrees, 0 ... 360) double meter_calibration=0.0; double display_calibration=0.0; +int can_transmit=0; + void reconfigure_radio() { int i; int y; @@ -347,7 +349,9 @@ void reconfigure_radio() { } } - reconfigure_transmitter(transmitter,rx_height); + if(can_transmit) { + reconfigure_transmitter(transmitter,rx_height); + } } @@ -375,6 +379,20 @@ void start_radio() { int rc; + switch(radio->protocol) { + case ORIGINAL_PROTOCOL: + case NEW_PROTOCOL: + can_transmit=1; + break; +#ifdef SOAPYSDR + case SOAPYSDR_PROTOCOL: + can_transmit=(radio->info.soapy.tx_channels!=0); + break; +#endif + } + + g_print("start_radio: can_transmit=%d tx_channels=%d\n",can_transmit,radio->info.soapy.tx_channels); + #ifdef MIDI MIDIstartup(); #endif @@ -771,17 +789,18 @@ void start_radio() { active_receiver=receiver[0]; //fprintf(stderr,"Create transmitter\n"); - transmitter=create_transmitter(CHANNEL_TX, buffer_size, fft_size, updates_per_second, display_width, tx_height); - transmitter->x=0; - transmitter->y=VFO_HEIGHT; - //gtk_fixed_put(GTK_FIXED(fixed),transmitter->panel,0,VFO_HEIGHT); + if(can_transmit) { + transmitter=create_transmitter(CHANNEL_TX, buffer_size, fft_size, updates_per_second, display_width, tx_height); + transmitter->x=0; + transmitter->y=VFO_HEIGHT; #ifdef PURESIGNAL - tx_set_ps_sample_rate(transmitter,protocol==NEW_PROTOCOL?192000:active_receiver->sample_rate); - receiver[PS_TX_FEEDBACK]=create_pure_signal_receiver(PS_TX_FEEDBACK, buffer_size,protocol==ORIGINAL_PROTOCOL?active_receiver->sample_rate:192000,display_width); - receiver[PS_RX_FEEDBACK]=create_pure_signal_receiver(PS_RX_FEEDBACK, buffer_size,protocol==ORIGINAL_PROTOCOL?active_receiver->sample_rate:192000,display_width); - SetPSHWPeak(transmitter->id, protocol==ORIGINAL_PROTOCOL? 0.4067 : 0.2899); + tx_set_ps_sample_rate(transmitter,protocol==NEW_PROTOCOL?192000:active_receiver->sample_rate); + receiver[PS_TX_FEEDBACK]=create_pure_signal_receiver(PS_TX_FEEDBACK, buffer_size,protocol==ORIGINAL_PROTOCOL?active_receiver->sample_rate:192000,display_width); + receiver[PS_RX_FEEDBACK]=create_pure_signal_receiver(PS_RX_FEEDBACK, buffer_size,protocol==ORIGINAL_PROTOCOL?active_receiver->sample_rate:192000,display_width); + SetPSHWPeak(transmitter->id, protocol==ORIGINAL_PROTOCOL? 0.4067 : 0.2899); #endif + } #ifdef AUDIO_WATERFALL audio_waterfall=audio_waterfall_init(200,100); @@ -871,10 +890,11 @@ void start_radio() { launch_rigctl(); } - calcDriveLevel(); - - if(transmitter->puresignal) { - tx_set_ps(transmitter,transmitter->puresignal); + if(can_transmit) { + calcDriveLevel(); + if(transmitter->puresignal) { + tx_set_ps(transmitter,transmitter->puresignal); + } } if(protocol==NEW_PROTOCOL) { @@ -885,7 +905,7 @@ void start_radio() { if(protocol==SOAPYSDR_PROTOCOL) { RECEIVER *rx=receiver[0]; soapy_protocol_create_receiver(rx); - if(transmitter!=NULL) { + if(can_transmit) { soapy_protocol_create_transmitter(transmitter); soapy_protocol_set_tx_antenna(transmitter,dac[0].antenna); for(int i=0;iinfo.soapy.tx_gains;i++) { @@ -1049,6 +1069,7 @@ static void rxtx(int state) { } void setMox(int state) { + if(!can_transmit) return; vox_cancel(); // remove time-out if(mox!=state) { if (state && vox) { @@ -1136,6 +1157,8 @@ void frequency_changed(RECEIVER *rx) { void setTune(int state) { int i; + if(!can_transmit) return; + // if state==tune, this function is a no-op if(tune!=state) { @@ -1870,7 +1893,9 @@ fprintf(stderr,"sem_wait: returned\n"); // the alex_antenna an the adc receiver_save_state(receiver[PS_RX_FEEDBACK]); #endif - transmitter_save_state(transmitter); + if(can_transmit) { + transmitter_save_state(transmitter); + } #ifdef FREEDV freedv_save_state(); #endif diff --git a/radio.h b/radio.h index 85a7431..7a7f801 100644 --- a/radio.h +++ b/radio.h @@ -261,6 +261,8 @@ extern double div_gain, div_phase; extern double meter_calibration; extern double display_calibration; +extern int can_transmit; + extern void reconfigure_radio(); extern void start_radio(); //extern void init_radio(); diff --git a/radio_menu.c b/radio_menu.c index 57bbb8e..26d5ab3 100644 --- a/radio_menu.c +++ b/radio_menu.c @@ -581,16 +581,18 @@ void radio_menu(GtkWidget *parent) { gtk_grid_attach(GTK_GRID(grid),agc,col,row,1,1); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(agc),adc[0].agc); g_signal_connect(agc,"toggled",G_CALLBACK(agc_changed_cb),&adc[0]); - col++; + row++; } row=temp_row; - if(radio->info.soapy.tx_gains>0) { - col=2; - GtkWidget *tx_gain=gtk_label_new("Tx Gains:"); - gtk_grid_attach(GTK_GRID(grid),tx_gain,col,row,1,1); - row++; + if(can_transmit) { + if(radio->info.soapy.tx_gains>0) { + col=2; + GtkWidget *tx_gain=gtk_label_new("Tx Gains:"); + gtk_grid_attach(GTK_GRID(grid),tx_gain,col,row,1,1); + row++; + } } temp_row=row; @@ -615,21 +617,23 @@ void radio_menu(GtkWidget *parent) { row=temp_row; - for(i=0;iinfo.soapy.tx_gains;i++) { - col=2; - GtkWidget *tx_gain_label=gtk_label_new(radio->info.soapy.tx_gain[i]); - gtk_grid_attach(GTK_GRID(grid),tx_gain_label,col,row,1,1); - col++; - SoapySDRRange range=radio->info.soapy.tx_range[i]; - if(range.step==0.0) { - range.step=1.0; + if(can_transmit) { + for(i=0;iinfo.soapy.tx_gains;i++) { + col=2; + GtkWidget *tx_gain_label=gtk_label_new(radio->info.soapy.tx_gain[i]); + gtk_grid_attach(GTK_GRID(grid),tx_gain_label,col,row,1,1); + col++; + SoapySDRRange range=radio->info.soapy.tx_range[i]; + if(range.step==0.0) { + range.step=1.0; + } + GtkWidget *tx_gain_b=gtk_spin_button_new_with_range(range.minimum,range.maximum,range.step); + gtk_widget_set_name (tx_gain_b, radio->info.soapy.tx_gain[i]); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(tx_gain_b),(double)dac[0].tx_gain[i]); + gtk_grid_attach(GTK_GRID(grid),tx_gain_b,col,row,1,1); + g_signal_connect(tx_gain_b,"value_changed",G_CALLBACK(tx_gain_value_changed_cb),&dac[0]); + row++; } - GtkWidget *tx_gain_b=gtk_spin_button_new_with_range(range.minimum,range.maximum,range.step); - gtk_widget_set_name (tx_gain_b, radio->info.soapy.tx_gain[i]); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(tx_gain_b),(double)dac[0].tx_gain[i]); - gtk_grid_attach(GTK_GRID(grid),tx_gain_b,col,row,1,1); - g_signal_connect(tx_gain_b,"value_changed",G_CALLBACK(tx_gain_value_changed_cb),&dac[0]); - row++; } } diff --git a/soapy_discovery.c b/soapy_discovery.c index 54c64fd..7c46202 100644 --- a/soapy_discovery.c +++ b/soapy_discovery.c @@ -32,11 +32,20 @@ static void get_info(char *driver) { size_t rx_rates_length, tx_rates_length, rx_gains_length, tx_gains_length, ranges_length, rx_antennas_length, tx_antennas_length, rx_bandwidth_length, tx_bandwidth_length; int i; SoapySDRKwargs args={}; - int version=0; + int software_version=0; int rtlsdr_val=0; + char fw_version[64]; + char gw_version[64]; + char hw_version[64]; + char p_version[64]; fprintf(stderr,"soapy_discovery: get_info: %s\n", driver); + strcpy(fw_version,""); + strcpy(gw_version,""); + strcpy(hw_version,""); + strcpy(p_version,""); + SoapySDRKwargs_set(&args, "driver", driver); if(strcmp(driver,"rtlsdr")==0) { char count[16]; @@ -47,7 +56,7 @@ static void get_info(char *driver) { } SoapySDRDevice *sdr = SoapySDRDevice_make(&args); SoapySDRKwargs_clear(&args); - version=0; + software_version=0; char *driverkey=SoapySDRDevice_getDriverKey(sdr); fprintf(stderr,"DriverKey=%s\n",driverkey); @@ -59,13 +68,17 @@ static void get_info(char *driver) { for(i=0;ilocal_microphone) { - if(audio_open_input()!=0) { - fprintf(stderr,"audio_open_input failed\n"); - transmitter->local_microphone=0; + if(can_transmit) { + if(transmitter->local_microphone) { + if(audio_open_input()!=0) { + fprintf(stderr,"audio_open_input failed\n"); + transmitter->local_microphone=0; + } } } diff --git a/transmitter.c b/transmitter.c index f767486..a79f5a7 100644 --- a/transmitter.c +++ b/transmitter.c @@ -576,6 +576,7 @@ TRANSMITTER *create_transmitter(int id, int buffer_size, int fft_size, int fps, tx->iq_output_rate=radio_sample_rate; tx->buffer_size=1024; tx->output_samples=1024*(tx->iq_output_rate/tx->mic_sample_rate); + tx->pixels=width*8; // to allow 384k to 24k conversion break; #endif diff --git a/vfo.c b/vfo.c index 7f558ef..38555da 100644 --- a/vfo.c +++ b/vfo.c @@ -200,7 +200,11 @@ void vfo_restore_state() { vfo[i].band=band20; vfo[i].bandstack=0; - vfo[i].frequency=14010000; + if(radio->protocol==SOAPYSDR_PROTOCOL) { + vfo[i].frequency=144010000; + } else { + vfo[i].frequency=14010000; + } vfo[i].mode=modeCWU; vfo[i].filter=6; vfo[i].lo=0; @@ -293,7 +297,9 @@ void vfo_band_changed(int b) { receiver_vfo_changed(receiver[id]); BAND *band=band_get_band(vfo[id].band); set_alex_rx_antenna(band->alexRxAntenna); - set_alex_tx_antenna(band->alexTxAntenna); + if(can_transmit) { + set_alex_tx_antenna(band->alexTxAntenna); + } set_alex_attenuation(band->alexAttenuation); receiver_vfo_changed(receiver[0]); break; @@ -304,17 +310,19 @@ void vfo_band_changed(int b) { break; } - if(split) { - tx_set_mode(transmitter,vfo[VFO_B].mode); - } else { - tx_set_mode(transmitter,vfo[VFO_A].mode); + if(can_transmit) { + if(split) { + tx_set_mode(transmitter,vfo[VFO_B].mode); + } else { + tx_set_mode(transmitter,vfo[VFO_A].mode); + } + // + // If the band has changed, it is necessary to re-calculate + // the drive level. Furthermore, possibly the "PA disable" + // status has changed. + // + calcDriveLevel(); // sends HighPrio packet if in new protocol } - // - // If the band has changed, it is necessary to re-calculate - // the drive level. Furthermore, possibly the "PA disable" - // status has changed. - // - calcDriveLevel(); // sends HighPrio packet if in new protocol if (protocol == NEW_PROTOCOL) { schedule_general(); } @@ -351,10 +359,12 @@ void vfo_bandstack_changed(int b) { break; } - if(split) { - tx_set_mode(transmitter,vfo[VFO_B].mode); - } else { - tx_set_mode(transmitter,vfo[VFO_A].mode); + if(can_transmit) { + if(split) { + tx_set_mode(transmitter,vfo[VFO_B].mode); + } else { + tx_set_mode(transmitter,vfo[VFO_A].mode); + } } // // I do not think the band can change within this function. @@ -396,10 +406,12 @@ void vfo_mode_changed(int m) { } break; } - if(split) { - tx_set_mode(transmitter,vfo[VFO_B].mode); - } else { - tx_set_mode(transmitter,vfo[VFO_A].mode); + if(can_transmit) { + if(split) { + tx_set_mode(transmitter,vfo[VFO_B].mode); + } else { + tx_set_mode(transmitter,vfo[VFO_A].mode); + } } // // changing modes may change BFO frequency @@ -447,8 +459,10 @@ void vfo_a_to_b() { if(receivers==2) { receiver_vfo_changed(receiver[1]); } - if(split) { - tx_set_mode(transmitter,vfo[VFO_B].mode); + if(can_transmit) { + if(split) { + tx_set_mode(transmitter,vfo[VFO_B].mode); + } } g_idle_add(ext_vfo_update,NULL); } @@ -464,8 +478,10 @@ void vfo_b_to_a() { vfo[VFO_A].rit_enabled=vfo[VFO_B].rit_enabled; vfo[VFO_A].rit=vfo[VFO_B].rit; receiver_vfo_changed(receiver[0]); - if(!split) { - tx_set_mode(transmitter,vfo[VFO_B].mode); + if(can_transmit) { + if(!split) { + tx_set_mode(transmitter,vfo[VFO_B].mode); + } } g_idle_add(ext_vfo_update,NULL); } @@ -515,10 +531,12 @@ void vfo_a_swap_b() { if(receivers==2) { receiver_vfo_changed(receiver[1]); } - if(split) { - tx_set_mode(transmitter,vfo[VFO_B].mode); - } else { - tx_set_mode(transmitter,vfo[VFO_A].mode); + if(can_transmit) { + if(split) { + tx_set_mode(transmitter,vfo[VFO_B].mode); + } else { + tx_set_mode(transmitter,vfo[VFO_A].mode); + } } g_idle_add(ext_vfo_update,NULL); } @@ -840,15 +858,17 @@ void vfo_update() { // Since we can now change it by a MIDI controller, // we should display the compressor (level) // - cairo_move_to(cr, 400, 50); - if (transmitter->compressor) { - sprintf(temp_text,"CMPR %d dB",(int) transmitter->compressor_level); - cairo_set_source_rgb(cr, 1.0, 1.0, 0.0); - cairo_show_text(cr, temp_text); - } else { - cairo_set_source_rgb(cr, 0.7, 0.7, 0.7); - cairo_show_text(cr, "CMPR OFF"); - } + if(can_transmit) { + cairo_move_to(cr, 400, 50); + if (transmitter->compressor) { + sprintf(temp_text,"CMPR %d dB",(int) transmitter->compressor_level); + cairo_set_source_rgb(cr, 1.0, 1.0, 0.0); + cairo_show_text(cr, temp_text); + } else { + cairo_set_source_rgb(cr, 0.7, 0.7, 0.7); + cairo_show_text(cr, "CMPR OFF"); + } + } cairo_move_to(cr, 500, 50); if(diversity_enabled) { @@ -914,13 +934,15 @@ void vfo_update() { cairo_show_text(cr, "Split"); #ifdef PURESIGNAL - cairo_move_to(cr, 105, 50); - if(transmitter->puresignal) { - cairo_set_source_rgb(cr, 1.0, 1.0, 0.0); - } else { - cairo_set_source_rgb(cr, 0.7, 0.7, 0.7); + if(can_transmit) { + cairo_move_to(cr, 105, 50); + if(transmitter->puresignal) { + cairo_set_source_rgb(cr, 1.0, 1.0, 0.0); + } else { + cairo_set_source_rgb(cr, 0.7, 0.7, 0.7); + } + cairo_show_text(cr, "PS"); } - cairo_show_text(cr, "PS"); #endif -- 2.45.2