cleaning out old logdist and show list options

Former-commit-id: 589204f731d1c82a7873fd2cb527e0caf89a023a
Former-commit-id: f0e62e9917e8193e92d2c1217fc58c47d7f900ce
This commit is contained in:
nathan 2020-03-01 22:58:10 -08:00
parent 6916ee2a4c
commit c338cb7340
8 changed files with 9 additions and 308 deletions

View file

@ -19,8 +19,8 @@ all: view1090
%.o: %.c
$(CC) $(CFLAGS) $(EXTRACFLAGS) -c $<
view1090: view1090.o anet.o interactive.o mode_ac.o mode_s.o net_io.o planeObj.o input.o draw.o font.o init.o mapdata.o status.o list.o parula.o monokai.o
$(CC) -g -o view1090 view1090.o anet.o interactive.o mode_ac.o mode_s.o net_io.o planeObj.o input.o draw.o font.o init.o mapdata.o status.o list.o parula.o monokai.o $(LIBS) $(LDFLAGS)
view1090: view1090.o anet.o interactive.o mode_ac.o mode_s.o net_io.o planeObj.o input.o draw.o font.o init.o mapdata.o status.o parula.o monokai.o
$(CC) -g -o view1090 view1090.o anet.o interactive.o mode_ac.o mode_s.o net_io.o planeObj.o input.o draw.o font.o init.o mapdata.o status.o parula.o monokai.o $(LIBS) $(LDFLAGS)
clean:
rm -f *.o view1090

20
draw.c
View file

