From 4e3fc950f009068de71cd094686f0f9f986bff0d Mon Sep 17 00:00:00 2001 From: c vw Date: Tue, 18 May 2021 12:31:58 +0200 Subject: [PATCH] Manual merge effort --- agc_menu.c | 1 + alsa_midi.c | 1 + audio.h | 4 +- band_menu.c | 5 +- bandstack_menu.c | 1 + discovered.h | 2 +- discovery.c | 4 +- display_menu.c | 1 + exit_menu.c | 1 + ext.c | 488 ++++++++++++++++++++---------------------- filter_menu.c | 1 + iambic.c | 33 +-- main.c | 9 +- meter.c | 12 +- midi3.c | 10 +- mode_menu.c | 1 + new_menu.c | 81 +++---- new_protocol.c | 45 ++-- noise_menu.c | 1 + oc_menu.c | 2 +- old_protocol.c | 8 +- portaudio.c | 3 +- property.c | 2 +- radio.c | 134 +++++++++--- radio.h | 21 +- radio_menu.c | 85 ++++---- receiver.c | 108 +++++----- receiver.h | 16 +- rigctl.c | 6 +- rigctl_menu.c | 2 +- rx_menu.c | 2 +- sliders.c | 117 ++++++----- soapy_discovery.c | 132 +++++++++--- stemlab_discovery.c | 1 + toolbar.c | 501 +++++--------------------------------------- transmitter.c | 2 +- tx_menu.c | 4 +- vfo.c | 38 ++-- vfo.h | 3 +- vfo_menu.c | 2 + waterfall.c | 4 +- zoompan.c | 6 +- 42 files changed, 803 insertions(+), 1097 deletions(-) diff --git a/agc_menu.c b/agc_menu.c index 5670218..36e2caa 100644 --- a/agc_menu.c +++ b/agc_menu.c @@ -43,6 +43,7 @@ static void cleanup() { gtk_widget_destroy(dialog); dialog=NULL; sub_menu=NULL; + active_menu=NO_MENU; } } diff --git a/alsa_midi.c b/alsa_midi.c index d05ad69..865cb21 100644 --- a/alsa_midi.c +++ b/alsa_midi.c @@ -19,6 +19,7 @@ */ #include + #include "midi.h" #include "midi_menu.h" #include "alsa_midi.h" diff --git a/audio.h b/audio.h index 234c184..398b8c2 100644 --- a/audio.h +++ b/audio.h @@ -36,13 +36,15 @@ extern int n_input_devices; extern AUDIO_DEVICE input_devices[MAX_AUDIO_DEVICES]; extern int n_output_devices; extern AUDIO_DEVICE output_devices[MAX_AUDIO_DEVICES]; +extern GMutex audio_mutex; +extern gint local_microphone_buffer_size; extern int audio_open_input(); extern void audio_close_input(); extern int audio_open_output(RECEIVER *rx); extern void audio_close_output(RECEIVER *rx); extern int audio_write(RECEIVER *rx,float left_sample,float right_sample); -extern int cw_audio_write(float sample); +extern int cw_audio_write(RECEIVER *rx,float sample); extern void audio_get_cards(); char * audio_get_error_string(int err); float audio_get_next_mic_sample(); diff --git a/band_menu.c b/band_menu.c index 908dafc..7bbb472 100644 --- a/band_menu.c +++ b/band_menu.c @@ -32,7 +32,9 @@ #include "receiver.h" #include "vfo.h" #include "button_text.h" +#ifdef CLIENT_SERVER #include "client_server.h" +#endif static GtkWidget *parent_window=NULL; @@ -45,6 +47,7 @@ static void cleanup() { gtk_widget_destroy(dialog); dialog=NULL; sub_menu=NULL; + active_menu=NO_MENU; } } @@ -112,7 +115,7 @@ void band_menu(GtkWidget *parent) { long long frequency_min=radio->frequency_min; long long frequency_max=radio->frequency_max; -//g_print("band_menu: min=%lld max=%lld\n",frequency_min,frequency_max); + //g_print("band_menu: min=%lld max=%lld\n",frequency_min,frequency_max); j=0; for(i=0;iprotocol,d->name); break; #ifdef SOAPYSDR case SOAPYSDR_PROTOCOL: - sprintf(text,"%s (Protocol SOAPY_SDR %s) via Soapy lib",d->name,d->info.soapy.version); + sprintf(text,"%s (Protocol SOAPY_SDR %s) on %s",d->name,d->info.soapy.version,d->info.soapy.address); break; + #endif #ifdef STEMLAB_DISCOVERY case STEMLAB_PROTOCOL: diff --git a/display_menu.c b/display_menu.c index 7dbf1e3..38aab90 100644 --- a/display_menu.c +++ b/display_menu.c @@ -24,6 +24,7 @@ #include #include +#include "main.h" #include "new_menu.h" #include "display_menu.h" #include "channel.h" diff --git a/exit_menu.c b/exit_menu.c index ece8880..10c049b 100644 --- a/exit_menu.c +++ b/exit_menu.c @@ -33,6 +33,7 @@ #include "soapy_protocol.h" #endif #ifdef GPIO +#include "actions.h" #include "gpio.h" #endif diff --git a/ext.c b/ext.c index 366b2df..e0d4aab 100644 --- a/ext.c +++ b/ext.c @@ -56,13 +56,11 @@ // // Re-structuring of the rigctl, MIDI, and gpio code // eliminates the need for many "ext" functions -// defined here. For the time being, they are -// moved to the end of the file, and the whole block is -// deactivated with #if0/#endif +// defined here. // // -// Furthermore, some "helper" functions defined here +// Some "helper" functions defined in this file // are moved to the top of the file, since they // eventually are moved elsewhere. // @@ -218,18 +216,48 @@ void update_vfo_step(int direction) { // // Functions to be invoked through the GTK idle queue, -// still in use // +int ext_menu_filter(void *data) { + start_filter(); + return 0; +} + +int ext_menu_mode(void *data) { + start_mode(); + return 0; +} + +int ext_num_pad(void *data) { + gint val=GPOINTER_TO_INT(data); + num_pad(val); + return 0; +} + +int ext_vfo_mode_changed(void * data) +{ + int mode=GPOINTER_TO_INT(data); + vfo_mode_changed(mode); + return 0; +} + int ext_discovery(void *data) { discovery(); return 0; } -// -// ext_vfo_update includes a limitation to how often -// the VFO bar is actually re-drawn (every 100 msec) -// +int ext_set_frequency(void *data) { + // + // If new frequency is outside of current band, + // behave as if the user had chosen the new band + // via the menu prior to changing the frequency + // + SET_FREQUENCY *SetFreq=(SET_FREQUENCY *)data; +g_print("ext_set_frequency: vfo=%d freq=%lld\n",SetFreq->vfo,SetFreq->frequency); + set_frequency(SetFreq->vfo,SetFreq->frequency); + free(data); + return 0; +} static guint vfo_timeout=0; @@ -250,6 +278,11 @@ int ext_vfo_update(void *data) { return 0; } +int ext_vfo_filter_changed(void *data) { + vfo_filter_changed(GPOINTER_TO_INT(data)); + return 0; +} + int ext_band_update(void *data) { if(data==NULL) { start_band(); @@ -284,7 +317,13 @@ int ext_memory_update(void *data) { return 0; } +int ext_noise_update(void *data) { + start_noise(); + return 0; +} + int ext_mox_update(void *data) { +g_print("%s\n",__FUNCTION__); mox_update(GPOINTER_TO_INT(data)); return 0; } @@ -299,6 +338,38 @@ int ext_vox_changed(void *data) { return 0; } +int ext_update_agc_gain(void *data) { + update_agc_gain(GPOINTER_TO_INT(data)); + free(data); + return 0; +} + +int ext_update_af_gain(void *data) { + update_af_gain(); + return 0; +} + +int ext_calc_drive_level(void *data) { + calcDriveLevel(); + return 0; +} + +int ext_vfo_band_changed(void *data) { + int b=GPOINTER_TO_INT(data); + vfo_band_changed(active_receiver->id,b); + return 0; +} + +int ext_radio_change_sample_rate(void *data) { + radio_change_sample_rate(GPOINTER_TO_INT(data)); + return 0; +} + +int ext_update_squelch(void *data) { + set_squelch(); + return 0; +} + int ext_sliders_update(void *data) { sliders_update(); return 0; @@ -314,6 +385,62 @@ int ext_tx_set_ps(void *data) { } #endif +int ext_update_vfo_step(void *data) { + int direction=GPOINTER_TO_INT(data); + update_vfo_step(direction); + return 0; +} + +int ext_vfo_step(void *data) { + int step=GPOINTER_TO_INT(data); + vfo_step(step); + return 0; +} + +int ext_vfo_id_step(void *data) { + int *ip=(int *) data; + int id=ip[0]; + int step=ip[1]; + vfo_id_step(id,step); + free(data); + return 0; +} + +int ext_set_mic_gain(void * data) { + double d=*(double *)data; + set_mic_gain(d); + free(data); + return 0; +} + +int ext_set_af_gain(void *data) { + double d=*(double *)data; + set_af_gain(active_receiver->id,d); + free(data); + return 0; +} + +int ext_set_agc_gain(void *data) { + double d=*(double *)data; + set_agc_gain(active_receiver->id,d); + free(data); + return 0; +} + +int ext_set_drive(void *data) { + double d=*(double *)data; + set_drive(d); + free(data); + return 0; +} + +int ext_set_compression(void *data) { + if(can_transmit) { + set_compression(transmitter); + } + return 0; +} + int ext_vfo_a_swap_b(void *data) { vfo_a_swap_b(); return 0; @@ -329,6 +456,25 @@ int ext_vfo_b_to_a(void *data) { return 0; } +int ext_update_att_preamp(void *data) { + update_att_preamp(); + return 0; +} + +int ext_set_alex_attenuation(void *data) { + int val=GPOINTER_TO_INT(data); + set_alex_attenuation(val); + return 0; +} + +int ext_set_attenuation_value(void *data) { + double d=*(double *)data; + set_attenuation_value(d); + free(data); + return 0; +} + + #ifdef PURESIGNAL int ext_ps_update(void *data) { if(can_transmit) { @@ -404,6 +550,13 @@ int ext_snb_update(void *data) { return 0; } +int ext_band_select(void *data) { + int b=GPOINTER_TO_INT(data); + g_print("%s: %d\n",__FUNCTION__,b); + vfo_band_changed(active_receiver->id,b); + return 0; +} + int ext_band_plus(void *data) { band_plus(active_receiver->id); return 0; @@ -522,8 +675,10 @@ int ext_agc_update(void *data) { } int ext_split_toggle(void *data) { - int val = split ? 0 : 1; - set_split(val); + if(can_transmit) { + set_split(!split); + g_idle_add(ext_vfo_update, NULL); + } return 0; } @@ -552,6 +707,20 @@ int ext_diversity_update(void *data) { return 0; } +int ext_diversity_change_gain(void *data) { + double *dp = (double *) data; + update_diversity_gain(*dp); + free(dp); + return 0; +} + +int ext_diversity_change_phase(void *data) { + double *dp = (double *) data; + update_diversity_phase(*dp); + free(dp); + return 0; +} + #ifdef PURESIGNAL int ext_start_ps(void *data) { start_ps(); @@ -585,6 +754,19 @@ int ext_function_update(void *data) { return 0; } +int ext_set_rf_gain(void *data) { + int pos=GPOINTER_TO_INT(data); + double value; + value=(double)pos; + if(value<-12.0) { + value=-12.0; + } else if(value>48.0) { + value=48.0; + } + set_rf_gain(active_receiver->id,value); + return 0; +} + int ext_update_noise(void *data) { update_noise(); return 0; @@ -612,7 +794,7 @@ int ext_remote_command(void *data) { temp=active_receiver->pan; int vfo=freq_command->id; long long f=ntohll(freq_command->hz); - set_frequency(vfo,f); + local_set_frequency(vfo,f); vfo_update(); send_vfo_data(client,VFO_A); send_vfo_data(client,VFO_B); @@ -997,254 +1179,6 @@ int ext_receiver_remote_update_display(void *data) { } #endif -int ext_mute_update(void *data) { - active_receiver->mute_radio=!active_receiver->mute_radio; - return 0; -} - -int ext_zoom_update(void *data) { - update_zoom((double)GPOINTER_TO_INT(data)); - return 0; -} - -int ext_pan_update(void *data) { - update_pan((double)GPOINTER_TO_INT(data)); - return 0; -} - -int ext_remote_set_zoom(void *data) { - int zoom=GPOINTER_TO_INT(data); -g_print("ext_remote_set_zoom: %d\n",zoom); - remote_set_zoom(active_receiver->id,(double)zoom); - return 0; -} - -int ext_remote_set_pan(void *data) { - int pan=GPOINTER_TO_INT(data); -g_print("ext_remote_set_pan: %d\n",pan); - remote_set_pan(active_receiver->id,(double)pan); - return 0; -} - -int ext_set_title(void *data) { - gtk_window_set_title(GTK_WINDOW(top_window),(char *)data); - return 0; -} - -// -// Functions no longer used -// -#if 0 -int ext_recall_memory_slot(void *data) { - recall_memory_slot(GPOINTER_TO_INT(data)); - return 0; -} - -int ext_vfo_mode_changed(void * data) -{ - int mode=GPOINTER_TO_INT(data); - vfo_mode_changed(mode); - return 0; -} - -int ext_set_frequency(void *data) { - // - // If new frequency is outside of current band, - // behave as if the user had chosen the new band - // via the menu prior to changing the frequency - // - SET_FREQUENCY *set_frequency=(SET_FREQUENCY *)data; -g_print("ext_set_frequency: vfo=%d freq=%lld\n",set_frequency->vfo,set_frequency->frequency); - set_frequency(set_frequency->vfo,set_frequency->frequency); - free(data); - return 0; -} - -int ext_vfo_filter_changed(void *data) { - vfo_filter_changed(GPOINTER_TO_INT(data)); - return 0; -} - -int ext_noise_update(void *data) { - start_noise(); - return 0; -} - -int ext_update_agc_gain(void *data) { - update_agc_gain(GPOINTER_TO_INT(data)); - return 0; -} - -int ext_update_af_gain(void *data) { - update_af_gain(); - return 0; -} - -int ext_calc_drive_level(void *data) { - calcDriveLevel(); - return 0; -} - -int ext_vfo_band_changed(void *data) { - int b=GPOINTER_TO_INT(data); - vfo_band_changed(active_receiver->id,b); - return 0; -} - -int ext_radio_change_sample_rate(void *data) { - radio_change_sample_rate(GPOINTER_TO_INT(data)); - return 0; -} - -int ext_update_squelch(void *data) { - set_squelch(); - return 0; -} - -int ext_update_vfo_step(void *data) { - int direction=GPOINTER_TO_INT(data); - int i=0; - while(steps[i]!=step && steps[i]!=0) { - i++; - } - - if(steps[i]!=0) { - if(direction>0) { - i++; - if(steps[i]!=0) { - step=steps[i]; - } - } else { - i--; - if(i>=0) { - step=steps[i]; - } - } - } - g_idle_add(ext_vfo_update, NULL); - return 0; -} - -int ext_vfo_step(void *data) { - int step=GPOINTER_TO_INT(data); - vfo_step(step); - return 0; -} - -int ext_vfo_id_step(void *data) { - // - // the two integer input arguments (VFO id and Step in Hz) - // are encoded in a single integer-type number: - // input = 10000*vfo_id + (step+1000); - // - // Normally vfo_id is a small number (0 or 1) - // and the step is in the range -100 - 100 (in units of the VFO step size) - // - int val = GPOINTER_TO_INT(data); - int id = val / 10000; - int step = (val % 10000) - 1000; - vfo_id_step(id,step); - return 0; -} - -int ext_set_mic_gain(void * data) { - // - // mic gain is (input value - 1000), normally between -12 and 50 - // - int val = GPOINTER_TO_INT(data); - double d = val - 1000; - set_mic_gain(d); - return 0; -} - -int ext_set_agc_gain(void *data) { - // - // AGC is (input value - 1000), normally between -20 and +120 - // - int val=GPOINTER_TO_INT(data); - double d= val - 1000; - set_agc_gain(active_receiver->id,d); - return 0; -} - -int ext_set_drive(void *data) { - // - // Drive is input value, normally between 0 and 100 - // - int val=GPOINTER_TO_INT(data); - double d=(double) val; - set_drive(d); - return 0; -} - -int ext_set_compression(void *data) { - if(can_transmit) { - set_compression(transmitter); - } - return 0; -} - -int ext_update_att_preamp(void *data) { - update_att_preamp(); - return 0; -} - -int ext_set_alex_attenuation(void *data) { - int val=GPOINTER_TO_INT(data); - set_alex_attenuation(val); - return 0; -} - -int ext_set_attenuation_value(void *data) { - // - // Att valus is (input -1000), normally between 0 and 31 - // but HermesLite-II and others have the range -12 to 48. - // - int val=GPOINTER_TO_INT(data); - double d = val - 1000; - set_attenuation_value(d); - return 0; -} - -int ext_set_split(void *data) { - val=GPOINTER_TO_INT(data), - set_split(val); - return 0; -} - -int ext_diversity_change_gain(void *data) { - // - // value = (input-10000) * 0.1 - // - int val=GPOINTER_TO_INT(data); - double d = (val - 10000) * 0.1; - update_diversity_gain(d); - return 0; -} - -int ext_diversity_change_phase(void *data) { - // - // value = (input-10000) * 0.1 - // - int val=GPOINTER_TO_INT(data); - double d = (val - 10000) * 0.1; - update_diversity_phase(d); - return 0; -} - -int ext_set_rf_gain(void *data) { - int pos=GPOINTER_TO_INT(data); - double value; - value=(double)pos; - if(value<-12.0) { - value=-12.0; - } else if(value>48.0) { - value=48.0; - } - set_rf_gain(active_receiver->id,value); - return 0; -} - int ext_anf_update(void *data) { if(active_receiver->anf==0) { active_receiver->anf=1; @@ -1258,6 +1192,16 @@ int ext_anf_update(void *data) { return 0; } +int ext_mute_update(void *data) { + active_receiver->mute_radio=!active_receiver->mute_radio; + return 0; +} + +int ext_zoom_update(void *data) { + update_zoom((double)GPOINTER_TO_INT(data)); + return 0; +} + int ext_zoom_set(void *data) { int pos=GPOINTER_TO_INT(data); double zoom=((double)pos/(100.0/7.0))+1.0; @@ -1267,6 +1211,11 @@ int ext_zoom_set(void *data) { return 0; } +int ext_pan_update(void *data) { + update_pan((double)GPOINTER_TO_INT(data)); + return 0; +} + int ext_pan_set(void *data) { if(active_receiver->zoom>1) { int pos=GPOINTER_TO_INT(data); @@ -1276,8 +1225,21 @@ int ext_pan_set(void *data) { return 0; } -int ext_store_memory_slot(void *data) { - store_memory_slot(GPOINTER_TO_INT(data)); +int ext_remote_set_zoom(void *data) { + int zoom=GPOINTER_TO_INT(data); +g_print("ext_remote_set_zoom: %d\n",zoom); + remote_set_zoom(active_receiver->id,(double)zoom); + return 0; +} + +int ext_remote_set_pan(void *data) { + int pan=GPOINTER_TO_INT(data); +g_print("ext_remote_set_pan: %d\n",pan); + remote_set_pan(active_receiver->id,(double)pan); + return 0; +} + +int ext_set_title(void *data) { + gtk_window_set_title(GTK_WINDOW(top_window),(char *)data); return 0; } -#endif diff --git a/filter_menu.c b/filter_menu.c index 600b924..4654b03 100644 --- a/filter_menu.c +++ b/filter_menu.c @@ -44,6 +44,7 @@ static void cleanup() { gtk_widget_destroy(dialog); dialog=NULL; sub_menu=NULL; + active_menu=NO_MENU; } } diff --git a/iambic.c b/iambic.c index cba20c3..53ac9c6 100644 --- a/iambic.c +++ b/iambic.c @@ -241,26 +241,6 @@ extern int clock_nanosleep(clockid_t __clock_id, int __flags, struct timespec *__rem); #endif -static void keyer_straight_key(int state) { - // - // Interface for simple key-down action e.g. from a MIDI message - // - if (state != 0) { - cw_key_down=960000; // max. 20 sec to protect hardware - cw_key_up=0; - cw_key_hit=1; -#ifdef GPIO - gpio_cw_sidetone_set(1); -#endif - } else { - cw_key_down=0; - cw_key_up=0; -#ifdef GPIO - gpio_cw_sidetone_set(0); -#endif - } -} - void keyer_update() { // // This function will take notice of changes in the following variables @@ -456,7 +436,12 @@ static void* keyer_thread(void *arg) { // If both paddles are pressed (should not happen), then // the dash paddle wins. if (*kdash) { // send manual dashes - keyer_straight_key(1); // do key down + cw_key_down=960000; // max. 20 sec to protect hardware + cw_key_up=0; + cw_key_hit=1; +#ifdef GPIO + gpio_cw_sidetone_set(1); +#endif key_state=STRAIGHT; } } else { @@ -474,7 +459,11 @@ static void* keyer_thread(void *arg) { // Wait for dash paddle being released in "straight key" mode. // if (! *kdash) { - keyer_straight_key(0); // key-up + cw_key_down=0; + cw_key_up=0; +#ifdef GPIO + gpio_cw_sidetone_set(0); +#endif key_state=CHECK; } break; diff --git a/main.c b/main.c index 8e094eb..4fb2ced 100644 --- a/main.c +++ b/main.c @@ -41,8 +41,11 @@ #include "main.h" #include "channel.h" #include "discovered.h" +#ifdef GPIO +#include "actions.h" #include "configure.h" #include "gpio.h" +#endif #include "wdsp.h" #include "new_menu.h" #include "radio.h" @@ -173,10 +176,14 @@ gboolean main_delete (GtkWidget *widget) { static int init(void *data) { char wisdom_directory[1024]; - fprintf(stderr,"init\n"); + g_print("%s\n",__FUNCTION__); audio_get_cards(); + // wait for get_cards to complete + //g_mutex_lock(&audio_mutex); + //g_mutex_unlock(&audio_mutex); + cursor_arrow=gdk_cursor_new(GDK_ARROW); cursor_watch=gdk_cursor_new(GDK_WATCH); diff --git a/meter.c b/meter.c index 462a334..9371266 100644 --- a/meter.c +++ b/meter.c @@ -195,13 +195,13 @@ if(analog_meter) { 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) { @@ -563,13 +563,13 @@ if(analog_meter) { 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) { diff --git a/midi3.c b/midi3.c index 3fc1b05..46141a6 100644 --- a/midi3.c +++ b/midi3.c @@ -196,7 +196,7 @@ int DoTheRestOfTheMIDI(void *data) { } 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; @@ -805,12 +805,12 @@ int DoTheRestOfTheMIDI(void *data) { /////////////////////////////////////////////////////////// "RFGAIN" case MIDI_ACTION_RF_GAIN: // knob or wheel supported if (type == MIDI_TYPE_KNOB) { - dnew=-12.0 + 0.6*val; + dnew=val; } else if (type == MIDI_TYPE_WHEEL) { - dnew=active_receiver->rf_gain+val; + dnew=adc[active_receiver->id].gain+val; } - if (dnew < -12.0) dnew = -12.0; - if (dnew > 48.0) dnew = 48.0; + if (dnew < 0.0) dnew = 0.0; + if (dnew > 100.0) dnew = 100.0; set_rf_gain(active_receiver->id, dnew); break; /////////////////////////////////////////////////////////// "RFPOWER" diff --git a/mode_menu.c b/mode_menu.c index 7f5e910..b992d82 100644 --- a/mode_menu.c +++ b/mode_menu.c @@ -45,6 +45,7 @@ static void cleanup() { gtk_widget_destroy(dialog); dialog=NULL; sub_menu=NULL; + active_menu=NO_MENU; } } diff --git a/new_menu.c b/new_menu.c index e1ed1e1..b8311cb 100644 --- a/new_menu.c +++ b/new_menu.c @@ -57,7 +57,10 @@ #include "vfo_menu.h" #include "fft_menu.h" #include "main.h" +#ifdef GPIO #include "gpio.h" +#include "actions.h" +#endif #include "old_protocol.h" #include "new_protocol.h" #ifdef CLIENT_SERVER @@ -186,11 +189,13 @@ static gboolean rigctl_cb (GtkWidget *widget, GdkEventButton *event, gpointer da return TRUE; } +#ifdef GPIO static gboolean encoder_cb (GtkWidget *widget, GdkEventButton *event, gpointer data) { cleanup(); encoder_menu(top_window); return TRUE; } +#endif static gboolean switch_cb (GtkWidget *widget, GdkEventButton *event, gpointer data) { cleanup(); @@ -407,47 +412,6 @@ static gboolean ps_cb (GtkWidget *widget, GdkEventButton *event, gpointer data) } #endif -#ifdef GPIO -/* -void start_encoder(int encoder) { - int old_menu=active_menu; - cleanup(); - switch(encoder) { - case 2: - if(old_menu!=E2_MENU) { - encoder_menu(top_window,encoder); - active_menu=E2_MENU; - } - break; - case 3: - if(old_menu!=E3_MENU) { - encoder_menu(top_window,encoder); - active_menu=E3_MENU; - } - break; - case 4: - if(old_menu!=E4_MENU) { - encoder_menu(top_window,encoder); - active_menu=E4_MENU; - } - break; - case 5: - if(old_menu!=E5_MENU) { - encoder_menu(top_window,encoder); - active_menu=E5_MENU; - } - break; - } -} - -static gboolean encoder_cb (GtkWidget *widget, GdkEventButton *event, gpointer data) { - int encoder=(int)data; - start_encoder(encoder); - return TRUE; -} -*/ -#endif - void start_test() { cleanup(); test_menu(top_window); @@ -627,19 +591,32 @@ void new_menu() gtk_grid_attach(GTK_GRID(grid),rigctl_b,(i%5),i/5,1,1); i++; + switch(controller) { + case NO_CONTROLLER: + { + GtkWidget *switches_b=gtk_button_new_with_label("Switches"); + g_signal_connect (switches_b, "button-press-event", G_CALLBACK(switch_cb), NULL); + gtk_grid_attach(GTK_GRID(grid),switches_b,(i%5),i/5,1,1); + i++; + } + break; + case CONTROLLER1: + case CONTROLLER2_V1: + case CONTROLLER2_V2: + { #ifdef GPIO - GtkWidget *encoders_b=gtk_button_new_with_label("Encoders"); - g_signal_connect (encoders_b, "button-press-event", G_CALLBACK(encoder_cb), NULL); - gtk_grid_attach(GTK_GRID(grid),encoders_b,(i%5),i/5,1,1); - i++; - - if(controller==CONTROLLER2_V1 || controller==CONTROLLER2_V2) { - GtkWidget *switches_b=gtk_button_new_with_label("Switches"); - g_signal_connect (switches_b, "button-press-event", G_CALLBACK(switch_cb), NULL); - gtk_grid_attach(GTK_GRID(grid),switches_b,(i%5),i/5,1,1); - i++; - } + GtkWidget *encoders_b=gtk_button_new_with_label("Encoders"); + g_signal_connect (encoders_b, "button-press-event", G_CALLBACK(encoder_cb), NULL); + gtk_grid_attach(GTK_GRID(grid),encoders_b,(i%5),i/5,1,1); + i++; #endif + GtkWidget *switches_b=gtk_button_new_with_label("Switches"); + g_signal_connect (switches_b, "button-press-event", G_CALLBACK(switch_cb), NULL); + gtk_grid_attach(GTK_GRID(grid),switches_b,(i%5),i/5,1,1); + i++; + } + break; + } #ifdef MIDI GtkWidget *midi_b=gtk_button_new_with_label("MIDI"); diff --git a/new_protocol.c b/new_protocol.c index aab24a1..4c1b3dd 100644 --- a/new_protocol.c +++ b/new_protocol.c @@ -77,8 +77,8 @@ #define RXACTION_PS 2 // deliver 2*119 samples to PS engine #define RXACTION_DIV 3 // take 2*119 samples, mix them, deliver to a receiver -static int rxcase[MAX_DDC]; -static int rxid [MAX_DDC]; +static int rxcase[7/*MAX_DDC*/]; +static int rxid [7/*MAX_DDC*/]; int data_socket=-1; @@ -111,8 +111,8 @@ static int audio_addr_length; static struct sockaddr_in iq_addr; static int iq_addr_length; -static struct sockaddr_in data_addr[MAX_DDC]; -static int data_addr_length[MAX_DDC]; +static struct sockaddr_in data_addr[7/*MAX_DDC*/]; +static int data_addr_length[7/*MAX_DDC*/]; static GThread *new_protocol_thread_id; static GThread *new_protocol_timer_thread_id; @@ -121,7 +121,7 @@ static long high_priority_sequence = 0; static long general_sequence = 0; static long rx_specific_sequence = 0; static long tx_specific_sequence = 0; -static long ddc_sequence[MAX_DDC]; +static long ddc_sequence[7/*MAX_DDC*/]; //static int buffer_size=BUFFER_SIZE; //static int fft_size=4096; @@ -177,13 +177,13 @@ static sem_t mic_line_sem_buffer; #endif static GThread *mic_line_thread_id; #ifdef __APPLE__ -static sem_t *iq_sem_ready[MAX_DDC]; -static sem_t *iq_sem_buffer[MAX_DDC]; +static sem_t *iq_sem_ready[7/*MAX_DDC*/]; +static sem_t *iq_sem_buffer[7/*MAX_DDC*/]; #else -static sem_t iq_sem_ready[MAX_DDC]; -static sem_t iq_sem_buffer[MAX_DDC]; +static sem_t iq_sem_ready[7/*MAX_DDC*/]; +static sem_t iq_sem_buffer[7/*MAX_DDC*/]; #endif -static GThread *iq_thread_id[MAX_DDC]; +static GThread *iq_thread_id[7/*MAX_DDC*/]; #ifdef INCLUDED static int outputsamples; @@ -243,7 +243,7 @@ static mybuffer *buflist = NULL; // // The buffers used by new_protocol_thread // -static mybuffer *iq_buffer[MAX_DDC]; +static mybuffer *iq_buffer[7/*MAX_DDC*/]; static mybuffer *command_response_buffer; static mybuffer *high_priority_buffer; static mybuffer *mic_line_buffer; @@ -267,7 +267,7 @@ static pthread_mutex_t rx_spec_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t tx_spec_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t hi_prio_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t general_mutex = PTHREAD_MUTEX_INITIALIZER; -static pthread_mutex_t audio_mutex = PTHREAD_MUTEX_INITIALIZER; +static pthread_mutex_t p2_audio_mutex = PTHREAD_MUTEX_INITIALIZER; static int local_ptt=0; @@ -478,13 +478,6 @@ void new_protocol_init(int pixels) { #endif micoutputsamples=buffer_size*4; -// if(local_audio) { -// if(audio_open_output()!=0) { -// g_print("audio_open_output failed\n"); -// local_audio=0; -// } -// } - if(transmitter->local_microphone) { if(audio_open_input()!=0) { g_print("audio_open_input failed\n"); @@ -1192,11 +1185,11 @@ static void new_protocol_high_priority() { 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; } } @@ -2002,7 +1995,7 @@ void new_protocol_cw_audio_samples(short left_audio_sample,short right_audio_sam // // Only process samples if transmitting in CW // - pthread_mutex_lock(&audio_mutex); + pthread_mutex_lock(&p2_audio_mutex); // insert the samples audiobuffer[audioindex++]=left_audio_sample>>8; audiobuffer[audioindex++]=left_audio_sample; @@ -2024,7 +2017,7 @@ void new_protocol_cw_audio_samples(short left_audio_sample,short right_audio_sam audioindex=4; audiosequence++; } - pthread_mutex_unlock(&audio_mutex); + pthread_mutex_unlock(&p2_audio_mutex); } } @@ -2037,7 +2030,7 @@ void new_protocol_audio_samples(RECEIVER *rx,short left_audio_sample,short right // if (isTransmitting() && (txmode==modeCWU || txmode==modeCWL)) return; - pthread_mutex_lock(&audio_mutex); + pthread_mutex_lock(&p2_audio_mutex); // insert the samples audiobuffer[audioindex++]=left_audio_sample>>8; audiobuffer[audioindex++]=left_audio_sample; @@ -2061,7 +2054,7 @@ void new_protocol_audio_samples(RECEIVER *rx,short left_audio_sample,short right audioindex=4; audiosequence++; } - pthread_mutex_unlock(&audio_mutex); + pthread_mutex_unlock(&p2_audio_mutex); } void new_protocol_flush_iq_samples() { diff --git a/noise_menu.c b/noise_menu.c index f426b97..433faa9 100644 --- a/noise_menu.c +++ b/noise_menu.c @@ -47,6 +47,7 @@ static void cleanup() { gtk_widget_destroy(dialog); dialog=NULL; sub_menu=NULL; + active_menu=NO_MENU; } } diff --git a/oc_menu.c b/oc_menu.c index 3342545..5da076f 100644 --- a/oc_menu.c +++ b/oc_menu.c @@ -224,7 +224,7 @@ g_print("oc_menu: parent=%p\n",parent); BAND *band=band_get_band(i); if(strlen(band->title)>0) { GtkWidget *band_label=gtk_label_new(NULL); - char band_text[24]; + char band_text[32]; sprintf(band_text,"%s",band->title); gtk_label_set_markup(GTK_LABEL(band_label), band_text); //gtk_widget_override_font(band_label, pango_font_description_from_string("Arial 18")); diff --git a/old_protocol.c b/old_protocol.c index fab5d03..229f1a9 100644 --- a/old_protocol.c +++ b/old_protocol.c @@ -1655,7 +1655,7 @@ void ozy_send_buffer() { // 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 @@ -1685,7 +1685,7 @@ void ozy_send_buffer() { 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; @@ -1703,9 +1703,9 @@ void ozy_send_buffer() { } 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[receiver[0]->adc].attenuation & 0x1F); } else { - output_buffer[C1]=0x20 | (adc_attenuation[receiver[1]->adc] & 0x1F); + output_buffer[C1]=0x20 | (adc[receiver[1]->adc].attenuation & 0x1F); } } } diff --git a/portaudio.c b/portaudio.c index dfb4e89..c68d1f7 100644 --- a/portaudio.c +++ b/portaudio.c @@ -577,8 +577,7 @@ int audio_write (RECEIVER *rx, float left, float right) // // Thus we have an active latency management. // -int cw_audio_write(float sample) { - RECEIVER *rx = active_receiver; +int cw_audio_write(RECEIVER *rx, float sample) { float *buffer = rx->local_audio_buffer; int oldpt, newpt; static int count=0; diff --git a/property.c b/property.c index 923daba..860bf91 100644 --- a/property.c +++ b/property.c @@ -48,7 +48,7 @@ g_print("clearProperties\n"); * @param filename */ void loadProperties(char* filename) { - char string[80]; + char string[256]; char* name; char* value; FILE* f=fopen(filename,"r"); diff --git a/radio.c b/radio.c index 84f1837..0479746 100644 --- a/radio.c +++ b/radio.c @@ -55,6 +55,7 @@ #include "soapy_protocol.h" #endif #ifdef GPIO +##include "actions.h" #include "gpio.h" #endif #include "vfo.h" @@ -134,10 +135,20 @@ gboolean radio_is_remote=FALSE; char property_path[128]; GMutex property_mutex; -RECEIVER *receiver[MAX_RECEIVERS]; +RECEIVER *receiver[7]; RECEIVER *active_receiver; TRANSMITTER *transmitter; +int RECEIVERS; +int MAX_RECEIVERS; +int MAX_DDC; +#ifdef PURESIGNAL +int PS_TX_FEEDBACK; +int PS_RX_FEEDBACK; +#endif + + + int buffer_size=1024; // 64, 128, 256, 512, 1024, 2048 int fft_size=2048; // 1024, 2048, 4096, 8192, 16384 @@ -169,7 +180,7 @@ int panadapter_high=-40; int panadapter_low=-140; int display_filled=1; -int display_gradient=0; +int display_gradient=1; int display_detector_mode=DETECTOR_MODE_AVERAGE; int display_average_mode=AVERAGE_MODE_LOG_RECURSIVE; double display_average_time=120.0; @@ -203,11 +214,11 @@ int mic_ptt_tip_bias_ring=0; //int drive_level=0; //int tune_drive_level=0; -int receivers=RECEIVERS; +int receivers; ADC adc[2]; DAC dac[2]; -int adc_attenuation[2]; +//int adc_attenuation[2]; int locked=0; @@ -561,27 +572,29 @@ if(!radio_is_remote) { calcDriveLevel(); #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); - switch (protocol) { - case NEW_PROTOCOL: - pk = 0.2899; - break; - case ORIGINAL_PROTOCOL: - switch (device) { - case DEVICE_HERMES_LITE2: - pk = 0.2300; - break; - default: - pk = 0.4067; - break; - } + if(protocol==NEW_PROTOCOL || protocol==ORIGINAL_PROTOCOL) { + 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); + switch (protocol) { + case NEW_PROTOCOL: + pk = 0.2899; + break; + case ORIGINAL_PROTOCOL: + switch (device) { + case DEVICE_HERMES_LITE2: + pk = 0.2300; + break; + default: + pk = 0.4067; + break; + } + } + SetPSHWPeak(transmitter->id, pk); } - SetPSHWPeak(transmitter->id, pk); #endif - } + #ifdef CLIENT_SERVER } #endif @@ -1104,6 +1117,7 @@ void start_radio() { } #endif + /* adc_attenuation[0]=0; adc_attenuation[1]=0; @@ -1111,6 +1125,7 @@ void start_radio() { adc_attenuation[0]=14; adc_attenuation[1]=14; } + */ adc[0].antenna=ANTENNA_1; adc[0].filters=AUTOMATIC; @@ -1119,7 +1134,11 @@ void start_radio() { 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) { @@ -1144,7 +1163,11 @@ void start_radio() { 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) { @@ -1169,17 +1192,17 @@ void start_radio() { #ifdef GPIO switch(controller) { + case NO_CONTROLLER: + display_zoompan=1; + display_sliders=1; + display_toolbar=1; + break; case CONTROLLER2_V1: case CONTROLLER2_V2: display_zoompan=1; display_sliders=0; display_toolbar=0; break; - default: - display_zoompan=1; - display_sliders=1; - display_toolbar=1; - break; } #else display_zoompan=1; @@ -1198,6 +1221,36 @@ void start_radio() { display_sequence_errors=TRUE; + g_print("%s: setup RECEIVERS protocol=%d\n",__FUNCTION__,protocol); + switch(protocol) { +#ifdef SOAPYSDR + case SOAPYSDR_PROTOCOL: + g_print("%s: setup RECEIVERS SOAPYSDR\n",__FUNCTION__); + RECEIVERS=1; + MAX_RECEIVERS=RECEIVERS; +#ifdef PURESIGNAL + PS_TX_FEEDBACK=0; + PS_RX_FEEDBACK=0; +#endif + MAX_DDC=1; + break; +#endif + default: + g_print("%s: setup RECEIVERS default\n",__FUNCTION__); + RECEIVERS=2; +#ifdef PURESIGNAL + MAX_RECEIVERS=(RECEIVERS+2); + PS_TX_FEEDBACK=(RECEIVERS); + PS_RX_FEEDBACK=(RECEIVERS+1); +#else + MAX_RECEIVERS=RECEIVERS; +#endif + MAX_DDC=(RECEIVERS+2); + break; + } + + receivers=RECEIVERS; + radioRestoreState(); // @@ -1484,6 +1537,7 @@ static void rxtx(int state) { void setMox(int state) { if(!can_transmit) return; + // SOAPY and no local mic: continue! e.g. for doing CW. vox_cancel(); // remove time-out if(mox!=state) { if (state && vox) { @@ -1808,6 +1862,12 @@ void setSquelch(RECEIVER *rx) { SetRXAFMSQRun(rx->id, rx->squelch_enable); } +void radio_set_rf_gain(RECEIVER *rx) { +#ifdef SOAPYSDR + soapy_protocol_set_gain_element(rx,radio->info.soapy.rx_gain[rx->adc],(int)adc[rx->adc].gain); +#endif +} + void set_attenuation(int value) { switch(protocol) { case NEW_PROTOCOL: @@ -1815,8 +1875,8 @@ void set_attenuation(int value) { break; #ifdef SOAPYSDR case SOAPYSDR_PROTOCOL: - soapy_protocol_set_gain_element(active_receiver,radio->info.soapy.rx_gain[0],(int)adc[0].gain); - break; + soapy_protocol_set_gain_element(active_receiver,radio->info.soapy.rx_gain[0],(int)adc[0].gain); + break; #endif } } @@ -1839,6 +1899,7 @@ void set_alex_rx_antenna() { schedule_high_priority(); break; } + // This function is NOT called for SOAPY devices } // @@ -1902,6 +1963,8 @@ g_print("radioRestoreState: %s\n",property_path); #endif } else { #endif + value=getProperty("radio_sample_rate"); + if (value) radio_sample_rate=atoi(value); value=getProperty("diversity_enabled"); if (value) diversity_enabled=atoi(value); value=getProperty("diversity_gain"); @@ -2226,9 +2289,7 @@ g_print("radioSaveState: %s\n",property_path); g_mutex_lock(&property_mutex); clearProperties(); #ifdef GPIO - if(controller!=NO_CONTROLLER) { - gpio_save_actions(); - } + gpio_save_actions(); #endif sprintf(value,"%d",receivers); setProperty("receivers",value); @@ -2462,6 +2523,11 @@ g_print("radioSaveState: %s\n",property_path); } #endif + sprintf(value,"%d", dac[0].antenna); + setProperty("radio.dac[0].antenna",value); + sprintf(value,"%f", dac[0].gain); + setProperty("radio.dac[0].gain",value); + if(receivers>1) { sprintf(value,"%d", adc[1].filters); setProperty("radio.adc[1].filters",value); diff --git a/radio.h b/radio.h index fb77263..93236e3 100644 --- a/radio.h +++ b/radio.h @@ -67,8 +67,6 @@ enum { PA_500W }; -extern gint controller; - extern DISCOVERED *radio; #ifdef CLIENT_SERVER extern gboolean radio_is_remote; @@ -91,16 +89,15 @@ extern char property_path[]; extern int region; -// specify how many receivers: for PURESIGNAL need two extra -#define RECEIVERS 2 +extern int RECEIVERS; +extern int MAX_RECEIVERS; +extern int MAX_DDC; + + #ifdef PURESIGNAL -#define MAX_RECEIVERS (RECEIVERS+2) -#define PS_TX_FEEDBACK (RECEIVERS) -#define PS_RX_FEEDBACK (RECEIVERS+1) -#else -#define MAX_RECEIVERS RECEIVERS +extern int PS_TX_FEEDBACK; +extern int PS_RX_FEEDBACK; #endif -#define MAX_DDC (RECEIVERS+2) extern RECEIVER *receiver[]; extern RECEIVER *active_receiver; @@ -192,7 +189,7 @@ extern int receivers; extern ADC adc[2]; extern DAC dac[2]; -extern int adc_attenuation[2]; +//extern int adc_attenuation[2]; extern int locked; @@ -351,6 +348,8 @@ extern void setTuneDrive(double d); extern void calcTuneDriveLevel(); extern void setSquelch(RECEIVER *rx); +extern void radio_set_rf_gain(RECEIVER *rx); + extern void set_attenuation(int value); extern void set_alex_rx_antenna(void); extern void set_alex_tx_antenna(void); diff --git a/radio_menu.c b/radio_menu.c index 360261e..aa63c64 100644 --- a/radio_menu.c +++ b/radio_menu.c @@ -39,7 +39,10 @@ #ifdef SOAPYSDR #include "soapy_protocol.h" #endif +#ifdef GPIO +#include "actions.h" #include "gpio.h" +#endif #include "vfo.h" #include "ext.h" #ifdef CLIENT_SERVER @@ -172,9 +175,11 @@ static void vfo_divisor_value_changed_cb(GtkWidget *widget, gpointer data) { vfo_encoder_divisor=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget)); } +#ifdef GPIO static void gpio_settle_value_changed_cb(GtkWidget *widget, gpointer data) { settle_time=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget)); } +#endif /* static void toolbar_dialog_buttons_cb(GtkWidget *widget, gpointer data) { @@ -668,23 +673,23 @@ void radio_menu(GtkWidget *parent) { row=1; GtkWidget *rit_label=gtk_label_new(NULL); - gtk_label_set_markup(GTK_LABEL(rit_label), "RIT(XIT) step (Hz):"); + gtk_label_set_markup(GTK_LABEL(rit_label), "RIT/XIT step (Hz):"); gtk_grid_attach(GTK_GRID(grid),rit_label,col,row,1,1); row++; - GtkWidget *rit_1=gtk_radio_button_new_with_label(NULL,"1(10)"); + GtkWidget *rit_1=gtk_radio_button_new_with_label(NULL,"1/10"); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (rit_1), rit_increment==1); gtk_grid_attach(GTK_GRID(grid),rit_1,col,row,1,1); g_signal_connect(rit_1,"pressed",G_CALLBACK(rit_cb),(gpointer *)1); row++; - GtkWidget *rit_10=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(rit_1),"10(100)"); + GtkWidget *rit_10=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(rit_1),"10/100"); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (rit_10), rit_increment==10); gtk_grid_attach(GTK_GRID(grid),rit_10,col,row,1,1); g_signal_connect(rit_10,"pressed",G_CALLBACK(rit_cb),(gpointer *)10); row++; - GtkWidget *rit_100=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(rit_10),"100(1000)"); + GtkWidget *rit_100=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(rit_10),"100/1000"); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (rit_100), rit_increment==100); gtk_grid_attach(GTK_GRID(grid),rit_100,col,row,1,1); g_signal_connect(rit_100,"pressed",G_CALLBACK(rit_cb),(gpointer *)100); @@ -839,7 +844,6 @@ void radio_menu(GtkWidget *parent) { col=0; if(radio->device==SOAPYSDR_USB_DEVICE) { int i; -/* if(radio->info.soapy.rx_gains>0) { GtkWidget *rx_gain=gtk_label_new(NULL); gtk_label_set_markup(GTK_LABEL(rx_gain), "RX Gains:"); @@ -858,50 +862,47 @@ void radio_menu(GtkWidget *parent) { row++; temp_row=row; -*/ col=0; -/* - //rx_gains=g_new(GtkWidget*,radio->info.soapy.rx_gains); - for(i=0;iinfo.soapy.rx_gains;i++) { + if(strcmp(radio->name,"sdrplay")==0 || strcmp(radio->name,"rtlsdr")==0) { + for(i=0;iinfo.soapy.rx_gains;i++) { + col=0; + GtkWidget *rx_gain_label=gtk_label_new(radio->info.soapy.rx_gain[i]); + gtk_grid_attach(GTK_GRID(grid),rx_gain_label,col,row,1,1); + col++; + SoapySDRRange range=radio->info.soapy.rx_range[i]; + if(range.step==0.0) { + range.step=1.0; + } + rx_gains[i]=gtk_spin_button_new_with_range(range.minimum,range.maximum,range.step); + gtk_widget_set_name (rx_gains[i], radio->info.soapy.rx_gain[i]); + int value=soapy_protocol_get_gain_element(active_receiver,radio->info.soapy.rx_gain[i]); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(rx_gains[i]),(double)value); + gtk_grid_attach(GTK_GRID(grid),rx_gains[i],col,row,1,1); + g_signal_connect(rx_gains[i],"value_changed",G_CALLBACK(rx_gain_value_changed_cb),&adc[0]); + + row++; + } + } else { + // used single gain control - LimeSDR works out best setting for the 3 rx gains col=0; - GtkWidget *rx_gain_label=gtk_label_new(radio->info.soapy.rx_gain[i]); - gtk_grid_attach(GTK_GRID(grid),rx_gain_label,col,row,1,1); + GtkWidget *rf_gain_label=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(rf_gain_label), "RF Gain"); + gtk_grid_attach(GTK_GRID(grid),rf_gain_label,col,row,1,1); col++; - SoapySDRRange range=radio->info.soapy.rx_range[i]; - if(range.step==0.0) { - range.step=1.0; + double max=100; + if(strcmp(radio->name,"lime")==0) { + max=60.0; + } else if(strcmp(radio->name,"plutosdr")==0) { + max=73.0; } - rx_gains[i]=gtk_spin_button_new_with_range(range.minimum,range.maximum,range.step); - gtk_widget_set_name (rx_gains[i], radio->info.soapy.rx_gain[i]); - int value=soapy_protocol_get_gain_element(active_receiver,radio->info.soapy.rx_gain[i]); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(rx_gains[i]),(double)value); - //gtk_spin_button_set_value(GTK_SPIN_BUTTON(rx_gains[i]),(double)adc[0].rx_gain[i]); - gtk_grid_attach(GTK_GRID(grid),rx_gains[i],col,row,1,1); - g_signal_connect(rx_gains[i],"value_changed",G_CALLBACK(rx_gain_value_changed_cb),&adc[0]); - - gtk_widget_set_sensitive(rx_gains[i], FALSE); + 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]); row++; } -*/ - // used single gain control - LimeSDR works out best setting for the 3 rx gains - col=0; - GtkWidget *rf_gain_label=gtk_label_new(NULL); - gtk_label_set_markup(GTK_LABEL(rf_gain_label), "RF Gain"); - gtk_grid_attach(GTK_GRID(grid),rf_gain_label,col,row,1,1); - col++; - double max=100; - if(strcmp(radio->name,"lime")==0) { - max=60.0; - } else if(strcmp(radio->name,"plutosdr")==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_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]); - - row++; if(radio->info.soapy.rx_has_automatic_gain) { GtkWidget *agc=gtk_check_button_new_with_label("Hardware AGC: "); diff --git a/receiver.c b/receiver.c index a073e71..c83d70f 100644 --- a/receiver.c +++ b/receiver.c @@ -69,7 +69,7 @@ static int waterfall_resample=6; void receiver_weak_notify(gpointer data,GObject *obj) { RECEIVER *rx=(RECEIVER *)data; - fprintf(stderr,"receiver_weak_notify: id=%d obj=%p\n",rx->id, obj); + g_print("%s: id=%d obj=%p\n",__FUNCTION__,rx->id, obj); } gboolean receiver_button_press_event(GtkWidget *widget, GdkEventButton *event, gpointer data) { @@ -194,7 +194,7 @@ void receiver_save_state(RECEIVER *rx) { char name[128]; char value[128]; - g_print("receiver_save_state: %d\n",rx->id); + g_print("%s: %d\n",__FUNCTION__,rx->id); sprintf(name,"receiver.%d.audio_channel",rx->id); sprintf(value,"%d",rx->audio_channel); setProperty(name,value); @@ -231,7 +231,11 @@ void receiver_save_state(RECEIVER *rx) { // for PS_RX_RECEIVER, *only* save the ALEX antenna setting // and then return quickly. // - if (rx->id == PS_RX_FEEDBACK) return; + if (rx->id == PS_RX_FEEDBACK +#ifdef SOAPYSDR + && protocol!=SOAPYSDR_PROTOCOL +#endif + ) return; #endif sprintf(name,"receiver.%d.sample_rate",rx->id); @@ -277,9 +281,9 @@ void receiver_save_state(RECEIVER *rx) { 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); @@ -363,7 +367,7 @@ void receiver_restore_state(RECEIVER *rx) { char name[128]; char *value; -fprintf(stderr,"receiver_restore_state: id=%d\n",rx->id); +g_print("%s: id=%d\n",__FUNCTION__,rx->id); sprintf(name,"receiver.%d.audio_channel",rx->id); value=getProperty(name); @@ -404,7 +408,11 @@ fprintf(stderr,"receiver_restore_state: id=%d\n",rx->id); // for PS_RX_RECEIVER, *only* restore the ALEX antenna and setting // and then return quickly // - if (rx->id == PS_RX_FEEDBACK) return; + if (rx->id == PS_RX_FEEDBACK +#ifdef SOAPYSDR + && protocol!=SOAPYSDR_PROTOCOL +#endif + ) return; #endif sprintf(name,"receiver.%d.sample_rate",rx->id); @@ -471,9 +479,9 @@ fprintf(stderr,"receiver_restore_state: id=%d\n",rx->id); 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); @@ -568,12 +576,11 @@ void reconfigure_receiver(RECEIVER *rx,int height) { if(rx->display_panadapter) { if(rx->panadapter==NULL) { -fprintf(stderr,"reconfigure_receiver: panadapter_init: width:%d height:%d\n",rx->width,myheight); +g_print("%s: panadapter_init: width:%d height:%d\n",__FUNCTION__,rx->width,myheight); rx_panadapter_init(rx, rx->width,myheight); gtk_fixed_put(GTK_FIXED(rx->panel),rx->panadapter,0,y); // y=0 here always } else { // set the size -//fprintf(stderr,"reconfigure_receiver: panadapter set_size_request: width:%d height:%d\n",rx->width,myheight); gtk_widget_set_size_request(rx->panadapter, rx->width, myheight); // move the current one gtk_fixed_move(GTK_FIXED(rx->panel),rx->panadapter,0,y); @@ -589,12 +596,12 @@ fprintf(stderr,"reconfigure_receiver: panadapter_init: width:%d height:%d\n",rx- if(rx->display_waterfall) { if(rx->waterfall==NULL) { -fprintf(stderr,"reconfigure_receiver: waterfall_init: width:%d height:%d\n",rx->width,myheight); +g_print("%s: waterfall_init: width:%d height:%d\n",__FUNCTION__,rx->width,myheight); waterfall_init(rx,rx->width,myheight); gtk_fixed_put(GTK_FIXED(rx->panel),rx->waterfall,0,y); // y=0 if ONLY waterfall is present } else { // set the size -fprintf(stderr,"reconfigure_receiver: waterfall set_size_request: width:%d height:%d\n",rx->width,myheight); +g_print("%s: waterfall set_size_request: width:%d height:%d\n",__FUNCTION__,rx->width,myheight); gtk_widget_set_size_request(rx->waterfall, rx->width, myheight); // move the current one gtk_fixed_move(GTK_FIXED(rx->panel),rx->waterfall,0,y); @@ -615,8 +622,6 @@ static gint update_display(gpointer data) { RECEIVER *rx=(RECEIVER *)data; int rc; -//g_print("update_display: rx=%d displaying=%d\n",rx->id,rx->displaying); - if(rx->displaying) { if(rx->pixels>0) { g_mutex_lock(&rx->display_mutex); @@ -744,8 +749,6 @@ void set_agc(RECEIVER *rx, int agc) { } void set_offset(RECEIVER *rx,long long offset) { -//fprintf(stderr,"set_offset: id=%d ofset=%lld\n",rx->id,offset); -//fprintf(stderr,"set_offset: frequency=%lld ctun_freqeuncy=%lld offset=%lld\n",vfo[rx->id].frequency,vfo[rx->id].ctun_frequency,vfo[rx->id].offset); if(offset==0) { SetRXAShiftFreq(rx->id, (double)offset); RXANBPSetShiftFrequency(rx->id, (double)offset); @@ -780,7 +783,7 @@ static void init_analyzer(RECEIVER *rx) { overlap = (int)fmax(0.0, ceil(fft_size - (double)rx->sample_rate / (double)rx->fps)); - //g_print("SetAnalyzer id=%d buffer_size=%d overlap=%d\n",rx->id,rx->buffer_size,overlap); + //g_print("%s: id=%d buffer_size=%d overlap=%d\n",_FUNCTION__,rx->id,rx->buffer_size,overlap); SetAnalyzer(rx->id, @@ -811,7 +814,7 @@ static void create_visual(RECEIVER *rx) { int y=0; rx->panel=gtk_fixed_new(); -fprintf(stderr,"receiver: create_visual: id=%d width=%d height=%d %p\n",rx->id, rx->width, rx->height, rx->panel); +g_print("%s: id=%d width=%d height=%d %p\n",__FUNCTION__,rx->id, rx->width, rx->height, rx->panel); g_object_weak_ref(G_OBJECT(rx->panel),receiver_weak_notify,(gpointer)rx); gtk_widget_set_size_request (rx->panel, rx->width, rx->height); @@ -824,14 +827,14 @@ fprintf(stderr,"receiver: create_visual: id=%d width=%d height=%d %p\n",rx->id, } rx_panadapter_init(rx, rx->width,height); -fprintf(stderr,"receiver: panadapter_init: height=%d y=%d %p\n",height,y,rx->panadapter); +g_print("%s: panadapter height=%d y=%d %p\n",__FUNCTION__,height,y,rx->panadapter); g_object_weak_ref(G_OBJECT(rx->panadapter),receiver_weak_notify,(gpointer)rx); gtk_fixed_put(GTK_FIXED(rx->panel),rx->panadapter,0,y); y+=height; if(rx->display_waterfall) { waterfall_init(rx,rx->width,height); -fprintf(stderr,"receiver: waterfall_init: height=%d y=%d %p\n",height,y,rx->waterfall); +g_print("%ss: waterfall height=%d y=%d %p\n",__FUNCTION__,height,y,rx->waterfall); g_object_weak_ref(G_OBJECT(rx->waterfall),receiver_weak_notify,(gpointer)rx); gtk_fixed_put(GTK_FIXED(rx->panel),rx->waterfall,0,y); } @@ -841,7 +844,7 @@ fprintf(stderr,"receiver: waterfall_init: height=%d y=%d %p\n",height,y,rx->wate #ifdef PURESIGNAL RECEIVER *create_pure_signal_receiver(int id, int buffer_size,int sample_rate,int width) { -fprintf(stderr,"create_pure_signal_receiver: id=%d buffer_size=%d\n",id,buffer_size); +g_print("%s: id=%d buffer_size=%d\n",__FUNCTION__,id,buffer_size); RECEIVER *rx=malloc(sizeof(RECEIVER)); rx->id=id; @@ -896,7 +899,7 @@ fprintf(stderr,"create_pure_signal_receiver: id=%d buffer_size=%d\n",id,buffer_s rx->panadapter_step=20; rx->volume=5.0; - rx->rf_gain=50.0; + //rx->rf_gain=50.0; rx->squelch_enable=0; rx->squelch=0; @@ -925,7 +928,12 @@ fprintf(stderr,"create_pure_signal_receiver: id=%d buffer_size=%d\n",id,buffer_s rx->agc_slope=35.0; rx->agc_hang_threshold=0.0; +#if defined(ALSAAUDIO) || defined(PORTAUDIO) rx->playback_handle=NULL; +#endif +#ifdef PULSEAUDIO + rx->playstream=NULL; +#endif rx->local_audio_buffer=NULL; rx->local_audio_buffer_size=2048; rx->local_audio=0; @@ -944,7 +952,7 @@ fprintf(stderr,"create_pure_signal_receiver: id=%d buffer_size=%d\n",id,buffer_s int result; XCreateAnalyzer(rx->id, &result, 262144, 1, 1, ""); if(result != 0) { - fprintf(stderr, "XCreateAnalyzer id=%d failed: %d\n", rx->id, result); + g_print( "%s: XCreateAnalyzer id=%d failed: %d\n",__FUNCTION__, rx->id, result); } else { init_analyzer(rx); } @@ -961,7 +969,7 @@ fprintf(stderr,"create_pure_signal_receiver: id=%d buffer_size=%d\n",id,buffer_s #endif RECEIVER *create_receiver(int id, int buffer_size, int fft_size, int pixels, int fps, int width, int height) { -fprintf(stderr,"create_receiver: id=%d buffer_size=%d fft_size=%d pixels=%d fps=%d\n",id,buffer_size, fft_size, pixels, fps); +g_print("%s: id=%d buffer_size=%d fft_size=%d pixels=%d fps=%d\n",__FUNCTION__,id,buffer_size, fft_size, pixels, fps); RECEIVER *rx=malloc(sizeof(RECEIVER)); rx->id=id; g_mutex_init(&rx->mutex); @@ -998,12 +1006,13 @@ fprintf(stderr,"create_receiver: id=%d buffer_size=%d fft_size=%d pixels=%d fps= break; } } -fprintf(stderr,"create_receiver: id=%d default adc=%d\n",rx->id, rx->adc); +g_print("%s: id=%d default adc=%d\n",__FUNCTION__,rx->id, rx->adc); #ifdef SOAPYSDR if(radio->device==SOAPYSDR_USB_DEVICE) { rx->sample_rate=radio->info.soapy.sample_rate; rx->resampler=NULL; rx->resample_buffer=NULL; +g_print("%s: id=%d sample_rate=%d\n",__FUNCTION__,rx->id, rx->sample_rate); } else { #endif rx->sample_rate=48000; @@ -1032,7 +1041,7 @@ fprintf(stderr,"create_receiver: id=%d default adc=%d\n",rx->id, rx->adc); rx->waterfall_automatic=1; rx->volume=0.1; - rx->rf_gain=50.0; + //rx->rf_gain=50.0; rx->dither=0; rx->random=0; @@ -1059,7 +1068,7 @@ fprintf(stderr,"create_receiver: id=%d default adc=%d\n",rx->id, rx->adc); rx->agc_slope=35.0; rx->agc_hang_threshold=0.0; - rx->playback_handle=NULL; + //rx->playback_handle=NULL; rx->local_audio=0; g_mutex_init(&rx->local_audio_mutex); rx->local_audio_buffer=NULL; @@ -1096,21 +1105,21 @@ fprintf(stderr,"create_receiver: id=%d default adc=%d\n",rx->id, rx->adc); rx->pixel_samples=g_new(float,rx->pixels); -fprintf(stderr,"create_receiver (after restore): rx=%p id=%d audio_buffer_size=%d local_audio=%d\n",rx,rx->id,rx->audio_buffer_size,rx->local_audio); - //rx->audio_buffer=g_new(guchar,rx->audio_buffer_size); +g_print("%s (after restore): rx=%p id=%d audio_buffer_size=%d local_audio=%d\n",__FUNCTION__,rx,rx->id,rx->audio_buffer_size,rx->local_audio); int scale=rx->sample_rate/48000; rx->output_samples=rx->buffer_size/scale; rx->audio_output_buffer=g_new(gdouble,2*rx->output_samples); -fprintf(stderr,"create_receiver: id=%d output_samples=%d\n",rx->id,rx->output_samples); +g_print("%s: id=%d output_samples=%d audio_output_buffer=%p\n",__FUNCTION__,rx->id,rx->output_samples,rx->audio_output_buffer); rx->hz_per_pixel=(double)rx->sample_rate/(double)rx->pixels; // setup wdsp for this receiver -fprintf(stderr,"create_receiver: id=%d after restore adc=%d\n",rx->id, rx->adc); +g_print("%s: id=%d after restore adc=%d\n",__FUNCTION__,rx->id, rx->adc); -fprintf(stderr,"create_receiver: OpenChannel id=%d buffer_size=%d fft_size=%d sample_rate=%d\n", +g_print("%s: OpenChannel id=%d buffer_size=%d fft_size=%d sample_rate=%d\n", + __FUNCTION__, rx->id, rx->buffer_size, rx->fft_size, @@ -1142,9 +1151,7 @@ fprintf(stderr,"create_receiver: OpenChannel id=%d buffer_size=%d fft_size=%d sa create_anbEXT(rx->id,1, rx->buffer_size,rx->sample_rate,0.00001,0.00001,0.00001,0.05, 4.95); create_nobEXT(rx->id,1,0,rx->buffer_size,rx->sample_rate,0.00001,0.00001,0.00001,0.05, 4.95); -fprintf(stderr,"RXASetNC %d\n",rx->fft_size); RXASetNC(rx->id, rx->fft_size); -fprintf(stderr,"RXASetMP %d\n",rx->low_latency); RXASetMP(rx->id, rx->low_latency); set_agc(rx, rx->agc); @@ -1183,7 +1190,7 @@ fprintf(stderr,"RXASetMP %d\n",rx->low_latency); int result; XCreateAnalyzer(rx->id, &result, 262144, 1, 1, ""); if(result != 0) { - fprintf(stderr, "XCreateAnalyzer id=%d failed: %d\n", rx->id, result); + g_print( "%s: XCreateAnalyzer id=%d failed: %d\n",__FUNCTION__,rx->id, result); } else { init_analyzer(rx); } @@ -1195,11 +1202,12 @@ fprintf(stderr,"RXASetMP %d\n",rx->low_latency); create_visual(rx); -fprintf(stderr,"create_receiver: rx=%p id=%d local_audio=%d\n",rx,rx->id,rx->local_audio); +g_print("%s: rx=%p id=%d local_audio=%d\n",__FUNCTION__,rx,rx->id,rx->local_audio); if(rx->local_audio) { - if (audio_open_output(rx) < 0) rx->local_audio=0; + if(audio_open_output(rx)<0) { + rx->local_audio=0; + } } - return rx; } @@ -1223,8 +1231,9 @@ void receiver_change_sample_rate(RECEIVER *rx,int sample_rate) { rx->output_samples=rx->buffer_size/scale; 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); +g_print("%s: id=%d rate=%d scale=%d buffer_size=%d output_samples=%d\n",__FUNCTION__,rx->id,sample_rate,scale,rx->buffer_size,rx->output_samples); #ifdef PURESIGNAL + if(can_transmit && transmitter->puresignal) { if (rx->id == PS_RX_FEEDBACK) { if (protocol == ORIGINAL_PROTOCOL) { rx->pixels = 2* scale * rx->width; @@ -1236,11 +1245,12 @@ g_print("receiver_change_sample_rate: id=%d rate=%d scale=%d buffer_size=%d outp 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; } + } #endif // // re-calculate AGC line for panadapter since it depends on sample rate @@ -1273,7 +1283,7 @@ g_print("receiver_change_sample_rate: id=%d rate=%d scale=%d buffer_size=%d outp g_mutex_unlock(&rx->mutex); -fprintf(stderr,"receiver_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: id=%d rate=%d buffer_size=%d output_samples=%d\n",__FUNCTION__,rx->id, rx->sample_rate, rx->buffer_size, rx->output_samples); } void receiver_frequency_changed(RECEIVER *rx) { @@ -1362,6 +1372,9 @@ static void process_rx_buffer(RECEIVER *rx) { gdouble left_sample,right_sample; short left_audio_sample,right_audio_sample; int i; + + //g_print("%s: rx=%p id=%d output_samples=%d audio_output_buffer=%p\n",__FUNCTION__,rx,rx->id,rx->output_samples,rx->audio_output_buffer); + for(i=0;ioutput_samples;i++) { if(isTransmitting() && (!duplex || mute_rx_while_transmitting)) { left_sample=0.0; @@ -1449,6 +1462,7 @@ static void process_rx_buffer(RECEIVER *rx) { void full_rx_buffer(RECEIVER *rx) { int error; + //g_print("%s: rx=%p\n",__FUNCTION__,rx); g_mutex_lock(&rx->mutex); // noise blanker works on original IQ samples @@ -1461,7 +1475,6 @@ void full_rx_buffer(RECEIVER *rx) { fexchange0(rx->id, rx->iq_input_buffer, rx->audio_output_buffer, &error); if(error!=0) { - //fprintf(stderr,"full_rx_buffer: id=%d fexchange0: error=%d\n",rx->id,error); rx->fexchange_errors++; } @@ -1471,7 +1484,6 @@ void full_rx_buffer(RECEIVER *rx) { g_mutex_unlock(&rx->display_mutex); } -//g_print("full_rx_buffer: rx=%d buffer_size=%d samples=%d\n",rx->id,rx->buffer_size,rx->samples); process_rx_buffer(rx); g_mutex_unlock(&rx->mutex); } @@ -1503,7 +1515,6 @@ void add_div_iq_samples(RECEIVER *rx, double i0, double q0, double i1, double q1 } void receiver_change_zoom(RECEIVER *rx,double zoom) { -g_print("receiver_change_zoom: %d %f\n",rx->id,zoom); rx->zoom=(int)zoom; rx->pixels=rx->width*rx->zoom; rx->hz_per_pixel=(double)rx->sample_rate/(double)rx->pixels; @@ -1530,7 +1541,6 @@ g_print("receiver_change_zoom: %d %f\n",rx->id,zoom); #ifdef CLIENT_SERVER } #endif -g_print("receiver_change_zoom: pixels=%d zoom=%d pan=%d\n",rx->pixels,rx->zoom,rx->pan); } void receiver_change_pan(RECEIVER *rx,double pan) { diff --git a/receiver.h b/receiver.h index 0551adc..222a15c 100644 --- a/receiver.h +++ b/receiver.h @@ -22,9 +22,14 @@ #include #ifdef PORTAUDIO #include "portaudio.h" -#else +#endif +#ifdef ALSAAUDIO #include #endif +#ifdef PULSEAUDIO +#include +#include +#endif enum _audio_t { STEREO=0, @@ -43,7 +48,6 @@ typedef struct _receiver { gint adc; gdouble volume; - gdouble rf_gain; gint agc; gdouble agc_gain; @@ -63,7 +67,6 @@ typedef struct _receiver { gdouble *iq_input_buffer; gdouble *audio_output_buffer; gint audio_buffer_size; - //guchar *audio_buffer; gint audio_index; guint32 audio_sequence; gfloat *pixel_samples; @@ -121,9 +124,14 @@ typedef struct _receiver { PaStream *playback_handle; gint local_audio_buffer_inpt; // pointer in audio ring-buffer gint local_audio_buffer_outpt; // pointer in audio ring-buffer -#else +#endif +#ifdef ALSAAUDIO snd_pcm_t *playback_handle; snd_pcm_format_t local_audio_format; +#endif +#ifdef PULSEAUDIO + pa_simple *playstream; + gboolean output_started; #endif gint local_audio_cw; // flag for latency switching gint local_audio_buffer_size; diff --git a/rigctl.c b/rigctl.c index ffd8a9d..7aadb34 100644 --- a/rigctl.c +++ b/rigctl.c @@ -58,6 +58,8 @@ #endif #include +#define NEW_PARSER + // IP stuff below #include #include //inet_addr @@ -3290,10 +3292,10 @@ int parse_cmd(void *data) { if(command[2]==';') { int att=0; if(have_rx_gain) { - att=(int)(adc_attenuation[active_receiver->adc]+12); + att=(int)(adc[active_receiver->adc].attenuation+12); att=(int)(((double)att/60.0)*99.0); } else { - att=(int)(adc_attenuation[active_receiver->adc]); + att=(int)(adc[active_receiver->adc].attenuation); att=(int)(((double)att/31.0)*99.0); } sprintf(reply,"RA%02d00;",att); diff --git a/rigctl_menu.c b/rigctl_menu.c index a35d12d..333ab12 100644 --- a/rigctl_menu.c +++ b/rigctl_menu.c @@ -100,7 +100,7 @@ static void serial_enable_cb(GtkWidget *widget, gpointer data) { // if (!rigctl_enable) { serial_enable=0; - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget),0); + gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(widget),0); return; } strcpy(ser_port,gtk_entry_get_text(GTK_ENTRY(serial_port_entry))); diff --git a/rx_menu.c b/rx_menu.c index b47ef25..4c45d82 100644 --- a/rx_menu.c +++ b/rx_menu.c @@ -369,7 +369,7 @@ void rx_menu(GtkWidget *parent) { output=gtk_combo_box_text_new(); for(i=0;iaudio_name!=NULL) { if(strcmp(active_receiver->audio_name,output_devices[i].name)==0) { gtk_combo_box_set_active(GTK_COMBO_BOX(output),i); diff --git a/sliders.c b/sliders.c index 7df32b5..6ccefcd 100644 --- a/sliders.c +++ b/sliders.c @@ -123,15 +123,8 @@ int sliders_active_receiver_changed(void *data) { if (filter_board == CHARLY25) { update_att_preamp(); } else { - gtk_range_set_value (GTK_RANGE(attenuation_scale),(double)adc_attenuation[active_receiver->adc]); + if(attenuation_scale!=NULL) gtk_range_set_value (GTK_RANGE(attenuation_scale),(double)adc[active_receiver->adc].attenuation); } - char title[64]; - if (have_rx_gain) { - sprintf(title,"RX GAIN"); - } else { - sprintf(title,"ATT (dB)"); - } - gtk_label_set_text(GTK_LABEL(attenuation_label),title); sliders_update(); } return FALSE; @@ -144,26 +137,28 @@ int scale_timeout_cb(gpointer data) { } 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].gain=gtk_range_get_value(GTK_RANGE(attenuation_scale)); + adc[active_receiver->adc].attenuation=(int)adc[active_receiver->adc].gain; #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]); + g_print("%s\n",__FUNCTION__); + 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) { @@ -189,7 +184,7 @@ void set_attenuation_value(double value) { 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); @@ -197,7 +192,7 @@ void set_attenuation_value(double value) { 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); } } @@ -212,10 +207,10 @@ void update_att_preamp(void) { 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); @@ -223,9 +218,10 @@ void update_att_preamp(void) { } void att_type_changed(void) { + g_print("%s\n",__FUNCTION__); if (filter_board == CHARLY25) { - gtk_widget_hide(attenuation_label); - gtk_widget_hide(attenuation_scale); + if(attenuation_label!=NULL) gtk_widget_hide(attenuation_label); + if(attenuation_scale!=NULL) gtk_widget_hide(attenuation_scale); gtk_widget_show(c25_att_preamp_label); gtk_widget_show(c25_att_combobox); gtk_widget_show(c25_preamp_combobox); @@ -234,8 +230,8 @@ void att_type_changed(void) { gtk_widget_hide(c25_att_preamp_label); gtk_widget_hide(c25_att_combobox); gtk_widget_hide(c25_preamp_combobox); - gtk_widget_show(attenuation_label); - gtk_widget_show(attenuation_scale); + if(attenuation_label!=NULL) gtk_widget_show(attenuation_label); + if(attenuation_scale!=NULL) gtk_widget_show(attenuation_scale); } } @@ -249,7 +245,7 @@ static void c25_att_combobox_changed(GtkWidget *widget, gpointer data) { 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 @@ -291,6 +287,7 @@ static void agcgain_value_changed_cb(GtkWidget *widget, gpointer data) { } void set_agc_gain(int rx,double value) { + g_print("%s\n",__FUNCTION__); receiver[rx]->agc_gain=value; SetRXAAGCTop(receiver[rx]->id, receiver[rx]->agc_gain); GetRXAAGCHangLevel(receiver[rx]->id, &receiver[rx]->agc_hang); @@ -352,6 +349,7 @@ void update_af_gain() { } void set_af_gain(int rx,double value) { + g_print("%s\n",__FUNCTION__); receiver[rx]->volume=value; SetRXAPanelGain1 (receiver[rx]->id, receiver[rx]->volume); if(display_sliders) { @@ -388,15 +386,15 @@ void set_af_gain(int rx,double value) { } 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(rf_gain_scale)); switch(protocol) { #ifdef SOAPYSDR case SOAPYSDR_PROTOCOL: soapy_protocol_set_gain(active_receiver); - break; + break; #endif default: - break; + break; } } @@ -450,6 +448,7 @@ void set_rf_gain(int rx,double value) { } void set_filter_width(int rx,int width) { + g_print("%s\n",__FUNCTION__); if(scale_status!=FILTER_WIDTH || scale_rx!=rx) { if(scale_status!=NO_FUNCTION) { g_source_remove(scale_timer); @@ -480,6 +479,7 @@ void set_filter_width(int rx,int width) { } void set_filter_shift(int rx,int shift) { + g_print("%s\n",__FUNCTION__); if(scale_status!=FILTER_SHIFT || scale_rx!=rx) { if(scale_status!=NO_FUNCTION) { g_source_remove(scale_timer); @@ -519,6 +519,7 @@ static void micgain_value_changed_cb(GtkWidget *widget, gpointer data) { } void set_mic_gain(double value) { + g_print("%s\n",__FUNCTION__); if(can_transmit) { mic_gain=value; SetTXAPanelGain1(transmitter->id,pow(10.0, mic_gain/20.0)); @@ -554,6 +555,7 @@ void set_mic_gain(double value) { } void set_linein_gain(int value) { + g_print("%s\n",__FUNCTION__); linein_gain=value; if(display_sliders) { gtk_range_set_value (GTK_RANGE(mic_gain_scale),linein_gain); @@ -592,6 +594,7 @@ int update_linein_gain(void *data) { } void set_drive(double value) { + g_print("%s\n",__FUNCTION__); setDrive(value); if(display_sliders) { gtk_range_set_value (GTK_RANGE(drive_scale),value); @@ -674,6 +677,7 @@ static void compressor_enable_cb(GtkWidget *widget, gpointer data) { } void set_squelch() { + g_print("%s\n",__FUNCTION__); setSquelch(active_receiver); #ifndef COMPRESSION_SLIDER_INSTEAD_OF_SQUELCH if(display_sliders) { @@ -712,6 +716,7 @@ void set_squelch() { } void set_compression(TRANSMITTER* tx) { + g_print("%s\n",__FUNCTION__); // Update VFO panel to reflect changed value g_idle_add(ext_vfo_update, NULL); #ifdef COMPRESSION_SLIDER_INSTEAD_OF_SQUELCH @@ -749,6 +754,7 @@ void set_compression(TRANSMITTER* tx) { } void show_diversity_gain() { + g_print("%s\n",__FUNCTION__); if(scale_status!=DIVERSITY_GAIN) { if(scale_status!=NO_FUNCTION) { g_source_remove(scale_timer); @@ -776,6 +782,7 @@ void show_diversity_gain() { } void show_diversity_phase() { + g_print("%s\n",__FUNCTION__); if(scale_status!=DIVERSITY_PHASE) { if(scale_status!=NO_FUNCTION) { g_source_remove(scale_timer); @@ -840,31 +847,41 @@ fprintf(stderr,"sliders_init: width=%d height=%d\n", width,height); gtk_grid_attach(GTK_GRID(sliders),agc_scale,4,0,2,1); g_signal_connect(G_OBJECT(agc_scale),"value_changed",G_CALLBACK(agcgain_value_changed_cb),NULL); - char title[64]; - if (have_rx_gain) { - sprintf(title,"RX-GAIN:"); - } else { - sprintf(title,"ATT (dB):"); - } - attenuation_label=gtk_label_new(title); - gtk_widget_override_font(attenuation_label, pango_font_description_from_string(SLIDERS_FONT)); - gtk_widget_show(attenuation_label); - gtk_grid_attach(GTK_GRID(sliders),attenuation_label,6,0,1,1); - - 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]); + + if(have_rx_gain) { + rf_gain_label=gtk_label_new("RX-GAIN:"); + gtk_widget_override_font(rf_gain_label, pango_font_description_from_string(SLIDERS_FONT)); + gtk_widget_show(rf_gain_label); + gtk_grid_attach(GTK_GRID(sliders),rf_gain_label,6,0,1,1); +#ifdef SOAPYSDR + if(protocol==SOAPYSDR_PROTOCOL) { + rf_gain_scale=gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL,adc[0].min_gain, adc[0].max_gain, 1.0); + gtk_range_set_value (GTK_RANGE(rf_gain_scale),adc[0].gain); + } else { +#endif + rf_gain_scale=gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL,-12.0, 48.0, 1.0); + gtk_range_set_value (GTK_RANGE(rf_gain_scale),adc[active_receiver->adc].attenuation); +#ifdef SOAPYSDR + } +#endif + gtk_widget_override_font(rf_gain_scale, pango_font_description_from_string(SLIDERS_FONT)); + gtk_range_set_increments (GTK_RANGE(rf_gain_scale),1.0,1.0); + gtk_widget_show(rf_gain_scale); + gtk_grid_attach(GTK_GRID(sliders),rf_gain_scale,7,0,2,1); + g_signal_connect(G_OBJECT(rf_gain_scale),"value_changed",G_CALLBACK(rf_gain_value_changed_cb),NULL); } 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]); + attenuation_label=gtk_label_new("ATT (dB):"); + gtk_widget_override_font(attenuation_label, pango_font_description_from_string(SLIDERS_FONT)); + gtk_widget_show(attenuation_label); + gtk_grid_attach(GTK_GRID(sliders),attenuation_label,6,0,1,1); + attenuation_scale=gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL,0.0, 31.0, 1.0); + gtk_widget_override_font(attenuation_scale, pango_font_description_from_string(SLIDERS_FONT)); + 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); + gtk_widget_show(attenuation_scale); + gtk_grid_attach(GTK_GRID(sliders),attenuation_scale,7,0,2,1); + g_signal_connect(G_OBJECT(attenuation_scale),"value_changed",G_CALLBACK(attenuation_value_changed_cb),NULL); } - gtk_range_set_increments (GTK_RANGE(attenuation_scale),1.0,1.0); - - gtk_widget_override_font(attenuation_scale, pango_font_description_from_string(SLIDERS_FONT)); - - gtk_widget_show(attenuation_scale); - gtk_grid_attach(GTK_GRID(sliders),attenuation_scale,7,0,2,1); - g_signal_connect(G_OBJECT(attenuation_scale),"value_changed",G_CALLBACK(attenuation_value_changed_cb),NULL); c25_att_preamp_label = gtk_label_new("Att/PreAmp"); gtk_widget_override_font(c25_att_preamp_label, pango_font_description_from_string(SLIDERS_FONT)); diff --git a/soapy_discovery.c b/soapy_discovery.c index f5b9447..4d0918c 100644 --- a/soapy_discovery.c +++ b/soapy_discovery.c @@ -27,17 +27,23 @@ #include "soapy_discovery.h" static int rtlsdr_count=0; +static int sdrplay_count=0; 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 software_version=0; + char *version; + char *address=NULL; int rtlsdr_val=0; + int sdrplay_val=0; char fw_version[16]; char gw_version[16]; char hw_version[16]; char p_version[16]; + char** tx_antennas; + char** tx_gains; fprintf(stderr,"soapy_discovery: get_info: %s\n", driver); @@ -53,6 +59,12 @@ static void get_info(char *driver) { SoapySDRKwargs_set(&args, "rtl", count); rtlsdr_val=rtlsdr_count; rtlsdr_count++; + } else if(strcmp(driver,"sdrplay")==0) { + char label[16]; + sprintf(label,"SDRplay Dev%d",sdrplay_count); + SoapySDRKwargs_set(&args, "label", label); + sdrplay_val=sdrplay_count; + sdrplay_count++; } SoapySDRDevice *sdr = SoapySDRDevice_make(&args); SoapySDRKwargs_clear(&args); @@ -63,6 +75,9 @@ static void get_info(char *driver) { char *hardwarekey=SoapySDRDevice_getHardwareKey(sdr); fprintf(stderr,"HardwareKey=%s\n",hardwarekey); + if(strcmp(driver,"sdrplay")==0) { + address=hardwarekey; + } SoapySDRKwargs info=SoapySDRDevice_getHardwareInfo(sdr); for(i=0;i %f (%f),", tx_rates[i].minimum, tx_rates[i].maximum, tx_rates[i].minimum/48000.0); + if(tx_channels>0) { + SoapySDRRange *tx_rates=SoapySDRDevice_getSampleRateRange(sdr, SOAPY_SDR_TX, 1, &tx_rates_length); + fprintf(stderr,"Tx sample rates: "); + for (size_t i = 0; i < tx_rates_length; i++) { + fprintf(stderr,"%f -> %f (%f),", tx_rates[i].minimum, tx_rates[i].maximum, tx_rates[i].minimum/48000.0); + } + fprintf(stderr,"\n"); + free(tx_rates); } - fprintf(stderr,"\n"); - free(tx_rates); double *bandwidths=SoapySDRDevice_listBandwidths(sdr, SOAPY_SDR_RX, 0, &rx_bandwidth_length); fprintf(stderr,"Rx bandwidths: "); @@ -148,19 +176,23 @@ static void get_info(char *driver) { fprintf(stderr,"\n"); free(bandwidths); - bandwidths=SoapySDRDevice_listBandwidths(sdr, SOAPY_SDR_TX, 0, &tx_bandwidth_length); - fprintf(stderr,"Tx bandwidths: "); - for (size_t i = 0; i < tx_bandwidth_length; i++) { - fprintf(stderr,"%f, ", bandwidths[i]); + if(tx_channels>0) { + bandwidths=SoapySDRDevice_listBandwidths(sdr, SOAPY_SDR_TX, 0, &tx_bandwidth_length); + fprintf(stderr,"Tx bandwidths: "); + for (size_t i = 0; i < tx_bandwidth_length; i++) { + fprintf(stderr,"%f, ", bandwidths[i]); + } + fprintf(stderr,"\n"); + free(bandwidths); } - fprintf(stderr,"\n"); - free(bandwidths); double bandwidth=SoapySDRDevice_getBandwidth(sdr, SOAPY_SDR_RX, 0); fprintf(stderr,"RX0: bandwidth=%f\n",bandwidth); - bandwidth=SoapySDRDevice_getBandwidth(sdr, SOAPY_SDR_TX, 0); - fprintf(stderr,"TX0: bandwidth=%f\n",bandwidth); + if(tx_channels>0) { + bandwidth=SoapySDRDevice_getBandwidth(sdr, SOAPY_SDR_TX, 0); + fprintf(stderr,"TX0: bandwidth=%f\n",bandwidth); + } SoapySDRRange *ranges = SoapySDRDevice_getFrequencyRange(sdr, SOAPY_SDR_RX, 0, &ranges_length); fprintf(stderr,"Rx freq ranges: "); @@ -172,10 +204,13 @@ static void get_info(char *driver) { for (size_t i = 0; i < rx_antennas_length; i++) fprintf(stderr, "%s, ", rx_antennas[i]); fprintf(stderr,"\n"); - char** tx_antennas = SoapySDRDevice_listAntennas(sdr, SOAPY_SDR_TX, 0, &tx_antennas_length); - fprintf(stderr, "Tx antennas: "); - for (size_t i = 0; i < tx_antennas_length; i++) fprintf(stderr, "%s, ", tx_antennas[i]); - fprintf(stderr,"\n"); + + if(tx_channels>0) { + tx_antennas = SoapySDRDevice_listAntennas(sdr, SOAPY_SDR_TX, 0, &tx_antennas_length); + fprintf(stderr, "Tx antennas: "); + for (size_t i = 0; i < tx_antennas_length; i++) fprintf(stderr, "%s, ", tx_antennas[i]); + fprintf(stderr,"\n"); + } char **rx_gains = SoapySDRDevice_listGains(sdr, SOAPY_SDR_RX, 0, &rx_gains_length); @@ -185,7 +220,9 @@ static void get_info(char *driver) { gboolean has_automatic_dc_offset_correction=SoapySDRDevice_hasDCOffsetMode(sdr, SOAPY_SDR_RX, 0); fprintf(stderr,"has_automaic_dc_offset_correction=%d\n",has_automatic_dc_offset_correction); - char **tx_gains = SoapySDRDevice_listGains(sdr, SOAPY_SDR_TX, 1, &tx_gains_length); + if(tx_channels>0) { + tx_gains = SoapySDRDevice_listGains(sdr, SOAPY_SDR_TX, 1, &tx_gains_length); + } size_t formats_length; char **formats = SoapySDRDevice_getStreamFormats(sdr,SOAPY_SDR_RX,0,&formats_length); @@ -193,7 +230,18 @@ static void get_info(char *driver) { for (size_t i = 0; i < formats_length; i++) fprintf(stderr, "%s, ", formats[i]); fprintf(stderr,"\n"); - fprintf(stderr,"float=%lu double=%lu\n",sizeof(float),sizeof(double)); + size_t sensors; + char **sensor = SoapySDRDevice_listSensors(sdr, &sensors); + gboolean has_temp=FALSE; + char *ptr; + fprintf(stderr, "Sensors:\n"); + for (size_t i = 0; i < sensors; i++) { + char *value=SoapySDRDevice_readSensor(sdr, sensor[i]); + fprintf(stderr, " %s=%s\n", sensor[i],value); + if((ptr=strstr(sensor[i],"temp"))!=NULL) { + has_temp=TRUE; + } + } if(devices %f step=%f\n",tx_range.minimum,tx_range.maximum,tx_range.step); - discovered[devices].info.soapy.tx_range[i]=tx_range; + if(tx_channels>0) { + discovered[devices].info.soapy.tx_gains=tx_gains_length; + discovered[devices].info.soapy.tx_gain=tx_gains; + discovered[devices].info.soapy.tx_range=malloc(tx_gains_length*sizeof(SoapySDRRange)); + fprintf(stderr,"Tx gains: \n"); + for (size_t i = 0; i < tx_gains_length; i++) { + fprintf(stderr,"%s ", tx_gains[i]); + SoapySDRRange tx_range=SoapySDRDevice_getGainElementRange(sdr, SOAPY_SDR_TX, 1, tx_gains[i]); + fprintf(stderr,"%f -> %f step=%f\n",tx_range.minimum,tx_range.maximum,tx_range.step); + discovered[devices].info.soapy.tx_range[i]=tx_range; + } + discovered[devices].info.soapy.tx_antennas=tx_antennas_length; + discovered[devices].info.soapy.tx_antenna=tx_antennas; } - discovered[devices].info.soapy.tx_antennas=tx_antennas_length; - discovered[devices].info.soapy.tx_antenna=tx_antennas; + discovered[devices].info.soapy.sensors=sensors; + discovered[devices].info.soapy.sensor=sensor; + discovered[devices].info.soapy.has_temp=has_temp; + + + if(address!=NULL) { + strcpy(discovered[devices].info.soapy.address,address); + } else { + strcpy(discovered[devices].info.soapy.address,"USB"); + } + devices++; } + SoapySDRDevice_unmake(sdr); free(ranges); - } void soapy_discovery() { diff --git a/stemlab_discovery.c b/stemlab_discovery.c index df9c45c..31607da 100644 --- a/stemlab_discovery.c +++ b/stemlab_discovery.c @@ -41,6 +41,7 @@ #include #include #include +#include #include #include diff --git a/toolbar.c b/toolbar.c index 8df8b61..7e619a8 100644 --- a/toolbar.c +++ b/toolbar.c @@ -23,6 +23,7 @@ #include #include #include +#include "actions.h" #ifdef GPIO #include "gpio.h" #endif @@ -83,9 +84,7 @@ static gint rit_minus_timer=-1; static gint xit_plus_timer=-1; static gint xit_minus_timer=-1; -#ifdef GPIO SWITCH *toolbar_switches=switches_controller1[0]; -#endif static gboolean rit_timer_cb(gpointer data) { int i=GPOINTER_TO_INT(data); @@ -95,6 +94,10 @@ static gboolean rit_timer_cb(gpointer data) { static gboolean xit_timer_cb(gpointer data) { int i=GPOINTER_TO_INT(data); + // + // In most operations, one want to move XIT faster than RIT + // therefore take 10 times the RIT value for XIT + // transmitter->xit+=(10*i*rit_increment); if(transmitter->xit>10000) transmitter->xit=10000; if(transmitter->xit<-10000) transmitter->xit=-10000; @@ -106,121 +109,14 @@ static gboolean xit_timer_cb(gpointer data) { } void update_toolbar_labels() { - switch(function) { - case 0: - if(can_transmit) { - gtk_button_set_label(GTK_BUTTON(sim_mox),"Mox"); - } else { - gtk_button_set_label(GTK_BUTTON(sim_mox),""); - } - gtk_button_set_label(GTK_BUTTON(sim_s1),"Band"); - gtk_button_set_label(GTK_BUTTON(sim_s2),"BStack"); - gtk_button_set_label(GTK_BUTTON(sim_s3),"Mode"); - gtk_button_set_label(GTK_BUTTON(sim_s4),"Filter"); - gtk_button_set_label(GTK_BUTTON(sim_s5),"Noise"); - gtk_button_set_label(GTK_BUTTON(sim_s6),"AGC"); - set_button_text_color(sim_s1,"black"); - set_button_text_color(sim_s2,"black"); - break; - case 1: - if(can_transmit) { - gtk_button_set_label(GTK_BUTTON(sim_mox),"Mox"); - } else { - gtk_button_set_label(GTK_BUTTON(sim_mox),""); - } - gtk_button_set_label(GTK_BUTTON(sim_s1),"Lock"); - gtk_button_set_label(GTK_BUTTON(sim_s2),"CTUN"); - gtk_button_set_label(GTK_BUTTON(sim_s3),"A>B"); - gtk_button_set_label(GTK_BUTTON(sim_s4),"AB"); - if(can_transmit) { - gtk_button_set_label(GTK_BUTTON(sim_s6),"Split"); - } else { - gtk_button_set_label(GTK_BUTTON(sim_s6),""); - } - break; - case 2: - if(can_transmit) { - gtk_button_set_label(GTK_BUTTON(sim_mox),"Mox"); - } else { - gtk_button_set_label(GTK_BUTTON(sim_mox),""); - } - gtk_button_set_label(GTK_BUTTON(sim_s1),"Freq"); - gtk_button_set_label(GTK_BUTTON(sim_s2),"Mem"); - gtk_button_set_label(GTK_BUTTON(sim_s3),"RIT"); - gtk_button_set_label(GTK_BUTTON(sim_s4),"RIT+"); - gtk_button_set_label(GTK_BUTTON(sim_s5),"RIT-"); - gtk_button_set_label(GTK_BUTTON(sim_s6),"RIT CL"); - break; - case 3: - if(can_transmit) { - gtk_button_set_label(GTK_BUTTON(sim_mox),"Mox"); - } else { - gtk_button_set_label(GTK_BUTTON(sim_mox),""); - } - gtk_button_set_label(GTK_BUTTON(sim_s1),"Freq"); - gtk_button_set_label(GTK_BUTTON(sim_s2),"Mem"); - if(can_transmit) { - gtk_button_set_label(GTK_BUTTON(sim_s3),"XIT"); - gtk_button_set_label(GTK_BUTTON(sim_s4),"XIT+"); - gtk_button_set_label(GTK_BUTTON(sim_s5),"XIT-"); - gtk_button_set_label(GTK_BUTTON(sim_s6),"XIT CL"); - } else { - gtk_button_set_label(GTK_BUTTON(sim_s3),""); - gtk_button_set_label(GTK_BUTTON(sim_s4),""); - gtk_button_set_label(GTK_BUTTON(sim_s5),""); - gtk_button_set_label(GTK_BUTTON(sim_s6),""); - } - break; - case 4: - if(can_transmit) { - gtk_button_set_label(GTK_BUTTON(sim_mox),"Mox"); - } else { - gtk_button_set_label(GTK_BUTTON(sim_mox),""); - } - gtk_button_set_label(GTK_BUTTON(sim_s1),"Freq"); - if(can_transmit) { - gtk_button_set_label(GTK_BUTTON(sim_s2),"Split"); - gtk_button_set_label(GTK_BUTTON(sim_s3),"Duplex"); - gtk_button_set_label(GTK_BUTTON(sim_s4),"SAT"); - gtk_button_set_label(GTK_BUTTON(sim_s5),"RSAT"); - } else { - gtk_button_set_label(GTK_BUTTON(sim_s2),""); - gtk_button_set_label(GTK_BUTTON(sim_s3),""); - gtk_button_set_label(GTK_BUTTON(sim_s4),""); - gtk_button_set_label(GTK_BUTTON(sim_s5),""); - } - gtk_button_set_label(GTK_BUTTON(sim_s6),""); - break; - case 5: - if(can_transmit) { - gtk_button_set_label(GTK_BUTTON(sim_mox),"Tune"); - if(OCtune!=0 && OCfull_tune_time!=0) { - gtk_button_set_label(GTK_BUTTON(sim_s1),"Full"); - } else { - gtk_button_set_label(GTK_BUTTON(sim_s1),""); - } - } else { - gtk_button_set_label(GTK_BUTTON(sim_mox),""); - gtk_button_set_label(GTK_BUTTON(sim_s1),""); - } - if(OCtune!=0 && OCmemory_tune_time!=0) { - gtk_button_set_label(GTK_BUTTON(sim_s2),"Memory"); - } else { - gtk_button_set_label(GTK_BUTTON(sim_s2),""); - } - gtk_button_set_label(GTK_BUTTON(sim_s3),"Band"); - gtk_button_set_label(GTK_BUTTON(sim_s4),"Mode"); - gtk_button_set_label(GTK_BUTTON(sim_s5),"Filter"); - gtk_button_set_label(GTK_BUTTON(sim_s6),""); - if(full_tune) { - set_button_text_color(sim_s1,"red"); - } - if(memory_tune) { - set_button_text_color(sim_s2,"red"); - } - break; - } + gtk_button_set_label(GTK_BUTTON(sim_mox),sw_cap_string[toolbar_switches[0].switch_function]); + gtk_button_set_label(GTK_BUTTON(sim_s1),sw_cap_string[toolbar_switches[1].switch_function]); + gtk_button_set_label(GTK_BUTTON(sim_s2),sw_cap_string[toolbar_switches[2].switch_function]); + gtk_button_set_label(GTK_BUTTON(sim_s3),sw_cap_string[toolbar_switches[3].switch_function]); + gtk_button_set_label(GTK_BUTTON(sim_s4),sw_cap_string[toolbar_switches[4].switch_function]); + gtk_button_set_label(GTK_BUTTON(sim_s5),sw_cap_string[toolbar_switches[5].switch_function]); + gtk_button_set_label(GTK_BUTTON(sim_s6),sw_cap_string[toolbar_switches[6].switch_function]); + gtk_button_set_label(GTK_BUTTON(sim_function),sw_cap_string[toolbar_switches[7].switch_function]); } static void close_cb(GtkWidget *widget, gpointer data) { @@ -615,306 +511,20 @@ void tune_update(int state) { g_idle_add(ext_vfo_update,NULL); } -void sim_s1_pressed_cb(GtkWidget *widget, gpointer data) { - switch(function) { - case 0: - band_cb(widget,data); - break; - case 1: - lock_cb(widget,data); - break; - case 2: - freq_cb(widget,data); - break; - case 3: - freq_cb(widget,data); - break; - case 4: - freq_cb(widget,data); - break; - case 5: - full_tune=full_tune==1?0:1; - if(full_tune) { - set_button_text_color(sim_s2,"black"); - set_button_text_color(sim_s1,"red"); - } else { - set_button_text_color(sim_s1,"black"); - } - break; - } -} - -void sim_s1_released_cb(GtkWidget *widget, gpointer data) { - switch(function) { - case 0: - break; - case 1: - break; - case 2: - break; - case 3: - break; - case 4: - break; - case 5: - break; - } -} - -void sim_s2_pressed_cb(GtkWidget *widget, gpointer data) { - switch(function) { - case 0: - bandstack_cb(widget,data); - break; - case 1: - ctun_cb(widget,data); - break; - case 2: - mem_cb(widget,data); - break; - case 3: - mem_cb(widget,data); - break; - case 4: - split_cb(widget,data); - break; - case 5: - memory_tune=memory_tune==1?0:1; - if(memory_tune) { - set_button_text_color(sim_s1,"black"); - set_button_text_color(sim_s2,"red"); - } else { - set_button_text_color(sim_s2,"black"); - } - break; - } -} - -void sim_s2_released_cb(GtkWidget *widget, gpointer data) { - switch(function) { - case 0: - break; - case 1: - break; - case 2: - break; - case 3: - break; - case 4: - break; - case 5: - break; - } -} - - -void sim_s3_pressed_cb(GtkWidget *widget, gpointer data) { - switch(function) { - case 0: - mode_cb(widget,data); - break; - case 1: - // A>B - atob_cb(widget,data); - break; - case 2: - rit_enable_cb(widget,data); - break; - case 3: - xit_enable_cb(widget,data); - break; - case 4: - duplex_cb(widget,data); - break; - case 5: - band_cb(widget,data); - break; - } -} - -void sim_s3_released_cb(GtkWidget *widget, gpointer data) { - switch(function) { - case 0: - break; - case 1: - break; - case 2: - break; - case 3: - break; - case 4: - break; - case 5: - break; - } -} - -void sim_s4_pressed_cb(GtkWidget *widget, gpointer data) { - switch(function) { - case 0: - filter_cb(widget,data); - break; - case 1: - // Aaction=toolbar_switches[i].switch_function; + a->state=PRESSED; + g_idle_add(switch_action,a); } -void sim_s4_released_cb(GtkWidget *widget, gpointer data) { - switch(function) { - case 0: - break; - case 1: - break; - case 2: - if(rit_plus_timer!=-1) { - g_source_remove(rit_plus_timer); - rit_plus_timer=-1; - } - break; - case 3: - if(xit_plus_timer!=-1) { - g_source_remove(xit_plus_timer); - xit_plus_timer=-1; - } - break; - case 4: - break; - case 5: - break; - } -} - -void sim_s5_pressed_cb(GtkWidget *widget, gpointer data) { - switch(function) { - case 0: - noise_cb(widget,data); - break; - case 1: - // A<>B - aswapb_cb(widget,data); - break; - case 2: - if(rit_minus_timer==-1 && rit_plus_timer==-1) { - rit_cb(widget,(void *)-1); - } - break; - case 3: - if(xit_minus_timer==-1 && xit_plus_timer==-1) { - xit_cb(widget,(void *)-1); - } - break; - case 4: - rsat_cb(widget,data); - break; - case 5: - filter_cb(widget,data); - break; - } -} - -void sim_s5_released_cb(GtkWidget *widget, gpointer data) { - switch(function) { - case 0: - break; - case 1: - break; - case 2: - if(rit_minus_timer!=-1) { - g_source_remove(rit_minus_timer); - rit_minus_timer=-1; - } - break; - case 3: - if(xit_minus_timer!=-1) { - g_source_remove(xit_minus_timer); - xit_minus_timer=-1; - } - break; - case 4: - break; - case 5: - break; - } -} - -void sim_s6_pressed_cb(GtkWidget *widget, gpointer data) { - switch(function) { - case 0: - agc_cb(widget,data); - break; - case 1: - split_cb(widget,data); - break; - case 2: - rit_clear_cb(widget,NULL); - break; - case 3: - xit_clear_cb(widget,NULL); - break; - case 4: - break; - case 5: - break; - } -} - -void sim_s6_released_cb(GtkWidget *widget, gpointer data) { - switch(function) { - case 0: - break; - case 1: - break; - case 2: - break; - case 3: - break; - case 4: - break; - case 5: - break; - } -} - -void sim_mox_cb(GtkWidget *widget, gpointer data) { - switch(function) { - case 0: - case 1: - case 2: - case 3: - case 4: - mox_cb((GtkWidget *)NULL, (gpointer)NULL); - break; - case 5: - tune_cb((GtkWidget *)NULL, (gpointer)NULL); - break; - } -} - -void sim_function_cb(GtkWidget *widget, gpointer data) { - function++; - if(function>MAX_FUNCTION) { - function=0; - } - update_toolbar_labels(); - g_idle_add(ext_vfo_update,NULL); +void switch_released_cb(GtkWidget *widget, gpointer data) { + gint i=GPOINTER_TO_INT(data); + SWITCH_ACTION *a=g_new(SWITCH_ACTION,1); + a->action=toolbar_switches[i].switch_function; + a->state=RELEASED; + g_idle_add(switch_action,a); } GtkWidget *toolbar_init(int my_width, int my_height, GtkWidget* parent) { @@ -940,60 +550,47 @@ GtkWidget *toolbar_init(int my_width, int my_height, GtkWidget* parent) { gtk_widget_set_size_request (toolbar, width, height); gtk_grid_set_column_homogeneous(GTK_GRID(toolbar),TRUE); - if(can_transmit) { - sim_mox=gtk_button_new_with_label("Mox"); - } else { - sim_mox=gtk_button_new_with_label(""); - } - //gtk_widget_override_font(sim_mox, pango_font_description_from_string("Sans 11")); - g_signal_connect(G_OBJECT(sim_mox),"clicked",G_CALLBACK(sim_mox_cb),NULL); + sim_mox=gtk_button_new_with_label(sw_cap_string[toolbar_switches[0].switch_function]); + g_signal_connect(G_OBJECT(sim_mox),"pressed",G_CALLBACK(switch_pressed_cb),GINT_TO_POINTER(0)); gtk_grid_attach(GTK_GRID(toolbar),sim_mox,0,0,4,1); - sim_s1=gtk_button_new_with_label("Band"); + + sim_s1=gtk_button_new_with_label(sw_cap_string[toolbar_switches[1].switch_function]); gtk_widget_set_size_request (sim_s1, button_width, 0); - //gtk_widget_override_font(sim_s1, pango_font_description_from_string("Sans 11")); - g_signal_connect(G_OBJECT(sim_s1),"pressed",G_CALLBACK(sim_s1_pressed_cb),NULL); - g_signal_connect(G_OBJECT(sim_s1),"released",G_CALLBACK(sim_s1_released_cb),NULL); + g_signal_connect(G_OBJECT(sim_s1),"pressed",G_CALLBACK(switch_pressed_cb),GINT_TO_POINTER(1)); + g_signal_connect(G_OBJECT(sim_s1),"released",G_CALLBACK(switch_released_cb),GINT_TO_POINTER(1)); gtk_grid_attach(GTK_GRID(toolbar),sim_s1,4,0,4,1); - sim_s2=gtk_button_new_with_label("BStack"); - gtk_widget_set_size_request (sim_s2, button_width, 0); - //gtk_widget_override_font(sim_s2, pango_font_description_from_string("Sans 11")); - g_signal_connect(G_OBJECT(sim_s2),"pressed",G_CALLBACK(sim_s2_pressed_cb),NULL); - g_signal_connect(G_OBJECT(sim_s2),"released",G_CALLBACK(sim_s2_released_cb),NULL); + sim_s2=gtk_button_new_with_label(sw_cap_string[toolbar_switches[2].switch_function]); + gtk_widget_set_size_request (sim_s2, button_width, 0); + g_signal_connect(G_OBJECT(sim_s2),"pressed",G_CALLBACK(switch_pressed_cb),GINT_TO_POINTER(2)); + g_signal_connect(G_OBJECT(sim_s2),"released",G_CALLBACK(switch_released_cb),GINT_TO_POINTER(2)); gtk_grid_attach(GTK_GRID(toolbar),sim_s2,8,0,4,1); - sim_s3=gtk_button_new_with_label("Mode"); - //gtk_widget_override_font(sim_s3, pango_font_description_from_string("Sans 11")); - g_signal_connect(G_OBJECT(sim_s3),"pressed",G_CALLBACK(sim_s3_pressed_cb),NULL); - g_signal_connect(G_OBJECT(sim_s3),"released",G_CALLBACK(sim_s3_released_cb),NULL); + sim_s3=gtk_button_new_with_label(sw_cap_string[toolbar_switches[3].switch_function]); + g_signal_connect(G_OBJECT(sim_s3),"pressed",G_CALLBACK(switch_pressed_cb),GINT_TO_POINTER(3)); + g_signal_connect(G_OBJECT(sim_s3),"released",G_CALLBACK(switch_released_cb),GINT_TO_POINTER(3)); gtk_grid_attach(GTK_GRID(toolbar),sim_s3,12,0,4,1); - sim_s4=gtk_button_new_with_label("Filter"); - //gtk_widget_override_font(sim_s4, pango_font_description_from_string("Sans 11")); - g_signal_connect(G_OBJECT(sim_s4),"pressed",G_CALLBACK(sim_s4_pressed_cb),NULL); - g_signal_connect(G_OBJECT(sim_s4),"released",G_CALLBACK(sim_s4_released_cb),NULL); + sim_s4=gtk_button_new_with_label(sw_cap_string[toolbar_switches[4].switch_function]); + g_signal_connect(G_OBJECT(sim_s4),"pressed",G_CALLBACK(switch_pressed_cb),GINT_TO_POINTER(4)); + g_signal_connect(G_OBJECT(sim_s4),"released",G_CALLBACK(switch_released_cb),GINT_TO_POINTER(4)); gtk_grid_attach(GTK_GRID(toolbar),sim_s4,16,0,4,1); - sim_s5=gtk_button_new_with_label("Noise"); - //gtk_widget_override_font(sim_s5, pango_font_description_from_string("Sans 11")); - g_signal_connect(G_OBJECT(sim_s5),"pressed",G_CALLBACK(sim_s5_pressed_cb),NULL); - g_signal_connect(G_OBJECT(sim_s5),"released",G_CALLBACK(sim_s5_released_cb),NULL); + sim_s5=gtk_button_new_with_label(sw_cap_string[toolbar_switches[5].switch_function]); + g_signal_connect(G_OBJECT(sim_s5),"pressed",G_CALLBACK(switch_pressed_cb),GINT_TO_POINTER(5)); + g_signal_connect(G_OBJECT(sim_s5),"released",G_CALLBACK(switch_released_cb),GINT_TO_POINTER(5)); gtk_grid_attach(GTK_GRID(toolbar),sim_s5,20,0,4,1); - sim_s6=gtk_button_new_with_label("AGC"); - //gtk_widget_override_font(sim_s6, pango_font_description_from_string("Sans 11")); - g_signal_connect(G_OBJECT(sim_s6),"pressed",G_CALLBACK(sim_s6_pressed_cb),NULL); - g_signal_connect(G_OBJECT(sim_s6),"released",G_CALLBACK(sim_s6_released_cb),NULL); + sim_s6=gtk_button_new_with_label(sw_cap_string[toolbar_switches[6].switch_function]); + g_signal_connect(G_OBJECT(sim_s6),"pressed",G_CALLBACK(switch_pressed_cb),GINT_TO_POINTER(6)); + g_signal_connect(G_OBJECT(sim_s6),"released",G_CALLBACK(switch_released_cb),GINT_TO_POINTER(6)); gtk_grid_attach(GTK_GRID(toolbar),sim_s6,24,0,4,1); - sim_function=gtk_button_new_with_label("Function"); - //gtk_widget_override_font(sim_function, pango_font_description_from_string("Sans 11")); - g_signal_connect(G_OBJECT(sim_function),"clicked",G_CALLBACK(sim_function_cb),NULL); + sim_function=gtk_button_new_with_label(sw_cap_string[toolbar_switches[7].switch_function]); + g_signal_connect(G_OBJECT(sim_function),"pressed",G_CALLBACK(switch_pressed_cb),GINT_TO_POINTER(7)); gtk_grid_attach(GTK_GRID(toolbar),sim_function,28,0,4,1); - //update_toolbar_labels(); - last_dialog=NULL; gtk_widget_show_all(toolbar); diff --git a/transmitter.c b/transmitter.c index ec74483..d751cbf 100644 --- a/transmitter.c +++ b/transmitter.c @@ -1422,7 +1422,7 @@ void add_mic_sample(TRANSMITTER *tx,float mic_sample) { // side tone ramp=cwramp48[cw_shape]; cwsample=0.00197 * getNextSideToneSample() * cw_keyer_sidetone_volume * ramp; - cw_audio_write(cwsample); + if(active_receiver->local_audio) cw_audio_write(active_receiver,cwsample); cw_shape_buffer48[tx->samples]=ramp; // // In the new protocol, we MUST maintain a constant flow of audio samples to the radio diff --git a/tx_menu.c b/tx_menu.c index 868b020..040643e 100644 --- a/tx_menu.c +++ b/tx_menu.c @@ -219,9 +219,11 @@ static gboolean emp_cb (GtkWidget *widget, gpointer data) { return FALSE; } +/* static void tune_value_changed_cb(GtkWidget *widget, gpointer data) { setTuneDrive(gtk_range_get_value(GTK_RANGE(tune_scale))); } +*/ void tx_menu(GtkWidget *parent) { int i; @@ -271,7 +273,7 @@ void tx_menu(GtkWidget *parent) { input=gtk_combo_box_text_new(); for(i=0;imicrophone_name!=NULL) { if(strcmp(transmitter->microphone_name,input_devices[i].name)==0) { gtk_combo_box_set_active(GTK_COMBO_BOX(input),i); diff --git a/vfo.c b/vfo.c index c78418f..7935ff7 100644 --- a/vfo.c +++ b/vfo.c @@ -64,8 +64,8 @@ static int my_height; static GtkWidget *vfo_panel; static cairo_surface_t *vfo_surface = NULL; -int steps[]={1,10,25,50,100,250,500,1000,5000,9000,10000,100000,250000,500000,1000000,0}; -char *step_labels[]={"1Hz","10Hz","25Hz","50Hz","100Hz","250Hz","500Hz","1kHz","5kHz","9kHz","10kHz","100kHz","250KHz","500KHz","1MHz",0}; +int steps[]={1,10,25,50,100,250,500,1000,5000,9000,10000,100000,250000,500000,1000000}; +char *step_labels[]={"1Hz","10Hz","25Hz","50Hz","100Hz","250Hz","500Hz","1kHz","5kHz","9kHz","10kHz","100kHz","250KHz","500KHz","1MHz"}; static GtkWidget* menu=NULL; static GtkWidget* band_menu=NULL; @@ -692,7 +692,6 @@ void vfo_step(int steps) { #ifdef CLIENT_SERVER if(radio_is_remote) { - //send_vfo_step(client_socket,id,steps); update_vfo_step(id,steps); return; } @@ -1078,12 +1077,12 @@ void vfo_update() { long long af = vfo[0].ctun ? vfo[0].ctun_frequency : vfo[0].frequency; long long bf = vfo[1].ctun ? vfo[1].ctun_frequency : vfo[1].frequency; - if(vfo[0].entering_frequency) { - af=vfo[0].entered_frequency; - } - if(vfo[1].entering_frequency) { - bf=vfo[1].entered_frequency; - } + if(vfo[0].entering_frequency) { + af=vfo[0].entered_frequency; + } + if(vfo[1].entering_frequency) { + bf=vfo[1].entered_frequency; + } #if 0 // @@ -1117,6 +1116,7 @@ void vfo_update() { int oob=0; if (can_transmit) oob=transmitter->out_of_band; + sprintf(temp_text,"VFO A: %0lld.%06lld",af/(long long)1000000,af%(long long)1000000); if(txvfo == 0 && (isTransmitting() || oob)) { if (oob) sprintf(temp_text,"VFO A: Out of band"); @@ -1298,10 +1298,12 @@ void vfo_update() { } cairo_show_text(cr, "DIV"); - int s=0; - while(steps[s]!=step && steps[s]!=0) { - s++; - } + int s; + for(s=0;s=STEPS) s=0; + sprintf(temp_text,"Step %s",step_labels[s]); cairo_move_to(cr, 400, 15); cairo_set_source_rgb(cr, 1.0, 1.0, 0.0); @@ -1379,16 +1381,6 @@ fprintf(stderr,"vfo_update: no surface!\n"); } } -/* -static gboolean -vfo_step_select_cb (GtkWidget *widget, - gpointer data) -{ - step=steps[(int)data]; - g_idle_add(ext_vfo_update,NULL); -} -*/ - static gboolean vfo_press_event_cb (GtkWidget *widget, GdkEventButton *event, diff --git a/vfo.h b/vfo.h index a479d17..f380cce 100644 --- a/vfo.h +++ b/vfo.h @@ -45,7 +45,8 @@ struct _vfo { long long offset; gboolean entering_frequency; - long long entered_frequency; + gint64 entered_frequency; + }; extern struct _vfo vfo[MAX_VFOS]; diff --git a/vfo_menu.c b/vfo_menu.c index 2cf8b84..8cef9d6 100644 --- a/vfo_menu.c +++ b/vfo_menu.c @@ -58,6 +58,7 @@ static void cleanup() { gtk_widget_destroy(dialog); dialog=NULL; sub_menu=NULL; + active_menu=NO_MENU; } } @@ -155,6 +156,7 @@ static gboolean freqent_select_cb (GtkWidget *widget, gpointer data) { send_vfo_frequency(client_socket,active_receiver->id,f); } else { #endif + //This is inside a callback so we do not need g_idle_add //fp=g_new(SET_FREQUENCY,1); //fp->vfo=v; //fp->frequency = f; diff --git a/waterfall.c b/waterfall.c index 479398c..01bb5b7 100644 --- a/waterfall.c +++ b/waterfall.c @@ -183,9 +183,9 @@ void waterfall_update(RECEIVER *rx) { for(i=0;iadc]); + 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) { diff --git a/zoompan.c b/zoompan.c index d83b607..7575b92 100644 --- a/zoompan.c +++ b/zoompan.c @@ -96,7 +96,7 @@ g_print("zoom_value_changed_cb\n"); } void set_zoom(int rx,double value) { -g_print("set_zoom: %f\n",value); +//g_print("set_zoom: %f\n",value); receiver[rx]->zoom=value; if(display_zoompan) { gtk_range_set_value (GTK_RANGE(zoom_scale),receiver[rx]->zoom); @@ -145,7 +145,7 @@ g_print("remote_set_zoom: EXIT\n"); } void update_zoom(double zoom) { -g_print("update_zoom: %f\n",zoom); +//g_print("update_zoom: %f\n",zoom); int z=active_receiver->zoom+(int)zoom; if(z>MAX_ZOOM) z=MAX_ZOOM; if(z<1) z=1; @@ -236,7 +236,7 @@ fprintf(stderr,"zoompan_init: width=%d height=%d\n", width,height); gtk_grid_set_row_homogeneous(GTK_GRID(zoompan), FALSE); gtk_grid_set_column_homogeneous(GTK_GRID(zoompan),TRUE); - zoom_label=gtk_label_new("Zoom:"); + zoom_label=gtk_label_new("Zoom"); gtk_widget_override_font(zoom_label, pango_font_description_from_string(SLIDERS_FONT)); gtk_widget_show(zoom_label); gtk_grid_attach(GTK_GRID(zoompan),zoom_label,0,0,1,1); -- 2.45.2