Skip to content

Commit

Permalink
Merge branch 'Tlf:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
darvark authored Jul 19, 2023
2 parents d10b061 + e7cb6d0 commit 7a11229
Show file tree
Hide file tree
Showing 7 changed files with 184 additions and 60 deletions.
80 changes: 50 additions & 30 deletions src/bandmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,13 @@ GPtrArray *spots;


bm_config_t bm_config = {
1, /* show all bands */
1, /* show all mode */
1, /* show dupes */
1, /* skip dupes during grab */
900,/* default lifetime */
0 /* DO NOT show ONLY multipliers */
.allband = true, /* show all bands */
.allmode = true, /* show all mode */
.showdupes = true, /* show dupes */
.skipdupes = true, /* skip dupes during grab */
.lifetime = 900, /* default lifetime */
.onlymults = false, /* DO NOT show ONLY multipliers */
.show_out_of_band = false, /* do not show out-of-band spots */
};

static bool bm_initialized = false;
Expand Down Expand Up @@ -110,10 +111,10 @@ void bmdata_write_file() {
fprintf(fp, "%d\n", (int)tv.tv_sec);
while (found != NULL) {
sp = found->data;
fprintf(fp, "%s;%d;%d;%d;%c;%u;%d;%d;%d;%s\n",
fprintf(fp, "%s;%d;%d;%d;%c;%u;%d;%d;%d;%s;%d\n",
sp->call, sp->freq, sp->mode, sp->bandindex,
sp->node, sp->timeout, sp->dupe, sp->cqzone,
sp->ctynr, g_strchomp(sp->pfx));
sp->ctynr, g_strchomp(sp->pfx), sp->mult);
found = found->next;
}

Expand Down Expand Up @@ -156,20 +157,25 @@ void bmdata_read_file() {
break;
case 2: sscanf(token, "%hhd", &entry->mode);
break;
case 3: sscanf(token, "%hd", &entry->bandindex);
case 3: // re-evaluate band index
entry->bandindex = freq2bandindex(entry->freq);
break;
case 4: sscanf(token, "%c", &entry->node);
break;
case 5: sscanf(token, "%u", &entry->timeout);
break;
case 6: sscanf(token, "%hhd", &entry->dupe);
case 6: // dupe is transient, not read back
entry->dupe = false;
break;
case 7: sscanf(token, "%d", &entry->cqzone);
break;
case 8: sscanf(token, "%d", &entry->ctynr);
break;
case 9: entry->pfx = g_strdup(token);
break;
case 10: // mult is transient, not read back
entry->mult = false;
break;
}
fc++;
token = strtok(NULL, ";");
Expand Down Expand Up @@ -306,9 +312,6 @@ void bandmap_addspot(char *call, freq_t freq, char node) {
return;

bandindex = freq2bandindex(freq);
if (bandindex == BANDINDEX_OOB) /* no ham band */
return;

mode = freq2mode(freq, bandindex);

/* acquire bandmap mutex */
Expand Down Expand Up @@ -351,6 +354,7 @@ void bandmap_addspot(char *call, freq_t freq, char node) {
entry -> node = node;
entry -> timeout = SPOT_NEW;
entry -> dupe = 0; /* Dupe will be determined later. */
entry -> mult = false; /* Mult will be determined later. */

lastexch = NULL;
dxccindex = getctynr(entry->call);
Expand Down Expand Up @@ -585,6 +589,17 @@ char *format_spot(spot *data) {
return temp;
}

static char get_spot_marker(spot *data) {
if (data->bandindex == BANDINDEX_OOB) {
return 'X';
}
if (data->mult) {
return 'M';
}

return ' ';
}


/* helper function for bandmap display
* shows formatted spot on actual cursor position
Expand All @@ -594,12 +609,13 @@ void show_spot(spot *data) {
printw("%7.1f%c", (data->freq / 1000.),
(data->node == thisnode ? '*' : data->node));

if (bm_ismulti(data)) {
char marker = get_spot_marker(data);
if (marker != ' ') {
attrset(COLOR_PAIR(CB_NORMAL));
printw("M");
}
addch(marker);
if (marker != ' ') {
attrset(COLOR_PAIR(CB_DUPE) | A_BOLD);
} else {
printw(" ");
}

char *temp = format_spot(data);
Expand All @@ -616,7 +632,7 @@ void show_spot_on_qrg(spot *data) {

printw("%7.1f%c%c ", (data->freq / 1000.),
(data->node == thisnode ? '*' : data->node),
bm_ismulti(data) ? 'M' : ' ');
get_spot_marker(data));

char *temp = format_spot(data);
printw("%-12s", temp);
Expand Down Expand Up @@ -675,7 +691,6 @@ static bool mode_matches(spot *data) {
void filter_spots() {
GList *list;
spot *data;
bool dupe, multi;
/* acquire mutex
* do not add new spots to allspots during
* - aging and
Expand All @@ -687,30 +702,34 @@ void filter_spots() {

if (spots)
g_ptr_array_free(spots, TRUE); /* free spot array */
/* allocate new one */
/* allocate new one */
spots = g_ptr_array_new_full(128, (GDestroyNotify)free_spot);


for (list = allspots; list; list = list->next) {
data = list->data;

/* check and mark spot as dupe */
dupe = bm_isdupe(data->call, data->bandindex);
data -> dupe = dupe;
data->dupe = bm_isdupe(data->call, data->bandindex);

/* ignore spots on WARC bands if in contest mode */
if (iscontest && IsWarcIndex(data->bandindex))
continue;

/* ignore dupes if not forced */
if (dupe && !bm_config.showdupes)
if (data->dupe && !bm_config.showdupes)
continue;

/* Ignore non-multis if we want to show only multis */
multi = bm_ismulti(data);
if (!multi && bm_config.onlymults)
data->mult = bm_ismulti(data);
if (!data->mult && bm_config.onlymults)
continue;

/* ignore out-of-band spots if configured so */
if (data->bandindex == BANDINDEX_OOB && !bm_config.show_out_of_band) {
continue;
}

/* if spot is allband or allmode is set or band or mode matches
* than add to the filtered 'spot' array
*/
Expand Down Expand Up @@ -903,19 +922,19 @@ void bm_menu() {
c = toupper(key_get());
switch (c) {
case 'B':
bm_config.allband = 1 - bm_config.allband;
bm_config.allband = !bm_config.allband;
break;

case 'M':
bm_config.allmode = 1 - bm_config.allmode;
bm_config.allmode = !bm_config.allmode;
break;

case 'D':
bm_config.showdupes = 1 - bm_config.showdupes;
bm_config.showdupes = !bm_config.showdupes;
break;

case 'O':
bm_config.onlymults = 1 - bm_config.onlymults;
bm_config.onlymults = !bm_config.onlymults;
break;
}
bandmap_show(); /* refresh display */
Expand All @@ -939,6 +958,7 @@ spot *copy_spot(spot *data) {
result -> node = data -> node;
result -> timeout = data -> timeout;
result -> dupe = data -> dupe;
result -> mult = data -> mult;
result -> cqzone = data -> cqzone;
result -> ctynr = data -> ctynr;
result -> pfx = g_strdup(data -> pfx);
Expand Down Expand Up @@ -1087,7 +1107,7 @@ void get_spot_on_qrg(char *dest, freq_t freq) {
data = g_ptr_array_index(spots, i);

if ((fabs(data->freq - freq) < TOLERANCE) &&
(!bm_config.skipdupes || data->dupe == 0)) {
(!bm_config.skipdupes || !data->dupe)) {
strcpy(dest, data->call);
break;
}
Expand Down
14 changes: 8 additions & 6 deletions src/bandmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ typedef struct {
short bandindex;
char node;
unsigned int timeout;/* time (in seconds) left in bandmap */
char dupe; /* only used internal in bm_show() */
bool dupe; /* only used internally in bm_show() */
bool mult; /* only used internally in bm_show() */
int cqzone; /* CQ zone */
int ctynr; /* Country nr */
char *pfx; /* prefix */
Expand All @@ -42,12 +43,13 @@ typedef struct {
#define SPOT_OLD (SPOT_NEW * 2) / 3

typedef struct {
short allband;
short allmode;
short showdupes;
short skipdupes;
bool allband;
bool allmode;
bool showdupes;
bool skipdupes;
short lifetime;
short onlymults;
bool onlymults;
bool show_out_of_band;
} bm_config_t;

extern bm_config_t bm_config;
Expand Down
6 changes: 3 additions & 3 deletions src/bands.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
const static int bandnr[NBANDS] =
{ 160, 80, 60, 40, 30, 20, 17, 15, 12, 10, 0 };

const unsigned int bandcorner[NBANDS][2] = {
unsigned int bandcorner[NBANDS][2] = {
{ 1800000, 2000000 }, // band bottom, band top
{ 3500000, 4000000 },
{ 5250000, 5450000 }, // 5351500-5356500 worldwide
Expand All @@ -42,7 +42,7 @@ const unsigned int bandcorner[NBANDS][2] = {
{ 0, 0 }
};

const unsigned int cwcorner[NBANDS] = {
unsigned int cwcorner[NBANDS] = {
1838000,
3580000,
5354000,
Expand All @@ -56,7 +56,7 @@ const unsigned int cwcorner[NBANDS] = {
0
};

const unsigned int ssbcorner[NBANDS] = {
unsigned int ssbcorner[NBANDS] = {
1840000,
3600000,
5354000,
Expand Down
6 changes: 3 additions & 3 deletions src/bands.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
#define BAND_DOWN -1

extern int inxes[NBANDS]; /**< conversion from BANDINDEX to BAND-mask */
extern const unsigned int bandcorner[NBANDS][2];
extern const unsigned int cwcorner[NBANDS];
extern const unsigned int ssbcorner[NBANDS];
extern unsigned int bandcorner[NBANDS][2];
extern unsigned int cwcorner[NBANDS];
extern unsigned int ssbcorner[NBANDS];

/** \brief converts bandnumber to bandindex
*
Expand Down
Loading

0 comments on commit 7a11229

Please sign in to comment.