From: Ramakrishnan Muthukrishnan Date: Sat, 6 Jan 2024 15:53:37 +0000 (+0530) Subject: ctun: while turning ctun from on to off, copy last ctun freq X-Git-Url: https://git.rkrishnan.org/pf/content/en/COPYING.TGPPL.html?a=commitdiff_plain;h=bf4c37f845b1264cea8cd7675a4d110922698d39;p=pihpsdr.git ctun: while turning ctun from on to off, copy last ctun freq --- diff --git a/ext.c b/ext.c index 06f52c0..58fc2a9 100644 --- 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) {