Skip to content

Commit

Permalink
Some updates related to "filters"
Browse files Browse the repository at this point in the history
  • Loading branch information
dl1ycf committed Dec 6, 2021
1 parent 9b67d8c commit 4eae9c4
Show file tree
Hide file tree
Showing 9 changed files with 158 additions and 165 deletions.
10 changes: 0 additions & 10 deletions cw_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,16 +128,6 @@ static void cw_keyer_sidetone_level_value_changed_cb(GtkWidget *widget, gpointer

static void cw_keyer_sidetone_frequency_value_changed_cb(GtkWidget *widget, gpointer data) {
cw_keyer_sidetone_frequency=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget));
/*
int txmode=get_tx_mode();
if(txmode==modeCWL || txmode==modeCWU) {
BANDSTACK_ENTRY *entry=bandstack_entry_get_current();
FILTER* band_filters=filters[entry->mode];
FILTER* band_filter=&band_filters[entry->filter];
//setFilter(band_filter->low,band_filter->high);
set_filter(active_receiver,band_filter->low,band_filter->high);
}
*/
cw_changed();
receiver_filter_changed(active_receiver);
// changing the side tone frequency affects BFO frequency offsets
Expand Down
53 changes: 29 additions & 24 deletions filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,24 @@ FILTER filterLSB[FILTERS]={
{-2850,-150,"Var2"}
};

//
// DigiMode Filters up to 3000 Hz wide are centered
// around 1500, the broader ones start at
// zero (this also holds for DIGU).
//
FILTER filterDIGL[FILTERS]={
{-5150,-150,"5.0k"},
{-4550,-150,"4.4k"},
{-3950,-150,"3.8k"},
{-3450,-150,"3.3k"},
{-3050,-150,"2.9k"},
{-2850,-150,"2.7k"},
{-2550,-150,"2.4k"},
{-2250,-150,"2.1k"},
{-1950,-150,"1.8k"},
{-1150,-150,"1.0k"},
{-2850,-150,"Var1"},
{-2850,-150,"Var2"}
{-5000, 0,"5.0k"},
{-4000, 0,"4.0k"},
{-3000, 0,"3.0k"},
{-2750, -250,"2.5k"},
{-2500, -500,"2.0k"},
{-2250, -750,"1.5k"},
{-2000,-1000,"1.0k"},
{-1875,-1125,"750"},
{-1750,-1250,"500"},
{-1625,-1375,"250"},
{-3000, 0,"Var1"},
{-2000,-1000,"Var2"}
};

