// sets or reads the Step Size
if(command[4]==';') {
// read the step size
- int i=0;
- for(i=0;i<STEPS;i++) {
- if(steps[i]==step) break;
- }
- if(i<STEPS) {
- // send reply back
- sprintf(reply,"ZZAC%02d;",i);
- send_resp(client->fd,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<STEPS) {
- step=steps[i];
- vfo_update();
- }
+ vfo_set_step_from_index(i);
} else {
}
break;
// move VFO A down by selected step
if(command[6]==';') {
int step_index=atoi(&command[4]);
- long long hz=0;
if(step_index>=0 && step_index<STEPS) {
- hz=(long long)steps[step_index];
- }
- if(hz!=0LL) {
- vfo_id_move(VFO_A,-hz,FALSE);
+ vfo_id_move(VFO_A,-steps[step_index],FALSE);
}
} else {
}
// move VFO A up by selected step
if(command[6]==';') {
int step_index=atoi(&command[4]);
- long long hz=0;
if(step_index>=0 && step_index<STEPS) {
- hz=(long long)steps[step_index];
- }
- if(hz!=0LL) {
- vfo_id_move(VFO_A,hz,FALSE);
+ vfo_id_move(VFO_A,steps[step_index],FALSE);
}
} else {
}
// move VFO B down by selected step
if(command[6]==';') {
int step_index=atoi(&command[4]);
- long long hz=0;
if(step_index>=0 && step_index<STEPS) {
- hz=(long long)steps[step_index];
- }
- if(hz!=0LL) {
- vfo_id_move(VFO_B,-hz,FALSE);
+ vfo_id_move(VFO_B,-steps[step_index],FALSE);
}
} else {
}
// move VFO B up by selected step
if(command[6]==';') {
int step_index=atoi(&command[4]);
- long long hz=0;
if(step_index>=0 && step_index<STEPS) {
- hz=(long long)steps[step_index];
- }
- if(hz!=0LL) {
- vfo_id_move(VFO_B,hz,FALSE);
+ vfo_id_move(VFO_B,steps[step_index],FALSE);
}
} else {
}
sprintf(name,"modeset.%d.rxeq.3", i);
sprintf(value,"%d", mode_settings[i].rxeq[3]);
setProperty(name,value);
+ sprintf(name,"modeset.%d.step", i);
+ sprintf(value,"%lld", mode_settings[i].step);
+ setProperty(name,value);
}
}
char name[80];
char *value;
- // set some reasonable defaults for the filters
+ // set some reasonable defaults
for (i=0; i<MODES; i++) {
mode_settings[i].filter=filterF6;
mode_settings[i].rxeq[1]=0;
mode_settings[i].rxeq[2]=0;
mode_settings[i].rxeq[3]=0;
+ mode_settings[i].step=100;
sprintf(name,"modeset.%d.filter",i);
value=getProperty(name);
sprintf(name,"modeset.%d.rxeq.3",i);
value=getProperty(name);
if(value) mode_settings[i].rxeq[3]=atoi(value);
+ sprintf(name,"modeset.%d.step",i);
+ value=getProperty(name);
+ if(value) mode_settings[i].step=atoll(value);
}
}
}
}
+void vfo_apply_mode_settings(int id) {
+ int m;
+
+ 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];
+ 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) {
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;
#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]);
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++) {
+ if(steps[i]==step) break;
+ }
+ //
+ // If step size is not found (usually cannot happen)
+ // report second-smallest step size so that we can
+ // safely increment and decrement in the caller
+ //
+ if (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;