Skip to content
This repository has been archived by the owner on Aug 1, 2020. It is now read-only.
/ readsb Public archive

Commit

Permalink
Merge pull request #26 from wiedehopf/bup-client
Browse files Browse the repository at this point in the history
Various improvements.
  • Loading branch information
Mictronics committed Dec 7, 2019
2 parents 2513670 + 7d0567d commit c2311dd
Show file tree
Hide file tree
Showing 9 changed files with 565 additions and 503 deletions.
124 changes: 63 additions & 61 deletions interactive.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ void interactiveCleanup(void) {
}

void interactiveShowData(void) {
struct aircraft *a = Modes.aircrafts;
static uint64_t next_update;
uint64_t now = mstime();
char progress;
Expand All @@ -115,69 +114,72 @@ void interactiveShowData(void) {
int rows = getmaxy(stdscr);
int row = 2;

while (a && row < rows) {

if ((now - a->seen) < Modes.interactive_display_ttl) {
int msgs = a->messages;

if (msgs > 1) {
char strSquawk[5] = " ";
char strFl[7] = " ";
char strTt[5] = " ";
char strGs[5] = " ";

if (trackDataValid(&a->squawk_valid)) {
snprintf(strSquawk, 5, "%04x", a->squawk);
}

if (trackDataValid(&a->gs_valid)) {
snprintf(strGs, 5, "%3d", convert_speed(a->gs));
}

if (trackDataValid(&a->track_valid)) {
snprintf(strTt, 5, "%03.0f", a->track);
}

if (msgs > 99999) {
msgs = 99999;
for (int j = 0; j < AIRCRAFTS_BUCKETS; j++) {
struct aircraft *a = Modes.aircrafts[j];
while (a && row < rows) {

if ((now - a->seen) < Modes.interactive_display_ttl) {
int msgs = a->messages;

if (msgs > 1) {
char strSquawk[5] = " ";
char strFl[7] = " ";
char strTt[5] = " ";
char strGs[5] = " ";

if (trackDataValid(&a->squawk_valid)) {
snprintf(strSquawk, 5, "%04x", a->squawk);
}

if (trackDataValid(&a->gs_valid)) {
snprintf(strGs, 5, "%3d", convert_speed(a->gs));
}

if (trackDataValid(&a->track_valid)) {
snprintf(strTt, 5, "%03.0f", a->track);
}

if (msgs > 99999) {
msgs = 99999;
}

char strMode[5] = " ";
char strLat[8] = " ";
char strLon[9] = " ";
double * pSig = a->signalLevel;
double signalAverage = (pSig[0] + pSig[1] + pSig[2] + pSig[3] +
pSig[4] + pSig[5] + pSig[6] + pSig[7]) / 8.0;

strMode[0] = 'S';
if (a->modeA_hit) {
strMode[2] = 'a';
}
if (a->modeC_hit) {
strMode[3] = 'c';
}

if (trackDataValid(&a->position_valid)) {
snprintf(strLat, 8, "%7.03f", a->lat);
snprintf(strLon, 9, "%8.03f", a->lon);
}

if (trackDataValid(&a->airground_valid) && a->airground == AG_GROUND) {
snprintf(strFl, 7, " grnd");
} else if (Modes.use_gnss && trackDataValid(&a->altitude_geom_valid)) {
snprintf(strFl, 7, "%5dH", convert_altitude(a->altitude_geom));
} else if (trackDataValid(&a->altitude_baro_valid)) {
snprintf(strFl, 7, "%5d ", convert_altitude(a->altitude_baro));
}

mvprintw(row, 0, "%s%06X %-4s %-4s %-8s %6s %3s %3s %7s %8s %5.1f %5d %2.0f",
(a->addr & MODES_NON_ICAO_ADDRESS) ? "~" : " ", (a->addr & 0xffffff),
strMode, strSquawk, a->callsign, strFl, strGs, strTt,
strLat, strLon, 10 * log10(signalAverage), msgs, (now - a->seen) / 1000.0);
++row;
}

char strMode[5] = " ";
char strLat[8] = " ";
char strLon[9] = " ";
double * pSig = a->signalLevel;
double signalAverage = (pSig[0] + pSig[1] + pSig[2] + pSig[3] +
pSig[4] + pSig[5] + pSig[6] + pSig[7]) / 8.0;

strMode[0] = 'S';
if (a->modeA_hit) {
strMode[2] = 'a';
}
if (a->modeC_hit) {
strMode[3] = 'c';
}

if (trackDataValid(&a->position_valid)) {
snprintf(strLat, 8, "%7.03f", a->lat);
snprintf(strLon, 9, "%8.03f", a->lon);
}

if (trackDataValid(&a->airground_valid) && a->airground == AG_GROUND) {
snprintf(strFl, 7, " grnd");
} else if (Modes.use_gnss && trackDataValid(&a->altitude_geom_valid)) {
snprintf(strFl, 7, "%5dH", convert_altitude(a->altitude_geom));
} else if (trackDataValid(&a->altitude_baro_valid)) {
snprintf(strFl, 7, "%5d ", convert_altitude(a->altitude_baro));
}

mvprintw(row, 0, "%s%06X %-4s %-4s %-8s %6s %3s %3s %7s %8s %5.1f %5d %2.0f",
(a->addr & MODES_NON_ICAO_ADDRESS) ? "~" : " ", (a->addr & 0xffffff),
strMode, strSquawk, a->callsign, strFl, strGs, strTt,
strLat, strLon, 10 * log10(signalAverage), msgs, (now - a->seen) / 1000.0);
++row;
}
a = a->next;
}
a = a->next;
}

if (Modes.mode_ac) {
Expand Down

0 comments on commit c2311dd

Please sign in to comment.