From 478922ffcdf9ac8eeb7775a287a9de851698953e Mon Sep 17 00:00:00 2001 From: c vw Date: Mon, 13 Sep 2021 17:29:51 +0200 Subject: [PATCH] VFO step size stored "by mode", better treatment of VFO step sizes, polished applying mode_settings. --- actions.c | 14 ++---- ext.c | 16 +------ rigctl.c | 40 +++------------- step_menu.c | 4 +- vfo.c | 135 ++++++++++++++++++++++++++++++++-------------------- vfo.h | 4 ++ vfo_menu.c | 7 ++- 7 files changed, 108 insertions(+), 112 deletions(-) diff --git a/actions.c b/actions.c index c48ebb2..53f6c12 100644 --- a/actions.c +++ b/actions.c @@ -1159,25 +1159,19 @@ int process_action(void *data) { break; case VFO_STEP_MINUS: if(a->mode==PRESSED) { - for(i=0;i=STEPS) i=0; + i=vfo_get_stepindex(); i--; if(i<0) i=STEPS-1; - step=steps[i]; + vfo_set_stepsize(steps[i]); g_idle_add(ext_vfo_update, NULL); } break; case VFO_STEP_PLUS: if(a->mode==PRESSED) { - for(i=0;i=STEPS) i=0; + i=vfo_get_stepindex(); i++; if(i>=STEPS) i=0; - step=steps[i]; + vfo_set_stepsize(steps[i]); g_idle_add(ext_vfo_update, NULL); } break; diff --git a/ext.c b/ext.c index 3370fa8..7cfa1de 100644 --- a/ext.c +++ b/ext.c @@ -190,26 +190,14 @@ void num_pad(int val) { } void update_vfo_step(int direction) { - int i; - for (i=0; i= STEPS) i=1; + int i = vfo_get_stepindex();; if (direction > 0) { i++; } else { i--; } - if (i >= STEPS) i=STEPS-1; - if (i < 0 ) i=0; - step=steps[i]; - + vfo_set_step_from_index(i); vfo_update(); } diff --git a/rigctl.c b/rigctl.c index f35a8c0..227c9ce 100644 --- a/rigctl.c +++ b/rigctl.c @@ -798,22 +798,12 @@ gboolean parse_extended_cmd (char *command,CLIENT *client) { // sets or reads the Step Size if(command[4]==';') { // read the step size - int i=0; - for(i=0;ifd,reply) ; - } + sprintf(reply,"ZZAC%02d;",vfo_get_stepindex()); + send_resp(client->fd,reply) ; } else if(command[6]==';') { // set the step size int i=atoi(&command[4]) ; - if(i>=0 && i=0 && step_index=0 && step_index=0 && step_index=0 && step_index= 0 && valnr =mode_settings[m].nr; + active_receiver->nr2=mode_settings[m].nr2; + active_receiver->nb =mode_settings[m].nb; + active_receiver->nb2=mode_settings[m].nb2; + active_receiver->anf=mode_settings[m].anf; + active_receiver->snb=mode_settings[m].snb; + enable_rx_equalizer =mode_settings[m].en_rxeq; + rx_equalizer[0] =mode_settings[m].rxeq[0]; + rx_equalizer[1] =mode_settings[m].rxeq[1]; + rx_equalizer[2] =mode_settings[m].rxeq[2]; + rx_equalizer[3] =mode_settings[m].rxeq[3]; + enable_tx_equalizer =mode_settings[m].en_txeq; + tx_equalizer[0] =mode_settings[m].txeq[0]; + tx_equalizer[1] =mode_settings[m].txeq[1]; + tx_equalizer[2] =mode_settings[m].txeq[2]; + tx_equalizer[3] =mode_settings[m].txeq[3]; + step =mode_settings[m].step; + + // make changes effective + g_idle_add(ext_update_noise, NULL); + g_idle_add(ext_update_eq , NULL); + +} + void vfo_band_changed(int id,int b) { BANDSTACK *bandstack; - int m; #ifdef CLIENT_SERVER if(radio_is_remote) { @@ -372,32 +408,7 @@ void vfo_band_changed(int id,int b) { vfo[id].mode=entry->mode; vfo[id].lo=band->frequencyLO+band->errorLO; -// -// Apply the filter/NR combination stored for this mode -// - m=vfo[id].mode; - - vfo[id].filter =mode_settings[m].filter; - active_receiver->nr =mode_settings[m].nr; - active_receiver->nr2=mode_settings[m].nr2; - active_receiver->nb =mode_settings[m].nb; - active_receiver->nb2=mode_settings[m].nb2; - active_receiver->anf=mode_settings[m].anf; - active_receiver->snb=mode_settings[m].snb; - enable_rx_equalizer =mode_settings[m].en_rxeq; - rx_equalizer[0] =mode_settings[m].rxeq[0]; - rx_equalizer[1] =mode_settings[m].rxeq[1]; - rx_equalizer[2] =mode_settings[m].rxeq[2]; - rx_equalizer[3] =mode_settings[m].rxeq[3]; - enable_tx_equalizer =mode_settings[m].en_txeq; - tx_equalizer[0] =mode_settings[m].txeq[0]; - tx_equalizer[1] =mode_settings[m].txeq[1]; - tx_equalizer[2] =mode_settings[m].txeq[2]; - tx_equalizer[3] =mode_settings[m].txeq[3]; - - // make changes effective - g_idle_add(ext_update_noise, NULL); - g_idle_add(ext_update_eq , NULL); + vfo_apply_mode_settings(id); // turn off ctun vfo[id].ctun=0; @@ -497,30 +508,8 @@ void vfo_mode_changed(int m) { #endif vfo[id].mode=m; -// -// Change to the filter/NR combination stored for this mode -// - vfo[id].filter =mode_settings[m].filter; - active_receiver->nr =mode_settings[m].nr; - active_receiver->nr2=mode_settings[m].nr2; - active_receiver->nb =mode_settings[m].nb; - active_receiver->nb2=mode_settings[m].nb2; - active_receiver->anf=mode_settings[m].anf; - active_receiver->snb=mode_settings[m].snb; - enable_rx_equalizer =mode_settings[m].en_rxeq; - rx_equalizer[0] =mode_settings[m].rxeq[0]; - rx_equalizer[1] =mode_settings[m].rxeq[1]; - rx_equalizer[2] =mode_settings[m].rxeq[2]; - rx_equalizer[3] =mode_settings[m].rxeq[3]; - enable_tx_equalizer =mode_settings[m].en_txeq; - tx_equalizer[0] =mode_settings[m].txeq[0]; - tx_equalizer[1] =mode_settings[m].txeq[1]; - tx_equalizer[2] =mode_settings[m].txeq[2]; - tx_equalizer[3] =mode_settings[m].txeq[3]; + vfo_apply_mode_settings(id); - // make changes effective - g_idle_add(ext_update_noise, NULL); - g_idle_add(ext_update_eq , NULL); switch(id) { case 0: receiver_mode_changed(receiver[0]); @@ -684,6 +673,50 @@ void vfo_a_swap_b() { g_idle_add(ext_vfo_update,NULL); } +// +// here we collect various functions to +// get/set the VFO step size +// + +int vfo_get_stepindex() { + // + // return index of current step size in steps[] array, + // or 1 if not found + // + int i; + for(i=0;i= STEPS) i=1; + return i; +} + +void vfo_set_step_from_index(int index) { + // + // Set VFO step size to steps[index], with range checking + // + if (index < 0) index=0; + if (index >= STEPS) index = STEPS-1; + vfo_set_stepsize(steps[index]); +} + +void vfo_set_stepsize(long long newstep) { + // + // Set current VFO step size. + // and store the value in mode_settings of the current mode + // + int id=active_receiver->id; + int m=vfo[id].mode; + + step=newstep; + mode_settings[m].step=newstep; +} + void vfo_step(int steps) { int id=active_receiver->id; long long delta; diff --git a/vfo.h b/vfo.h index f380cce..82b124a 100644 --- a/vfo.h +++ b/vfo.h @@ -67,6 +67,7 @@ struct _mode_settings { int en_rxeq; // RX equalizer on/off int txeq[4]; // TX equalizer settings int rxeq[4]; // RX equalizer settings + long long step; // VFO step size }; extern struct _mode_settings mode_settings[]; @@ -81,6 +82,9 @@ extern int steps[]; extern char *step_labels[]; extern GtkWidget* vfo_init(int width,int height,GtkWidget *parent); +extern int vfo_get_stepindex(); +extern void vfo_set_step_from_index(int index); +extern void vfo_set_stepsize(long long newstep); extern void vfo_step(int steps); extern void vfo_id_step(int id, int steps); extern void vfo_move(long long hz,int round); diff --git a/vfo_menu.c b/vfo_menu.c index 49c4c39..e47db55 100644 --- a/vfo_menu.c +++ b/vfo_menu.c @@ -187,8 +187,11 @@ static void rit_cb(GtkComboBox *widget,gpointer data) { } static void vfo_cb(GtkComboBox *widget,gpointer data) { - step=steps[gtk_combo_box_get_active(widget)]; - g_idle_add(ext_vfo_update,NULL); + int i=gtk_combo_box_get_active(widget); + if (i >= 0 && i < STEPS) { + vfo_set_stepsize(steps[i]); + g_idle_add(ext_vfo_update,NULL); + } } #ifdef PURESIGNAL -- 2.45.2