]> git.rkrishnan.org Git - pihpsdr.git/commitdiff
Fix zoom/pan bugs
authorJohn Melton G0ORX <john.d.melton@googlemail.com>
Thu, 23 Jul 2020 14:31:22 +0000 (15:31 +0100)
committerJohn Melton G0ORX <john.d.melton@googlemail.com>
Thu, 23 Jul 2020 14:31:22 +0000 (15:31 +0100)
gpio.c
old_protocol.c
radio.c
zoompan.c

diff --git a/gpio.c b/gpio.c
index 4a48aad472fe58bba4b37994a5ff9a1695d9284d..9fb48e12e05cb42618be39f97e7cf1708c5e31c6 100644 (file)
--- 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:
index 0733fafec10e1166327790127f16bf2b4d322a7b..ce59c047d607edea8e168bed32c8df56bc905f4f 100644 (file)
@@ -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 62bba24385dfa090816c242b6f3976862a87808a..1047c0030cea671e376ea866033a86b3f713d2c1 100644 (file)
--- 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() {
index 8d46e311f38463637b1d30b61f0396d292fabe4a..77fbc6ea3f7c2c5051e1d73357ebfd6695c15618 100644 (file)
--- 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);