]> git.rkrishnan.org Git - pihpsdr.git/commitdiff
ctun: while turning ctun from on to off, copy last ctun freq ctun-expt
authorRamakrishnan Muthukrishnan <ram@rkrishnan.org>
Sat, 6 Jan 2024 15:53:37 +0000 (21:23 +0530)
committerRamakrishnan Muthukrishnan <ram@rkrishnan.org>
Sat, 6 Jan 2024 15:53:37 +0000 (21:23 +0530)
ext.c

diff --git a/ext.c b/ext.c
index 06f52c0fe8c4a04a578688530d65bc58cbdb92bd..58fc2a91f5edec513f95da6720d5ae935e5801d2 100644 (file)
--- a/ext.c
+++ b/ext.c
@@ -604,12 +604,18 @@ int ext_mode_minus(void *data) {
 }
 
 void ctun_update(int id,int state) {
-  vfo[id].ctun=state;
-  if(!vfo[id].ctun) {
-    vfo[id].offset=0;
-  }
-  vfo[id].ctun_frequency=vfo[id].frequency;
-  set_offset(receiver[id],vfo[id].offset);
+    if (vfo[id].ctun == 1 && state == 0) {
+       // ctune was on and now we are switching off
+       vfo[id].frequency = vfo[id].ctun_frequency;
+    } else if (vfo[id].ctun == 0 && state == 1) {
+       // ctun was off, now we turned on
+       vfo[id].ctun_frequency=vfo[id].frequency;
+    }
+    vfo[id].ctun=state;
+    if(!vfo[id].ctun) {
+       vfo[id].offset=0;
+    }
+    set_offset(receiver[id],vfo[id].offset);
 }
 
 int ext_ctun_update(void *data) {