]> git.rkrishnan.org Git - pihpsdr.git/commitdiff
rigctl: implement FR cat command to toggle between VFOs on split
authorRamakrishnan Muthukrishnan <ram@rkrishnan.org>
Tue, 7 Nov 2023 02:24:07 +0000 (07:54 +0530)
committerRamakrishnan Muthukrishnan <ram@rkrishnan.org>
Tue, 7 Nov 2023 02:24:07 +0000 (07:54 +0530)
radio.c
receiver.h
rigctl.c
vfo.c

diff --git a/radio.c b/radio.c
index bb819d200aff1fd9c1e35fdbab4cfa0ed3dd12e0..0faeb647a92b2ff49031e97181542c763a997a24 100644 (file)
--- a/radio.c
+++ b/radio.c
@@ -545,6 +545,7 @@ static void create_visual() {
 #endif
     receiver[i]->x = 0;
     receiver[i]->y = y;
+    receiver[i]->active_vfo = VFO_A;
     // Upon startup, if RIT or CTUN is active, tell WDSP.
 #ifdef CLIENT_SERVER
     if (!radio_is_remote) {
index 0749ac9fae7998edc819f3469d9e1ec1f79235bc..59b53de39ad984f510038e3d3bf8ff3135e8a6e0 100644 (file)
@@ -166,6 +166,9 @@ typedef struct _receiver {
 
   gint x;
   gint y;
+
+  // active_vfo: used by the UI to highlight the selected vfo for update etc.
+  gint active_vfo;
 } RECEIVER;
 
 extern RECEIVER *create_pure_signal_receiver(int id, int buffer_size,int sample_rate,int pixels);
index 6241d28a55cfecac7fb8a9288db95f96225709fb..42ca9f34c2b84b2e77671e94a3f8b099677416f0 100644 (file)
--- a/rigctl.c
+++ b/rigctl.c
@@ -3032,28 +3032,47 @@ int parse_cmd(void *data) {
             implemented = FALSE;
             break;
         case 'R': // FR
-            // set/read transceiver receive VFO
+            // set/read transceiver receive VFO.
+           //
+           // If there is only one receiver and if it is in split
+           // mode, it returns the active VFO id'. If there are two
+           // receivers, then it switches between the receivers.
+           // When queried, it returns the active receiver's active
+           // vfo.
             if (command[2] == ';') {
-                sprintf(reply, "FR%d;", active_receiver->id);
+                sprintf(reply, "FR%d;", active_receiver->active_vfo);
                 send_resp(client->fd, reply);
             } else if (command[3] == ';') {
                 int id = atoi(&command[2]);
-                switch (id) {
-                case 0:
-                    active_receiver = receiver[id];
-                    break;
-                case 1:
-                    if (receivers == 2) {
-                        active_receiver = receiver[id];
-                    } else {
-                        implemented = FALSE;
-                    }
-                    break;
-                default:
-                    implemented = FALSE;
-                    break;
-                }
-            }
+               if (receivers == 1) {
+                   if (split == 1) {
+                       // id is taken as the VFO id
+                       switch (id) {
+                       case 0:
+                       case 1:
+                           active_receiver->active_vfo = id;
+                           break;
+                       default:
+                           // illegal value
+                           break;
+                       }
+                   } else {
+                       // split is not active. Ignore the command.
+                   }
+               } else if (receivers == 2) {
+                   // id is taken as the receiver id
+                   switch (id) {
+                   case 0:
+                   case 1:
+                       active_receiver = receiver[id];
+                       break;
+                   default:
+                       // ignore
+                       break;
+                   }
+               }
+           }
+           vfo_update();
             break;
         case 'S': // FS
             // set/read the fine tune function status
diff --git a/vfo.c b/vfo.c
index 44e55813e7e2e29277c1c83b60b1f4cb6c13b475..727fceab7b8785f4d90f44900a9b0103654889ee 100644 (file)
--- a/vfo.c
+++ b/vfo.c
@@ -1028,18 +1028,6 @@ void vfo_update() {
         cairo_move_to(cr, 70, 80);
         cairo_show_text(cr, temp_text);
 
-        /* // draw CW (wpm) */
-        /* switch(vfo[id].mode) { */
-        /* case modeCWU: */
-        /* case modeCWL: */
-        /*     cairo_set_font_size(cr, 16); */
-        /*     cairo_set_source_rgb(cr, 1.0, 1.0, 0.0); */
-        /*     cairo_show_text(cr, " wpm"); */
-        /*     break; */
-        /* default: */
-        /*     break; */
-        /* } */
-
        // In what follows, we want to display the VFO frequency
        // on which we currently transmit a signal with red colour.
        // If it is out-of-band, we display "Out of band" in red.
@@ -1134,10 +1122,18 @@ void vfo_update() {
                 cairo_set_source_rgb(cr, 0.0, 1.0, 1.0);
             }
         }
+
         cairo_move_to(cr, 285, 20);
         cairo_set_font_size(cr, 18);
         cairo_show_text(cr, temp_text);
 
+       // show the currently active VFO.
+       cairo_set_source_rgb(cr, 1.0, 1.0, 0.0);
+       sprintf(temp_text, "%c", active_receiver->active_vfo == 0 ? 'A' : 'B');
+       cairo_move_to(cr, 400, 20);
+       cairo_set_font_size(cr, 18);
+       cairo_show_text(cr, temp_text);
+
 #ifdef PURESIGNAL
         if(can_transmit) {
           cairo_move_to(cr, 130, 50);
@@ -1259,42 +1255,6 @@ void vfo_update() {
             break;
         }
 
-       //
-       // Since we can now change it by a MIDI controller,
-       // we should display the compressor (level)
-       //
-        /* if(can_transmit) { */
-        /*   cairo_move_to(cr, 395, 20); */
-       /*   if (transmitter->compressor) { */
-       /*     sprintf(temp_text,"CMPR %ddB",(int) transmitter->compressor_level); */
-        /*     cairo_set_source_rgb(cr, 1.0, 1.0, 0.0); */
-        /*     cairo_show_text(cr, temp_text); */
-       /*   } else { */
-        /*     cairo_set_source_rgb(cr, 0.7, 0.7, 0.7); */
-        /*     cairo_show_text(cr, "CMPR"); */
-       /*   } */
-        /* } */
-
-        /* cairo_move_to(cr, 505, 80);   */
-        /* if(diversity_enabled) { */
-        /*   cairo_set_source_rgb(cr, 1.0, 1.0, 0.0); */
-        /* } else { */
-        /*   cairo_set_source_rgb(cr, 0.7, 0.7, 0.7); */
-        /* } */
-        /* cairo_show_text(cr, "DIV"); */
-
-        /* sprintf(temp_text,"Step %s",step_labels[s]); */
-        /* cairo_move_to(cr, 400, 15); */
-        /* cairo_set_source_rgb(cr, 1.0, 1.0, 0.0); */
-        /* cairo_show_text(cr, temp_text); */
-
-        /* cairo_move_to(cr, 395, 40); */
-        /* if(vfo[id].ctun) { */
-        /*   cairo_set_source_rgb(cr, 1.0, 1.0, 0.0); */
-        /* } else { */
-        /*   cairo_set_source_rgb(cr, 0.7, 0.7, 0.7); */
-        /* } */
-        /* cairo_show_text(cr, "CTUN"); */
 
 #ifdef MIDI
         cairo_move_to(cr, 480, 20);
@@ -1306,14 +1266,6 @@ void vfo_update() {
         cairo_show_text(cr, "MIDI");
 #endif
 
-        /* cairo_move_to(cr, 475, 90);   */
-        /* if(cat_control>0) { */
-        /*   cairo_set_source_rgb(cr, 1.0, 1.0, 0.0); */
-        /* } else { */
-        /*   cairo_set_source_rgb(cr, 0.7, 0.7, 0.7); */
-        /* } */
-        /* cairo_show_text(cr, "CAT"); */
-
         if(can_transmit) {
           cairo_move_to(cr, 160, 40);
           if(vox_enabled) {