@ -128,15 +128,9 @@ SDL_Color hsv2SDLColor(float h, float s, float v)
}
int screenDist(float d) {
float scale_factor = (appData.screen_width > appData.screen_height) ? appData.screen_width : appData.screen_height;
if(appData.mapLogDist) {
return round(0.95 * scale_factor * 0.5 * log(1.0+fabs(d)) / log(1.0+appData.maxDist));
} else {
return round(0.95 * scale_factor * 0.5 * fabs(d) / appData.maxDist);
}
}
void pxFromLonLat(float *dx, float *dy, float lon, float lat) {
if(!lon || !lat) {
@ -385,7 +379,7 @@ void drawScaleBars()
int scalePower = 0;
int scaleBarDist = screenDist((float)pow(10,scalePower));
char scaleLabel[8] = "";
char scaleLabel[13] = "";
// thickLineRGBA(appData.renderer,10,10,10,10*appData.screen_uiscale,2,pink.r, pink.g, pink.b, 255);
lineRGBA(appData.renderer,10,10,10,10*appData.screen_uiscale,pink.r, pink.g, pink.b, 255);
@ -395,9 +389,9 @@ void drawScaleBars()
lineRGBA(appData.renderer,10+scaleBarDist,8,10+scaleBarDist,16*appData.screen_uiscale,pink.r, pink.g, pink.b, 255);
if (Modes.metric) {
snprintf(scaleLabel,8,"%dkm", (int)pow(10,scalePower));
snprintf(scaleLabel,13,"%dkm", (int)pow(10,scalePower));
} else {
snprintf(scaleLabel,8,"%dmi", (int)pow(10,scalePower));
snprintf(scaleLabel,13,"%dmi", (int)pow(10,scalePower));
}
drawString(scaleLabel, 10+scaleBarDist, 15*appData.screen_uiscale, appData.mapFont, pink);
@ -1102,12 +1096,8 @@ void draw() {
drawPlanes();
drawStatus();
if(appData.showList) {
drawList(0);
}
char fps[10] = " ";
snprintf(fps,10," %ffps", 1000.0 / (mstime() - appData.lastFrameTime));
char fps[13] = " ";
snprintf(fps,13," %ffps", 1000.0 / (mstime() - appData.lastFrameTime));
drawStringBG(fps, 0,0, appData.mapFont, grey, black);

View file

@ -30,14 +30,6 @@ void getInput()
exit(0);
break;
case SDLK_l:
appData.mapLogDist = !appData.mapLogDist;
break;
case SDLK_m:
appData.showList = !appData.showList;
break;
default:
break;
}

View file

@ -438,127 +438,7 @@ struct aircraft *interactiveReceiveData(struct modesMessage *mm) {
return (a);
}
//
//=========================================================================
//
// Show the currently captured interactive data on screen.
//
void interactiveShowData(void) {
struct aircraft *a = Modes.aircrafts;
time_t now = time(NULL);
int count = 0;
char progress;
char spinner[4] = "|/-\\";
// Refresh screen every (MODES_INTERACTIVE_REFRESH_TIME) miliseconde
if ((mstime() - Modes.interactive_last_update) < MODES_INTERACTIVE_REFRESH_TIME)
{return;}
Modes.interactive_last_update = mstime();
// Attempt to reconsile any ModeA/C with known Mode-S
// We can't condition on Modes.modeac because ModeA/C could be comming
// in from a raw input port which we can't turn off.
interactiveUpdateAircraftModeS();
progress = spinner[time(NULL)%4];
#ifndef _WIN32
printf("\x1b[H\x1b[2J"); // Clear the screen
#else
cls();
#endif
if (Modes.interactive_rtl1090 == 0) {
printf (
"Hex Mode Sqwk Flight Alt Spd Hdg Lat Long Sig Msgs Ti%c\n", progress);
} else {
printf (
"Hex Flight Alt V/S GS TT SSR G*456^ Msgs Seen %c\n", progress);
}
printf(
"-------------------------------------------------------------------------------\n");
while(a && (count < Modes.interactive_rows)) {
if ((now - a->seen) < Modes.interactive_display_ttl)
{
int msgs = a->messages;
int flags = a->modeACflags;
if ( (((flags & (MODEAC_MSG_FLAG )) == 0 ) )
|| (((flags & (MODEAC_MSG_MODES_HIT | MODEAC_MSG_MODEA_ONLY)) == MODEAC_MSG_MODEA_ONLY) && (msgs > 4 ) )
|| (((flags & (MODEAC_MSG_MODES_HIT | MODEAC_MSG_MODEC_OLD )) == 0 ) && (msgs > 127) )
) {
int altitude = a->altitude, speed = a->speed;
char strSquawk[5] = " ";
char strFl[6] = " ";
char strTt[5] = " ";
char strGs[5] = " ";
// Convert units to metric if --metric was specified
if (Modes.metric) {
altitude = (int) (altitude / 3.2828);
speed = (int) (speed * 1.852);
}
if (a->bFlags & MODES_ACFLAGS_SQUAWK_VALID) {
snprintf(strSquawk,5,"%04x", a->modeA);}
if (a->bFlags & MODES_ACFLAGS_SPEED_VALID) {
snprintf (strGs, 5,"%3d", speed);}
if (a->bFlags & MODES_ACFLAGS_HEADING_VALID) {
snprintf (strTt, 5,"%03d", a->track);}
if (msgs > 99999) {
msgs = 99999;}
if (Modes.interactive_rtl1090) { // RTL1090 display mode
if (a->bFlags & MODES_ACFLAGS_ALTITUDE_VALID) {
snprintf(strFl,6,"F%03d",(altitude/100));
}
printf("%06x %-8s %-4s %-3s %-3s %4s %-6d %-2d\n",
a->addr, a->flight, strFl, strGs, strTt, strSquawk, msgs, (int)(now - a->seen));
} else { // Dump1090 display mode
char strMode[5] = " ";
char strLat[8] = " ";
char strLon[9] = " ";
unsigned char * pSig = a->signalLevel;
unsigned int signalAverage = (pSig[0] + pSig[1] + pSig[2] + pSig[3] +
pSig[4] + pSig[5] + pSig[6] + pSig[7] + 3) >> 3;
if ((flags & MODEAC_MSG_FLAG) == 0) {
strMode[0] = 'S';
} else if (flags & MODEAC_MSG_MODEA_ONLY) {
strMode[0] = 'A';
}
if (flags & MODEAC_MSG_MODEA_HIT) {strMode[2] = 'a';}
if (flags & MODEAC_MSG_MODEC_HIT) {strMode[3] = 'c';}
if (a->bFlags & MODES_ACFLAGS_LATLON_VALID) {
snprintf(strLat, 8,"%7.03f", a->lat);
snprintf(strLon, 9,"%8.03f", a->lon);
}
if (a->bFlags & MODES_ACFLAGS_AOG) {
snprintf(strFl, 6," grnd");
} else if (a->bFlags & MODES_ACFLAGS_ALTITUDE_VALID) {
snprintf(strFl, 6, "%5d", altitude);
}
printf("%06X %-4s %-4s %-8s %5s %3s %3s %7s %8s %3d %5d %2d\n",
a->addr, strMode, strSquawk, a->flight, strFl, strGs, strTt,
strLat, strLon, signalAverage, msgs, (int)(now - a->seen));
}
count++;
}
}
a = a->next;
}
}
//
//=========================================================================
//

157
list.c
View file

@ -1,157 +0,0 @@
#include "dump1090.h"
#include "structs.h"
#include "parula.h"
#include "monokai.h"
#include "SDL2/SDL2_gfxPrimitives.h"
void drawList(int top) {
struct aircraft *a = Modes.aircrafts;
time_t now = time(NULL);
int count = 0;
char progress;
char spinner[4] = "|/-\\";
progress = spinner[time(NULL)%4];
drawStringBG(" Flight Alt(m) km/h D(km) H S ", 0, top, appData.mapBoldFont, black, (SDL_Color){255,255,255,64});
top = top + appData.mapFontHeight;
int numNoDir = 0;
while(a) {
if(top > appData.screen_height) {
return;
}
if ((now - a->seen) < Modes.interactive_display_ttl)
{
int msgs = a->messages;
int flags = a->modeACflags;
if ( (((flags & (MODEAC_MSG_FLAG )) == 0 ) )
|| (((flags & (MODEAC_MSG_MODES_HIT | MODEAC_MSG_MODEA_ONLY)) == MODEAC_MSG_MODEA_ONLY) && (msgs > 4 ) )
|| (((flags & (MODEAC_MSG_MODES_HIT | MODEAC_MSG_MODEC_OLD )) == 0 ) && (msgs > 127) )
) {
int altitude = a->altitude, speed = a->speed;
char strSquawk[5] = " ";
char strFl[6] = " ";
char strTt[5] = " ";
char strGs[5] = " ";
// Convert units to metric if --metric was specified
//if (Modes.metric) {
altitude = (int) (altitude / 3.2828);
speed = (int) (speed * 1.852);
//}
if (a->bFlags & MODES_ACFLAGS_SQUAWK_VALID) {
snprintf(strSquawk,5,"%04x", a->modeA);}
if (a->bFlags & MODES_ACFLAGS_SPEED_VALID) {
snprintf (strGs, 5,"%3d", speed);}
if (a->bFlags & MODES_ACFLAGS_HEADING_VALID) {
snprintf (strTt, 5,"%03d", a->track);}
if (msgs > 99999) {
msgs = 99999;}
// Dump1090 display mode
char strMode[5] = " ";
// char strLat[8] = " ";
// char strLon[9] = " ";
char strD[5] = " ";
char strDir[3] = " ";
char cLat = ' ';
char cLon = ' ';
char strS[3] = " ";
double d;
unsigned char * pSig = a->signalLevel;
unsigned int signalAverage = (pSig[0] + pSig[1] + pSig[2] + pSig[3] +
pSig[4] + pSig[5] + pSig[6] + pSig[7] + 3) >> 3;
if (a->bFlags & MODES_ACFLAGS_AOG) {
snprintf(strFl, 6," grnd");
} else if (a->bFlags & MODES_ACFLAGS_ALTITUDE_VALID) {
snprintf(strFl, 6, "%5d", altitude);
}
if ((flags & MODEAC_MSG_FLAG) == 0) {
strMode[0] = 'S';
} else if (flags & MODEAC_MSG_MODEA_ONLY) {
strMode[0] = 'A';
}
if (flags & MODEAC_MSG_MODEA_HIT) {strMode[2] = 'a';}
if (flags & MODEAC_MSG_MODEC_HIT) {strMode[3] = 'c';}
snprintf(strS, 3,"%3d", (int)((float)signalAverage/25.0f));
if (a->bFlags & MODES_ACFLAGS_LATLON_VALID) {
if(fabs(a->lon) < .01 && fabs(a->lat) > fabs(a->lon)) {
cLon = ' ';
} else {
if(a->lon < 0) {
cLon = 'W';
} else {
cLon = 'E';
}
}
if(fabs(a->lat) < .01 && fabs(a->lon) > fabs(a->lat)) {
cLat = ' ';
} else {
if(a->lat < 0) {
cLat = 'S';
} else {
cLat = 'N';
}
}
//snprintf(strDir,3,"%c%c",cLat,cLon);
//distance is borked during refactor
//d = sqrt(a->dx * a->dx + a->dy * a->dy);
//snprintf(strD, 5,"%4.01f", d);
if ((now - a->seen) > 30 ) {
drawString(a->flight, 0, top, appData.listFont, (SDL_Color){96,96,96,255});
} else {
drawString(a->flight, 10, top, appData.listFont, pink);
drawString(strFl, 90, top, appData.listFont, orange);
drawString(strGs, 160, top, appData.listFont, green);
drawString(strD, 210, top, appData.listFont, blue);
drawString(strDir, 270, top, appData.listFont, yellow);
// drawString(strS, 290, (count + 1) * 20, appData.listFont, (SDL_Color){255,9,96,255});
// printf("\x1B[1;31m%-8s\x1B[1;32m%5s \x1B[1;33m%4s \x1B[1;34m%5s \x1B[1;36m%c%c \x1B[1;35m%d",
// a->flight,
// strFl,
// strGs,
// strD,
// cLat, cLon,
// (int)((float)signalAverage/25.0f));
}
top = top + appData.mapFontHeight;
count++;
} else {
numNoDir++;
}
}
}
a = a->next;
}
}

View file

@ -24,8 +24,6 @@ typedef struct AppData
int messageFontHeight;
// map options
int showList;
int mapLogDist;
float maxDist;
//display options

View file

@ -1 +1 @@
26bcc33e9a70c2cecf2a74f5154818e228a3b303
6bd186af163808be339e2a911a4fbbd324e89f28

View file

@ -64,8 +64,6 @@ void view1090InitConfig(void) {
Modes.quiet = 1;
// Map options
appData.showList = 0;
appData.mapLogDist = 0;
appData.maxDist = 25.0;
appData.centerLon = Modes.fUserLon;
appData.centerLat = Modes.fUserLat;