]> git.rkrishnan.org Git - pihpsdr.git/commitdiff
Fixed touch screen scroll revered when not in CTUN mode. Fixed touch screen scrool...
authorJohn Melton G0ORX <john.d.melton@googlemail.com>
Fri, 8 Nov 2019 16:00:50 +0000 (16:00 +0000)
committerJohn Melton G0ORX <john.d.melton@googlemail.com>
Fri, 8 Nov 2019 16:00:50 +0000 (16:00 +0000)
radio.c
receiver.c
transmitter.c
tx_panadapter.c
vfo.c
vfo.h

diff --git a/radio.c b/radio.c
index fb6385752225f82ba89af5e2ae4e241c7c9a8b33..7cb1ec67148634fb482cafeaa6d9f5da7b16e6ed 100644 (file)
--- a/radio.c
+++ b/radio.c
@@ -828,7 +828,7 @@ void start_radio() {
 
   //fprintf(stderr,"Create transmitter\n");
   if(can_transmit) {
-    transmitter=create_transmitter(CHANNEL_TX, buffer_size, fft_size, updates_per_second, display_width/2, tx_height/2);
+    transmitter=create_transmitter(CHANNEL_TX, buffer_size, fft_size, updates_per_second, display_width/3, PANADAPTER_HEIGHT);
     transmitter->x=0;
     transmitter->y=VFO_HEIGHT;
 
index 48a33806203dab79262a49665183d523d0975228..defeb36f4eed73280ff373284f08290cbfedcd4e 100644 (file)
@@ -113,7 +113,7 @@ gboolean receiver_button_release_event(GtkWidget *widget, GdkEventButton *event,
       if (event->button == 1) {
         if(has_moved) {
           // drag
-          vfo_move((long long)((float)(x-last_x)*rx->hz_per_pixel));
+          vfo_move((long long)((float)(x-last_x)*rx->hz_per_pixel),TRUE);
         } else {
           // move to this frequency
           vfo_move_to((long long)((float)x*rx->hz_per_pixel));
@@ -142,7 +142,7 @@ gboolean receiver_motion_notify_event(GtkWidget *widget, GdkEventMotion *event,
     //if(state & GDK_BUTTON1_MASK) {
       //int moved=last_x-x;
       int moved=x-last_x;
-      vfo_move((long long)((float)moved*rx->hz_per_pixel));
+      vfo_move((long long)((float)moved*rx->hz_per_pixel),FALSE);
       last_x=x;
       has_moved=TRUE;
     //}
@@ -153,9 +153,9 @@ gboolean receiver_motion_notify_event(GtkWidget *widget, GdkEventMotion *event,
 
 gboolean receiver_scroll_event(GtkWidget *widget, GdkEventScroll *event, gpointer data) {
   if(event->direction==GDK_SCROLL_UP) {
-    vfo_move(step);
+    vfo_move(step,TRUE);
   } else {
-    vfo_move(-step);
+    vfo_move(-step,TRUE);
   }
   return TRUE;
 }
index 7a44d4ffca856f2aa7e747aac7644c1357b0dfb2..ec4be79b3b8c9fe75492e402d7b42252b9717e0d 100644 (file)
@@ -139,6 +139,7 @@ void transmitter_set_compressor(TRANSMITTER *tx,int state) {
 }
 
 void reconfigure_transmitter(TRANSMITTER *tx,int height) {
+g_print("reconfigure_transmitter: width=%d height=%d\n",tx->width,height);
   gtk_widget_set_size_request(tx->panadapter, tx->width, height);
 }
 
@@ -485,7 +486,9 @@ static gboolean update_display(gpointer data) {
       }
     } 
 
-    meter_update(active_receiver,POWER,transmitter->fwd,transmitter->rev,transmitter->exciter,transmitter->alc);
+    if(!duplex) {
+      meter_update(active_receiver,POWER,transmitter->fwd,transmitter->rev,transmitter->exciter,transmitter->alc);
+    }
 
     return TRUE; // keep going
   }
@@ -546,7 +549,7 @@ static void init_analyzer(TRANSMITTER *tx) {
 
 static void create_visual(TRANSMITTER *tx) {
  
-  fprintf(stderr,"transmitter: create_visual: id=%d\n",tx->id);
+  fprintf(stderr,"transmitter: create_visual: id=%d width=%d height=%d\n",tx->id, tx->width,tx->height);
 
   tx->panel=gtk_fixed_new();
   gtk_widget_set_size_request (tx->panel, tx->width, tx->height);
@@ -768,6 +771,7 @@ fprintf(stderr,"transmitter: allocate buffers: mic_input_buffer=%p iq_output_buf
 void tx_set_mode(TRANSMITTER* tx,int mode) {
   if(tx!=NULL) {
     tx->mode=mode;
+g_print("tx_set_mode: %s\n",mode_string[tx->mode]);
     SetTXAMode(tx->id, tx->mode);
     tx_set_filter(tx,tx_filter_low,tx_filter_high);
   }
index e78ea10d898011cb083bcc94da49871669c16225..04b86bd211aec75f3256a9aef74c9eb45083b07d 100644 (file)
@@ -123,7 +123,7 @@ tx_panadapter_button_release_event_cb (GtkWidget      *widget,
     if (event->button == 1) {
       if(has_moved) {
         // drag
-        vfo_move((long long)((float)(x-last_x)*hz_per_pixel));
+        vfo_move((long long)((float)(x-last_x)*hz_per_pixel),TRUE);
       } else {
         // move to this frequency
         vfo_move_to((long long)((float)(x-(display_width/2))*hz_per_pixel));
@@ -154,7 +154,7 @@ tx_panadapter_motion_notify_event_cb (GtkWidget      *widget,
                                     &state);
     if(state & GDK_BUTTON1_MASK) {
       int moved=last_x-x;
-      vfo_move((long long)((float)moved*hz_per_pixel));
+      vfo_move((long long)((float)moved*hz_per_pixel),FALSE);
       last_x=x;
       has_moved=TRUE;
     }
@@ -169,9 +169,9 @@ tx_panadapter_scroll_event_cb (GtkWidget      *widget,
                gpointer        data)
 {
   if(event->direction==GDK_SCROLL_UP) {
-    vfo_move(step);
+    vfo_move(step,TRUE);
   } else {
-    vfo_move(-step);
+    vfo_move(-step,TRUE);
   }
   return FALSE;
 }
@@ -417,6 +417,23 @@ void tx_panadapter_update(TRANSMITTER *tx) {
   }
 #endif
 
+  if(duplex) {
+    char text[64];
+    cairo_set_source_rgb(cr,1.0,0.0,0.0);
+
+    sprintf(text,"FWD: %f",transmitter->fwd);
+    cairo_move_to(cr,10,display_height-40);
+    cairo_show_text(cr, text);
+
+    sprintf(text,"REV: %f",transmitter->rev);
+    cairo_move_to(cr,10,display_height-30);
+    cairo_show_text(cr, text);
+
+    sprintf(text,"ALC: %f",transmitter->alc);
+    cairo_move_to(cr,10,display_height-20);
+    cairo_show_text(cr, text);
+  }
+
   cairo_destroy (cr);
   gtk_widget_queue_draw (tx->panadapter);
 
@@ -425,10 +442,7 @@ void tx_panadapter_update(TRANSMITTER *tx) {
 
 void tx_panadapter_init(TRANSMITTER *tx, int width,int height) {
 
-  int display_width=width;
-  int display_height=height;
-
-fprintf(stderr,"tx_panadapter_init: %d x %d\n",display_width,display_height);
+fprintf(stderr,"tx_panadapter_init: %d x %d\n",width,height);
 
   tx->panadapter_surface=NULL;
   tx->panadapter=gtk_drawing_area_new ();
diff --git a/vfo.c b/vfo.c
index 97b4c5192f9d219dad35548187d20cb9ee2affda..7b4180c787b690a84c97ac8b1dc4b624be0e3852 100644 (file)
--- a/vfo.c
+++ b/vfo.c
@@ -584,14 +584,20 @@ void vfo_step(int steps) {
   }
 }
 
-void vfo_move(long long hz) {
+void vfo_move(long long hz,int round) {
   int id=active_receiver->id;
 g_print("vfo_move: id=%d hz=%lld\n",id,hz);
   if(!locked) {
     if(vfo[id].ctun) {
-      vfo[id].ctun_frequency=((vfo[id].ctun_frequency+hz)/step)*step;
+      vfo[id].ctun_frequency=vfo[id].ctun_frequency+hz;
+      if(round) {
+         vfo[id].ctun_frequency=(vfo[id].ctun_frequency/step)*step;
+      }
     } else {
-      vfo[id].frequency=((vfo[id].frequency+hz)/step)*step;
+      vfo[id].frequency=vfo[id].frequency-hz;
+      if(round) {
+         vfo[id].frequency=(vfo[id].frequency/step)*step;
+      }
     }
     int sid=id==0?1:0;
     switch(sat_mode) {
@@ -600,17 +606,29 @@ g_print("vfo_move: id=%d hz=%lld\n",id,hz);
       case SAT_MODE:
         // A and B increment and decrement together
         if(vfo[sid].ctun) {
-          vfo[sid].ctun_frequency=((vfo[sid].ctun_frequency+hz)/step)*step;
+          vfo[sid].ctun_frequency=vfo[sid].ctun_frequency+hz;
+          if(round) {
+             vfo[sid].ctun_frequency=(vfo[sid].ctun_frequency/step)*step;
+          }
         } else {
-          vfo[sid].frequency=((vfo[sid].frequency+hz)/step)*step;
+          vfo[sid].frequency=vfo[sid].frequency-hz;
+          if(round) {
+             vfo[sid].frequency=(vfo[sid].frequency/step)*step;
+          }
         }
         break;
       case RSAT_MODE:
         // A increments and B decrements or A decrments and B increments
         if(vfo[sid].ctun) {
           vfo[sid].ctun_frequency=((vfo[sid].ctun_frequency-hz)/step)*step;
+          if(round) {
+             vfo[sid].ctun_frequency=(vfo[sid].ctun_frequency/step)*step;
+          }
         } else {
-          vfo[sid].frequency=((vfo[sid].frequency-hz)/step)*step;
+          vfo[sid].frequency=((vfo[sid].frequency+hz)/step)*step;
+          if(round) {
+             vfo[sid].ctun_frequency=(vfo[sid].ctun_frequency/step)*step;
+          }
         }
         break;
     }
@@ -715,9 +733,9 @@ vfo_scroll_event_cb (GtkWidget      *widget,
 {
   int i;
   if(event->direction==GDK_SCROLL_UP) {
-    vfo_move(step);
+    vfo_move(step,TRUE);
   } else {
-    vfo_move(-step);
+    vfo_move(-step,TRUE);
   }
   return FALSE;
 }
@@ -1061,7 +1079,7 @@ void vfo_update() {
         cairo_show_text(cr, "Locked");
 
         //cairo_move_to(cr, 55, 50);
-        cairo_move_to(cr, 260, 15);
+        cairo_move_to(cr, 260, 18);
         if(split) {
           cairo_set_source_rgb(cr, 1.0, 0.0, 0.0);
         } else {
@@ -1070,7 +1088,7 @@ void vfo_update() {
         cairo_show_text(cr, "Split");
 
         //cairo_move_to(cr, 95, 50);
-        cairo_move_to(cr, 260, 25);
+        cairo_move_to(cr, 260, 28);
         if(sat_mode!=SAT_NONE) {
           cairo_set_source_rgb(cr, 1.0, 0.0, 0.0);
         } else {
@@ -1090,7 +1108,7 @@ void vfo_update() {
         }
         sprintf(temp_text,"DUP");
         //cairo_move_to(cr, 130, 50);
-        cairo_move_to(cr, 260, 35);
+        cairo_move_to(cr, 260, 38);
         cairo_set_font_size(cr, 12);
         cairo_show_text(cr, temp_text);
 
diff --git a/vfo.h b/vfo.h
index 310e35c91576c39c1f3df52a21870c67293f0215..9ad802bbc897035ef18bde4a891260cebd14fd51 100644 (file)
--- a/vfo.h
+++ b/vfo.h
@@ -66,7 +66,7 @@ extern char *step_labels[];
 
 extern GtkWidget* vfo_init(int width,int height,GtkWidget *parent);
 extern void vfo_step(int steps);
-extern void vfo_move(long long hz);
+extern void vfo_move(long long hz,int round);
 extern void vfo_move_to(long long hz);
 extern void vfo_update();
 extern void set_frequency();