From a84905e6eb259d2c904582ca182c9ad2109e1d90 Mon Sep 17 00:00:00 2001 From: Ramakrishnan Muthukrishnan Date: Tue, 7 Nov 2023 07:54:07 +0530 Subject: [PATCH] rigctl: implement FR cat command to toggle between VFOs on split --- radio.c | 1 + receiver.h | 3 +++ rigctl.c | 55 +++++++++++++++++++++++++++++++--------------- vfo.c | 64 +++++++----------------------------------------------- 4 files changed, 49 insertions(+), 74 deletions(-) diff --git a/radio.c b/radio.c index bb819d2..0faeb64 100644 --- 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) { diff --git a/receiver.h b/receiver.h index 0749ac9..59b53de 100644 --- a/receiver.h +++ b/receiver.h @@ -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); diff --git a/rigctl.c b/rigctl.c index 6241d28..42ca9f3 100644 --- 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 44e5581..727fcea 100644 --- 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) { -- 2.45.2