FILTER filterUSB[FILTERS]={
Expand All @@ -73,18 +78,18 @@ FILTER filterUSB[FILTERS]={
};

FILTER filterDIGU[FILTERS]={
{150,5150,"5.0k"},
{150,4550,"4.4k"},
{150,3950,"3.8k"},
{150,3450,"3.3k"},
{150,3050,"2.9k"},
{150,2850,"2.7k"},
{150,2550,"2.4k"},
{150,2250,"2.1k"},
{150,1950,"1.8k"},
{150,1150,"1.0k"},
{150,2850,"Var1"},
{150,2850,"Var2"}
{ 0,5000,"5.0k"},
{ 0,4000,"4.0k"},
{ 0,3000,"3.0k"},
{ 250,2750,"2.5k"},
{ 500,2500,"2.0k"},
{ 750,2250,"1.5k"},
{1000,2000,"1.0k"},
{1125,1875,"750"},
{1250,1750,"500"},
{1375,1625,"250"},
{ 0,3000,"Var1"},
{1000,2000,"Var2"}
};

FILTER filterCWL[FILTERS]={
Expand Down
11 changes: 2 additions & 9 deletions filter_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,8 @@ static gboolean filter_select_cb (GtkWidget *widget, gpointer data) {
static gboolean deviation_select_cb (GtkWidget *widget, gpointer data) {
active_receiver->deviation=GPOINTER_TO_UINT(data);
transmitter->deviation=GPOINTER_TO_UINT(data);
if(active_receiver->deviation==2500) {
//setFilter(-4000,4000);
set_filter(active_receiver,-5500,5500);
tx_set_filter(transmitter,-5500,5500);
} else {
//setFilter(-8000,8000);
set_filter(active_receiver,-8000,8000);
tx_set_filter(transmitter,-8000,8000);
}
set_filter(active_receiver);
tx_set_filter(transmitter);
set_deviation(active_receiver);
transmitter_set_deviation(transmitter);
set_button_text_color(last_filter,"black");
Expand Down
69 changes: 35 additions & 34 deletions receiver.c
Original file line number Diff line number Diff line change
Expand Up @@ -665,16 +665,38 @@ void set_mode(RECEIVER *rx,int m) {
SetRXAMode(rx->id, vfo[rx->id].mode);
}

void set_filter(RECEIVER *rx,int low,int high) {
if(vfo[rx->id].mode==modeCWL) {
rx->filter_low=-cw_keyer_sidetone_frequency-low;
rx->filter_high=-cw_keyer_sidetone_frequency+high;
} else if(vfo[rx->id].mode==modeCWU) {
rx->filter_low=cw_keyer_sidetone_frequency-low;
rx->filter_high=cw_keyer_sidetone_frequency+high;
} else {
rx->filter_low=low;
rx->filter_high=high;
void set_filter(RECEIVER *rx) {
int m=vfo[rx->id].mode;
FILTER *mode_filters=filters[m];
FILTER *filter=&mode_filters[vfo[rx->id].filter]; // ignored in FMN

switch (m) {
case modeCWL:
rx->filter_low=-cw_keyer_sidetone_frequency-filter->low;
rx->filter_high=-cw_keyer_sidetone_frequency+filter->high;
break;
case modeCWU:
rx->filter_low=cw_keyer_sidetone_frequency-filter->low;
rx->filter_high=cw_keyer_sidetone_frequency+filter->high;
break;
case modeFMN:
//
// FM filter settings are ignored, instead, the filter
// size is calculated from the deviation
//
if(rx->deviation==2500) {
rx->filter_low=-5500;
rx->filter_high=5500;
} else {
rx->filter_low=-8000;
rx->filter_high=8000;
}
set_deviation(rx);
break;
default:
rx->filter_low=filter->low;
rx->filter_high=filter->high;
break;
}

RXASetPassband(rx->id,(double)rx->filter_low,(double)rx->filter_high);
Expand Down Expand Up @@ -1280,31 +1302,10 @@ void receiver_frequency_changed(RECEIVER *rx) {
}

void receiver_filter_changed(RECEIVER *rx) {
int filter_low, filter_high;
int m=vfo[rx->id].mode;
if(m==modeFMN) {
if(rx->deviation==2500) {
filter_low=-5500;
filter_high=5500;
} else {
filter_low=-8000;
filter_high=8000;
}
set_filter(rx,filter_low,filter_high);
set_deviation(rx);
} else {
FILTER *mode_filters=filters[m];
FILTER *filter=&mode_filters[vfo[rx->id].filter];
filter_low=filter->low;
filter_high=filter->high;
set_filter(rx,filter_low,filter_high);
}

set_filter(rx);
if(can_transmit && transmitter!=NULL) {
if(transmitter->use_rx_filter) {
if(rx==active_receiver) {
tx_set_filter(transmitter,filter_low,filter_high);
}
if(transmitter->use_rx_filter && rx==active_receiver) {
tx_set_filter(transmitter);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion receiver.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ extern void receiver_change_zoom(RECEIVER *rx,double zoom);
extern void receiver_change_pan(RECEIVER *rx,double pan);

extern void set_mode(RECEIVER* rx,int m);
extern void set_filter(RECEIVER *rx,int low,int high);
extern void set_filter(RECEIVER *rx);
extern void set_agc(RECEIVER *rx, int agc);
extern void set_offset(RECEIVER *rx, long long offset);
extern void set_deviation(RECEIVER *rx);
Expand Down
57 changes: 29 additions & 28 deletions rigctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -2772,15 +2772,11 @@ int parse_cmd(void *data) {
}
break;
case 'W': //FW
// set/read filter width
// make sure filter is filterVar1
if(vfo[active_receiver->id].filter!=filterVar1) {
vfo_filter_changed(filterVar1);
}
FILTER *mode_filters=filters[vfo[active_receiver->id].mode];
FILTER *filter=&mode_filters[filterVar1];
int val=0;
// set/read filter width. Switch to Var1 only when setting
if(command[2]==';') {
int val=0;
FILTER *mode_filters=filters[vfo[active_receiver->id].mode];
FILTER *filter=&mode_filters[vfo[active_receiver->id].filter];
switch(vfo[active_receiver->id].mode) {
case modeCWL:
case modeCWU:
Expand All @@ -2802,8 +2798,13 @@ int parse_cmd(void *data) {
send_resp(client->fd,reply) ;
}
} else if(command[6]==';') {
// make sure filter is filterVar1
if(vfo[active_receiver->id].filter!=filterVar1) {
vfo_filter_changed(filterVar1);
}
FILTER *mode_filters=filters[vfo[active_receiver->id].mode];
FILTER *filter=&mode_filters[filterVar1];
int fw=atoi(&command[2]);
int val=
filter->low=fw;
switch(vfo[active_receiver->id].mode) {
case modeCWL:
Expand Down Expand Up @@ -3366,15 +3367,10 @@ int parse_cmd(void *data) {
}
break;
case 'H': //SH
{
// set/read filter high
// make sure filter is filterVar1
if(vfo[active_receiver->id].filter!=filterVar1) {
vfo_filter_changed(filterVar1);
}
FILTER *mode_filters=filters[vfo[active_receiver->id].mode];
FILTER *filter=&mode_filters[filterVar1];
// set/read filter high, switch to Var1 only when setting
if(command[2]==';') {
FILTER *mode_filters=filters[vfo[active_receiver->id].mode];
FILTER *filter=&mode_filters[vfo[active_receiver->id].filter];
int fh=5;
int high=filter->high;
if(vfo[active_receiver->id].mode==modeLSB) {
Expand Down Expand Up @@ -3408,6 +3404,12 @@ int parse_cmd(void *data) {
sprintf(reply,"SH%02d;",fh);
send_resp(client->fd,reply) ;
} else if(command[4]==';') {
// make sure filter is filterVar1
if(vfo[active_receiver->id].filter!=filterVar1) {
vfo_filter_changed(filterVar1);
}
FILTER *mode_filters=filters[vfo[active_receiver->id].mode];
FILTER *filter=&mode_filters[filterVar1];
int i=atoi(&command[2]);
int fh=100;
switch(vfo[active_receiver->id].mode) {
Expand Down Expand Up @@ -3484,22 +3486,16 @@ int parse_cmd(void *data) {
}
vfo_filter_changed(filterVar1);
}
}
break;
case 'I': //SI
// enter satellite memory name
implemented=FALSE;
break;
case 'L': //SL
{
// set/read filter low
// make sure filter is filterVar1
if(vfo[active_receiver->id].filter!=filterVar1) {
vfo_filter_changed(filterVar1);
}
FILTER *mode_filters=filters[vfo[active_receiver->id].mode];
FILTER *filter=&mode_filters[filterVar1];
// set/read filter low, switch to Var1 only when setting
if(command[2]==';') {
FILTER *mode_filters=filters[vfo[active_receiver->id].mode];
FILTER *filter=&mode_filters[vfo[active_receiver->id].filter];
int fl=2;
int low=filter->low;
if(vfo[active_receiver->id].mode==modeLSB) {
Expand Down Expand Up @@ -3534,6 +3530,12 @@ int parse_cmd(void *data) {
sprintf(reply,"SL%02d;",fl);
send_resp(client->fd,reply) ;
} else if(command[4]==';') {
// make sure filter is filterVar1
if(vfo[active_receiver->id].filter!=filterVar1) {
vfo_filter_changed(filterVar1);
}
FILTER *mode_filters=filters[vfo[active_receiver->id].mode];
FILTER *filter=&mode_filters[filterVar1];
int i=atoi(&command[2]);
int fl=100;
switch(vfo[active_receiver->id].mode) {
Expand Down Expand Up @@ -3610,7 +3612,6 @@ int parse_cmd(void *data) {
}
vfo_filter_changed(filterVar1);
}
}
break;
case 'M': //SM
// read the S meter
Expand All @@ -3634,7 +3635,7 @@ int parse_cmd(void *data) {
if(command[2]=='0') {
int p2=atoi(&command[3]);
active_receiver->squelch=(int)((double)p2/255.0*100.0);
set_squelch();
set_squelch(active_receiver);
}
} else {
}
Expand Down
Loading

0 comments on commit 4eae9c4

Please sign in to comment.