From 9a1c6ee02932cb328a886e694c9988b67b463b40 Mon Sep 17 00:00:00 2001 From: John Melton G0ORX Date: Thu, 23 Jul 2020 15:31:22 +0100 Subject: [PATCH] Fix zoom/pan bugs --- gpio.c | 1 - old_protocol.c | 3 +++ radio.c | 23 +++++++++++++++++++++++ zoompan.c | 27 +++++++++++++++------------ 4 files changed, 41 insertions(+), 13 deletions(-) diff --git a/gpio.c b/gpio.c index 4a48aad..9fb48e1 100644 --- a/gpio.c +++ b/gpio.c @@ -2198,7 +2198,6 @@ static void encoder_changed(int action,int pos) { update_diversity_phase((double)pos*0.1); break; case ENCODER_ZOOM: -g_print("GPIO: ENCODER_ZOOM: update_zoom: pos=%d\n",pos); update_zoom((double)pos); break; case ENCODER_PAN: diff --git a/old_protocol.c b/old_protocol.c index 0733faf..ce59c04 100644 --- a/old_protocol.c +++ b/old_protocol.c @@ -1679,6 +1679,8 @@ static int metis_write(unsigned char ep,unsigned char* buffer,int length) { static void metis_restart() { int i; + + g_print("%s\n",__FUNCTION__); // // In TCP-ONLY mode, we possibly need to re-connect // since if we come from a METIS-stop, the server @@ -1722,6 +1724,7 @@ static void metis_start_stop(int command) { int tmp; unsigned char buffer[1032]; + g_print("%s: %d\n",__FUNCTION__,command); #ifdef USBOZY if(device!=DEVICE_OZY) { diff --git a/radio.c b/radio.c index 62bba24..1047c00 100644 --- a/radio.c +++ b/radio.c @@ -603,6 +603,7 @@ if(!radio_is_remote) { } #endif +/* #ifdef CLIENT_SERVER if(!radio_is_remote) { #endif @@ -622,6 +623,7 @@ if(!radio_is_remote) { #ifdef CLIENT_SERVER } #endif +*/ if(display_zoompan) { zoompan = zoompan_init(display_width,ZOOMPAN_HEIGHT); @@ -660,6 +662,27 @@ g_print("create_visual: calling radio_change_receivers: receivers=%d r=%d\n",rec //gtk_widget_show_all (fixed); gtk_widget_show_all (top_window); + +#ifdef CLIENT_SERVER + if(!radio_is_remote) { +#endif + switch(protocol) { + case ORIGINAL_PROTOCOL: + old_protocol_init(0,display_width,receiver[0]->sample_rate); + break; + case NEW_PROTOCOL: + new_protocol_init(display_width); + break; +#ifdef SOAPYSDR + case SOAPYSDR_PROTOCOL: + soapy_protocol_init(0,false); + break; +#endif + } +#ifdef CLIENT_SERVER + } +#endif + } void start_radio() { diff --git a/zoompan.c b/zoompan.c index 8d46e31..77fbc6e 100644 --- a/zoompan.c +++ b/zoompan.c @@ -63,7 +63,6 @@ int zoompan_active_receiver_changed(void *data) { } static void zoom_value_changed_cb(GtkWidget *widget, gpointer data) { -g_print("zoom_value_changed_cb\n"); g_mutex_lock(&pan_zoom_mutex); g_mutex_lock(&active_receiver->display_mutex); #ifdef CLIENT_SERVER @@ -92,10 +91,21 @@ g_print("zoom_value_changed_cb\n"); } void set_zoom(int rx,double value) { -g_print("set_zoom: %f\n",value); receiver[rx]->zoom=value; + receiver_change_zoom(receiver[rx],value); if(display_zoompan) { + g_signal_handler_block(G_OBJECT(zoom_scale),zoom_signal_id); gtk_range_set_value (GTK_RANGE(zoom_scale),receiver[rx]->zoom); + g_signal_handler_unblock(G_OBJECT(zoom_scale),zoom_signal_id); + g_signal_handler_block(G_OBJECT(pan_scale),pan_signal_id); + gtk_range_set_range(GTK_RANGE(pan_scale),0.0,(double)(active_receiver->zoom==1?active_receiver->pixels:active_receiver->pixels-active_receiver->width)); + gtk_range_set_value (GTK_RANGE(pan_scale),active_receiver->pan); + g_signal_handler_unblock(G_OBJECT(pan_scale),pan_signal_id); + if(active_receiver->zoom==1) { + gtk_widget_set_sensitive(pan_scale, FALSE); + } else { + gtk_widget_set_sensitive(pan_scale, TRUE); + } } else { if(scale_status!=ZOOM || scale_rx!=rx) { if(scale_status!=NO_FUNCTION) { @@ -128,7 +138,6 @@ g_print("set_zoom: %f\n",value); } void remote_set_zoom(int rx,double value) { -g_print("remote_set_zoom: rx=%d zoom=%f\n",rx,value); g_mutex_lock(&pan_zoom_mutex); g_signal_handler_block(G_OBJECT(zoom_scale),zoom_signal_id); g_signal_handler_block(G_OBJECT(pan_scale),pan_signal_id); @@ -136,11 +145,9 @@ g_print("remote_set_zoom: rx=%d zoom=%f\n",rx,value); g_signal_handler_unblock(G_OBJECT(pan_scale),pan_signal_id); g_signal_handler_unblock(G_OBJECT(zoom_scale),zoom_signal_id); g_mutex_unlock(&pan_zoom_mutex); -g_print("remote_set_zoom: EXIT\n"); } void update_zoom(double 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; @@ -148,7 +155,6 @@ g_print("update_zoom: %f\n",zoom); } static void pan_value_changed_cb(GtkWidget *widget, gpointer data) { -g_print("pan_value_changed_cb\n"); g_mutex_lock(&pan_zoom_mutex); #ifdef CLIENT_SERVER if(radio_is_remote) { @@ -163,10 +169,11 @@ g_print("pan_value_changed_cb\n"); } void set_pan(int rx,double value) { -g_print("set_pan: %f\n",value); receiver[rx]->pan=(int)value; if(display_zoompan) { + g_signal_handler_block(G_OBJECT(pan_scale),pan_signal_id); gtk_range_set_value (GTK_RANGE(pan_scale),receiver[rx]->pan); + g_signal_handler_unblock(G_OBJECT(pan_scale),pan_signal_id); } else { if(scale_status!=PAN || scale_rx!=rx) { if(scale_status!=NO_FUNCTION) { @@ -198,32 +205,28 @@ g_print("set_pan: %f\n",value); } void remote_set_pan(int rx,double value) { -g_print("remote_set_pan: rx=%d pan=%f\n",rx,value); g_mutex_lock(&pan_zoom_mutex); g_signal_handler_block(G_OBJECT(pan_scale),pan_signal_id); gtk_range_set_range(GTK_RANGE(pan_scale),0.0,(double)(receiver[rx]->zoom==1?receiver[rx]->pixels:receiver[rx]->pixels-receiver[rx]->width)); set_pan(rx,value); g_signal_handler_unblock(G_OBJECT(pan_scale),pan_signal_id); g_mutex_unlock(&pan_zoom_mutex); -g_print("remote_set_pan: EXIT\n"); } void update_pan(double pan) { - g_mutex_lock(&pan_zoom_mutex); if(active_receiver->zoom>1) { int p=active_receiver->pan+(int)pan; if(p<0) p=0; if(p>(active_receiver->pixels-active_receiver->width)) p=active_receiver->pixels-active_receiver->width; set_pan(active_receiver->id,(double)p); } - g_mutex_lock(&pan_zoom_mutex); } GtkWidget *zoompan_init(int my_width, int my_height) { width=my_width; height=my_height; -fprintf(stderr,"zoompan_init: width=%d height=%d\n", width,height); +g_print("%s: width=%d height=%d\n",__FUNCTION__,width,height); zoompan=gtk_grid_new(); gtk_widget_set_size_request (zoompan, width, height); -- 2.45.2