From c9991d492f6935c44e52c67361c818a48f414820 Mon Sep 17 00:00:00 2001
From: Ramakrishnan Muthukrishnan <ram@rkrishnan.org>
Date: Mon, 6 Nov 2023 19:41:12 +0530
Subject: [PATCH] split: depending on mode, set vfo b up by 1kc or 5kc

---
 actions.c |  8 ++++++++
 rigctl.c  | 10 ++++++++++
 2 files changed, 18 insertions(+)

diff --git a/actions.c b/actions.c
index 06be50e..db8618e 100644
--- a/actions.c
+++ b/actions.c
@@ -994,6 +994,14 @@ int process_action(void *data) {
       if(a->mode==PRESSED) {
         if(can_transmit) {
           split=split==1?0:1;
+	  if (split == 1) {
+	      int m = vfo[active_receiver->id].mode;
+	      if ((m == modeLSB) || (m == modeUSB)) {
+		  local_set_frequency(VFO_B, vfo[VFO_A].frequency + 5000);
+	      } else if ((m == modeCWL) || (m == modeCWU)) {
+		  local_set_frequency(VFO_B, vfo[VFO_A].frequency + 1000);
+	      }
+	  }
           tx_set_mode(transmitter,get_tx_mode());
           g_idle_add(ext_vfo_update, NULL);
         }
diff --git a/rigctl.c b/rigctl.c
index 7230dd0..6241d28 100644
--- a/rigctl.c
+++ b/rigctl.c
@@ -2332,6 +2332,16 @@ gboolean parse_extended_cmd(char *command, CLIENT *client) {
                 send_resp(client->fd, reply);
             } else if (command[5] == ';') {
                 split = atoi(&command[4]);
+		if (split == 1) {
+		    // if mode is LSB or USB, set VFO_B to VFO_A +
+		    // 5khz. If mode is CW, set VFO_B to VFO_A + 1khz.
+		    int m = vfo[active_receiver->id].mode;
+		    if ((m == modeLSB) || (m == modeUSB)) {
+			local_set_frequency(VFO_B, vfo[VFO_A].frequency + 5000);
+		    } else if ((m == modeCWL) || (m == modeCWU)) {
+			local_set_frequency(VFO_B, vfo[VFO_A].frequency + 1000);
+		    }
+		}
                 tx_set_mode(transmitter, get_tx_mode());
                 vfo_update();
             }
-- 
2.45.2