From e23ea7dbde6c53f05afd311281e2d2c98e6543ab Mon Sep 17 00:00:00 2001 From: John Melton G0ORX <john.d.melton@googlemail.com> Date: Tue, 7 Jul 2020 15:33:16 +0100 Subject: [PATCH] Added back preamp setting for Mercury systems. Added ability to autostart when 1 device discovered. --- discovery.c | 11 +++++++++++ old_protocol.c | 14 ++++++++++---- protocols.c | 18 ++++++++++++++++++ protocols.h | 3 ++- rx_menu.c | 11 +++++++++++ 5 files changed, 52 insertions(+), 5 deletions(-) diff --git a/discovery.c b/discovery.c index c9d6c99..27fdd28 100644 --- a/discovery.c +++ b/discovery.c @@ -365,6 +365,7 @@ void discovery() { fprintf(stderr,"discovery: found %d devices\n", devices); gdk_window_set_cursor(gtk_widget_get_window(top_window),gdk_cursor_new(GDK_ARROW)); + discovery_dialog = gtk_dialog_new(); gtk_window_set_transient_for(GTK_WINDOW(discovery_dialog),GTK_WINDOW(top_window)); gtk_window_set_title(GTK_WINDOW(discovery_dialog),"piHPSDR - Discovery"); @@ -523,6 +524,16 @@ fprintf(stderr,"%p Protocol=%d name=%s\n",d,d->protocol,d->name); } } + + g_print("%s: devices=%d autostart=%d\n",__FUNCTION__,devices,autostart); + + if(devices==1 && autostart) { + d=&discovered[0]; + if(d->status==STATE_AVAILABLE) { + if(start_cb(NULL,NULL,(gpointer)d)) return; + } + } + #ifdef CLIENT_SERVER loadProperties("remote.props"); diff --git a/old_protocol.c b/old_protocol.c index 498ad7d..0733faf 100644 --- a/old_protocol.c +++ b/old_protocol.c @@ -1402,10 +1402,16 @@ static int last_power=0; case 4: output_buffer[C0]=0x14; output_buffer[C1]=0x00; - // All current boards have NO switchable preamps - //for(i=0;i<receivers;i++) { - // output_buffer[C1]|=(receiver[i]->preamp<<i); - //} + +#ifdef USBOZY + if ((device == DEVICE_OZY) || (device == DEVICE_METIS)) { +#else + if (device == DEVICE_METIS) { +#endif + for(i=0;i<receivers;i++) { + output_buffer[C1]|=(receiver[i]->preamp<<i); + } + } if(mic_ptt_enabled==0) { output_buffer[C1]|=0x40; } diff --git a/protocols.c b/protocols.c index dca2a13..006ab2d 100644 --- a/protocols.c +++ b/protocols.c @@ -41,6 +41,7 @@ gboolean enable_soapy_protocol; #ifdef STEMLAB_DISCOVERY gboolean enable_stemlab; #endif +gboolean autostart; void protocols_save_state() { char value[80]; @@ -59,6 +60,8 @@ void protocols_save_state() { setProperty("enable_stemlab",value); #endif + sprintf(value,"%d",autostart); + setProperty("autostart",value); saveProperties("protocols.props"); } @@ -83,6 +86,10 @@ void protocols_restore_state() { value=getProperty("enable_stemlab"); if(value) enable_stemlab=atoi(value); #endif + autostart=FALSE; + value=getProperty("autostart"); + if(value) autostart=atoi(value); + clearProperties(); } @@ -114,6 +121,10 @@ static void stemlab_cb(GtkToggleButton *widget, gpointer data) { } #endif +static void autostart_cb(GtkToggleButton *widget, gpointer data) { + autostart=gtk_toggle_button_get_active(widget); +} + void configure_protocols(GtkWidget *parent) { int row; @@ -161,6 +172,13 @@ void configure_protocols(GtkWidget *parent) { row++; #endif + GtkWidget *b_autostart=gtk_check_button_new_with_label("Auto start if only one device"); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (b_autostart), autostart); + gtk_widget_show(b_autostart); + g_signal_connect(b_autostart,"toggled",G_CALLBACK(autostart_cb),NULL); + gtk_grid_attach(GTK_GRID(grid),b_autostart,0,row,1,1); + row++; + gtk_container_add(GTK_CONTAINER(content),grid); gtk_widget_show_all(dialog); diff --git a/protocols.h b/protocols.h index d4618ff..424d957 100644 --- a/protocols.h +++ b/protocols.h @@ -23,8 +23,9 @@ extern gboolean enable_protocol_2; extern gboolean enable_soapy_protocol; #endif #ifdef STEMLAB_DISCOVERY -gboolean enable_stemlab; +extern gboolean enable_stemlab; #endif +extern gboolean autostart; extern void protocols_save_state(); extern void protocols_restore_state(); diff --git a/rx_menu.c b/rx_menu.c index 84e937f..911ca05 100644 --- a/rx_menu.c +++ b/rx_menu.c @@ -305,6 +305,17 @@ void rx_menu(GtkWidget *parent) { gtk_grid_attach(GTK_GRID(grid),random_b,x,3,1,1); g_signal_connect(random_b,"toggled",G_CALLBACK(random_cb),NULL); + if((protocol==ORIGINAL_PROTOCOL && device == DEVICE_METIS) || +#ifdef USBOZY + (protocol==ORIGINAL_PROTOCOL && device == DEVICE_OZY) || +#endif + (protocol==NEW_PROTOCOL && device == NEW_DEVICE_ATLAS)) { + GtkWidget *preamp_b=gtk_check_button_new_with_label("Preamp"); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (preamp_b), active_receiver->preamp); + gtk_grid_attach(GTK_GRID(grid),preamp_b,x,4,1,1); + g_signal_connect(preamp_b,"toggled",G_CALLBACK(preamp_cb),NULL); + } + if (filter_board == ALEX && active_receiver->adc == 0 && ((protocol==ORIGINAL_PROTOCOL && device != DEVICE_ORION2) || (protocol==NEW_PROTOCOL && device != NEW_DEVICE_ORION2))) { -- 2.45.2