From b8fb5857d0a183238a868e24c3cd33bb3bba806c Mon Sep 17 00:00:00 2001
From: John Melton G0ORX <john.d.melton@googlemail.com>
Date: Sun, 23 Feb 2020 11:54:19 +0000
Subject: [PATCH] Cleanup code to remove unused txLO and txError

---
 band.c            | 17 -----------------
 band.h            |  2 --
 new_menu.c        |  6 +++++-
 new_menu.h        |  3 ++-
 rx_panadapter.c   |  4 ++--
 soapy_discovery.c |  2 --
 soapy_protocol.c  |  5 ++---
 tx_panadapter.c   |  5 ++---
 vfo.c             |  7 -------
 vfo.h             |  1 -
 xvtr_menu.c       | 25 -------------------------
 11 files changed, 13 insertions(+), 64 deletions(-)

diff --git a/band.c b/band.c
index 92543d2..d93df5b 100644
--- a/band.c
+++ b/band.c
@@ -457,15 +457,6 @@ void bandSaveState() {
         sprintf(name,"band.%d.errorLO",b);
         setProperty(name,value);
 
-        sprintf(value,"%lld",bands[b].txFrequencyLO);
-        sprintf(name,"band.%d.txFrequencyLO",b);
-        setProperty(name,value);
-
-        sprintf(value,"%lld",bands[b].txErrorLO);
-        sprintf(name,"band.%d.txErrorLO",b);
-        setProperty(name,value);
-
-
         sprintf(value,"%d",bands[b].disablePA);
         sprintf(name,"band.%d.disablePA",b);
         setProperty(name,value);
@@ -582,14 +573,6 @@ void bandRestoreState() {
         value=getProperty(name);
         if(value) bands[b].errorLO=atoll(value);
 
-        sprintf(name,"band.%d.txFrequencyLO",b);
-        value=getProperty(name);
-        if(value) bands[b].txFrequencyLO=atoll(value);
-
-        sprintf(name,"band.%d.txErrorLO",b);
-        value=getProperty(name);
-        if(value) bands[b].txErrorLO=atoll(value);
-
         sprintf(name,"band.%d.disablePA",b);
         value=getProperty(name);
         if(value) bands[b].disablePA=atoi(value);
diff --git a/band.h b/band.h
index 7d2de4d..4163ce5 100644
--- a/band.h
+++ b/band.h
@@ -73,8 +73,6 @@ struct _BAND {
     long long frequencyMax;
     long long frequencyLO;
     long long errorLO;
-    long long txFrequencyLO;
-    long long txErrorLO;
     int disablePA;
 };
 
diff --git a/new_menu.c b/new_menu.c
index d354574..4b943c1 100644
--- a/new_menu.c
+++ b/new_menu.c
@@ -331,8 +331,12 @@ static gboolean diversity_cb (GtkWidget *widget, GdkEventButton *event, gpointer
 }
 
 void start_vfo() {
+  int old_menu=active_menu;
   cleanup();
-  vfo_menu(top_window);
+  if(old_menu!=VFO_MENU) {
+    vfo_menu(top_window);
+    active_menu=VFO_MENU;
+  }
 }
 
 static gboolean vfo_cb (GtkWidget *widget, GdkEventButton *event, gpointer data) {
diff --git a/new_menu.h b/new_menu.h
index 0d8bdc0..d087f92 100644
--- a/new_menu.h
+++ b/new_menu.h
@@ -38,7 +38,8 @@ enum {
   MODE_MENU,
   FILTER_MENU,
   NOISE_MENU,
-  AGC_MENU
+  AGC_MENU,
+  VFO_MENU
 };
 
 extern int active_menu;
diff --git a/rx_panadapter.c b/rx_panadapter.c
index 3db0fed..ae696f1 100644
--- a/rx_panadapter.c
+++ b/rx_panadapter.c
@@ -263,12 +263,12 @@ void rx_panadapter_update(RECEIVER *rx) {
       divisor=50000L;
       break;
     case 768000:
-      divisor=50000L;
+      divisor=100000L;
       break;
     case 1048576:
     case 1536000:
     case 2097152:
-      divisor=100000L;
+      divisor=200000L;
       break;
   }
   for(i=0;i<display_width;i++) {
diff --git a/soapy_discovery.c b/soapy_discovery.c
index 9633428..db472d9 100644
--- a/soapy_discovery.c
+++ b/soapy_discovery.c
@@ -109,11 +109,9 @@ static void get_info(char *driver) {
         if((384000.0>=rx_rates[i].minimum) && (384000<=(int)rx_rates[i].maximum)) {
           sample_rate=384000;
         }
-/*
         if((768000.0>=rx_rates[i].minimum) && (768000<=(int)rx_rates[i].maximum)) {
           sample_rate=768000;
         }
-*/
       }
     }
   }
diff --git a/soapy_protocol.c b/soapy_protocol.c
index a6bd4ea..6a988e6 100644
--- a/soapy_protocol.c
+++ b/soapy_protocol.c
@@ -375,11 +375,10 @@ void soapy_protocol_set_tx_frequency(TRANSMITTER *tx) {
 
   v=get_tx_vfo();
   if(soapy_device!=NULL) {
-    //f=(double)(vfo[v].frequency+vfo[v].ctun_frequency-vfo[v].lo_tx);
     if(vfo[v].ctun) {
-      f=(double)(vfo[v].ctun_frequency-vfo[v].lo_tx);
+      f=(double)(vfo[v].ctun_frequency);
     } else {
-      f=(double)(vfo[v].frequency-vfo[v].lo_tx);
+      f=(double)(vfo[v].frequency);
     }
 
     if(transmitter->xit_enabled) {
diff --git a/tx_panadapter.c b/tx_panadapter.c
index 202e7f8..403deea 100644
--- a/tx_panadapter.c
+++ b/tx_panadapter.c
@@ -241,13 +241,12 @@ void tx_panadapter_update(TRANSMITTER *tx) {
   }
 
   // plot frequency markers
-  //long long half=24000LL; //(long long)(tx->output_rate/2);
   long long half=6000LL; //(long long)(tx->output_rate/2);
   long long frequency;
   if(vfo[txvfo].ctun) {
-    frequency=vfo[txvfo].ctun_frequency-vfo[txvfo].lo_tx;
+    frequency=vfo[txvfo].ctun_frequency;
   } else {
-    frequency=vfo[txvfo].frequency-vfo[txvfo].lo_tx;
+    frequency=vfo[txvfo].frequency;
   }
   double vfofreq=(double)display_width * 0.5;
   if (!cw_is_on_vfo_freq) {
diff --git a/vfo.c b/vfo.c
index f83cf67..9c41bdb 100644
--- a/vfo.c
+++ b/vfo.c
@@ -168,9 +168,6 @@ void vfo_save_state() {
     sprintf(name,"vfo.%d.lo",i);
     sprintf(value,"%lld",vfo[i].lo);
     setProperty(name,value);
-    sprintf(name,"vfo.%d.lo_tx",i);
-    sprintf(value,"%lld",vfo[i].lo_tx);
-    setProperty(name,value);
     sprintf(name,"vfo.%d.ctun_frequency",i);
     sprintf(value,"%lld",vfo[i].ctun_frequency);
     setProperty(name,value);
@@ -244,9 +241,6 @@ g_print("vfo_restore_state: band=%d frequency=%lld\n",vfo[i].band,vfo[i].frequen
     sprintf(name,"vfo.%d.filter",i);
     value=getProperty(name);
     if(value) vfo[i].filter=atoi(value);
-    sprintf(name,"vfo.%d.lo_tx",i);
-    value=getProperty(name);
-    if(value) vfo[i].lo_tx=atoll(value);
     // Sanity check: if !ctun, offset must be zero
     if (!vfo[i].ctun) {
 	vfo[i].offset=0;
@@ -293,7 +287,6 @@ void vfo_band_changed(int b) {
   vfo[id].mode=entry->mode;
   vfo[id].filter=entry->filter;
   vfo[id].lo=band->frequencyLO+band->errorLO;
-  vfo[id].lo_tx=band->txFrequencyLO+band->txErrorLO;
 
   // turn off ctun
   vfo[id].ctun=0;
diff --git a/vfo.h b/vfo.h
index bd08e57..f2927bc 100644
--- a/vfo.h
+++ b/vfo.h
@@ -43,7 +43,6 @@ struct _vfo {
 
   long long lo;
   long long offset;
-  long long lo_tx;
 
 } vfo[MAX_VFOS];
 
diff --git a/xvtr_menu.c b/xvtr_menu.c
index 805ded7..c8b7d83 100644
--- a/xvtr_menu.c
+++ b/xvtr_menu.c
@@ -68,14 +68,6 @@ static void save_xvtr () {
         xvtr->frequencyLO=(long long)(atof(lof)*1000000.0);
         loerr=gtk_entry_get_text(GTK_ENTRY(lo_error[i]));
         xvtr->errorLO=atoll(loerr);
-/*
-        txlof=gtk_entry_get_text(GTK_ENTRY(tx_lo_frequency[i]));
-        xvtr->txFrequencyLO=(long long)(atof(txlof)*1000000.0);
-        txloerr=gtk_entry_get_text(GTK_ENTRY(tx_lo_error[i]));
-        xvtr->txErrorLO=atoll(txloerr);
-*/
-        xvtr->txFrequencyLO=0LL;
-        xvtr->txErrorLO=0LL;
         xvtr->disablePA=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(disable_pa[i]));
 
         for(b=0;b<bandstack->entries;b++) {
@@ -105,7 +97,6 @@ void update_receiver(int band,gboolean error) {
     BAND *xvtr=band_get_band(band);
 //g_print("update_receiver: found band: %s\n",xvtr->title);
     vfo[0].lo=xvtr->frequencyLO+xvtr->errorLO;
-    vfo[0].lo_tx=xvtr->txFrequencyLO+xvtr->txErrorLO;
     saved_ctun=vfo[0].ctun;
     if(saved_ctun) {
       vfo[0].ctun=FALSE;
@@ -170,22 +161,6 @@ g_print("lo_error_update: band=%d\n",vfo[0].band);
   update_receiver(vfo[0].band,TRUE);
 }
 
-void tx_lo_frequency_cb(GtkEditable *editable,gpointer user_data) {
-  int band=GPOINTER_TO_INT(user_data);
-  BAND *xvtr=band_get_band(band);
-  const char* lof=gtk_entry_get_text(GTK_ENTRY(tx_lo_frequency[band]));
-  xvtr->txFrequencyLO=(long long)(atof(lof)*1000000.0);
-  update_receiver(band,FALSE);
-}
-
-void tx_lo_error_cb(GtkEditable *editable,gpointer user_data) {
-  int band=GPOINTER_TO_INT(user_data);
-  BAND *xvtr=band_get_band(band);
-  const char* errorf=gtk_entry_get_text(GTK_ENTRY(tx_lo_error[band]));
-  xvtr->txErrorLO=atoll(errorf);
-  update_receiver(band,TRUE);
-}
-
 static void cleanup() {
   save_xvtr();
   if(dialog!=NULL) {
-- 
2.45.2