diff --git a/TODO.md b/TODO.md index 77c2b56..8f47ae3 100644 --- a/TODO.md +++ b/TODO.md @@ -16,7 +16,7 @@ battery level (need separate linux/win/android) Utility stuff -zipped map load (and write from python) --> start by reducing lat/lon precision to 4 or 5 decimal places and change storage to float instead of double + +map load (and write from python) --> start by reducing lat/lon precision to 4 or 5 decimal places and change storage to float instead of double libconfig load settings Platforms diff --git a/font.c b/font.c index a196cd9..c604847 100755 --- a/font.c +++ b/font.c @@ -3,7 +3,6 @@ TTF_Font *loadFont(char *name, int size) { - /* Use SDL_TTF to load the font at the specified size */ TTF_Font *font = TTF_OpenFont(name, size); if (font == NULL) @@ -17,9 +16,7 @@ TTF_Font *loadFont(char *name, int size) } void closeFont(TTF_Font *font) -{ - /* Close the font once we're done with it */ - +{ if (font != NULL) { TTF_CloseFont(font); @@ -44,8 +41,6 @@ void drawString(char * text, int x, int y, TTF_Font *font, SDL_Color color) return; } - /* Blit the entire surface to the screen */ - dest.x = x; dest.y = y; dest.w = surface->w; diff --git a/init.c b/init.c index 6d5f0a5..90c7fd3 100644 --- a/init.c +++ b/init.c @@ -36,7 +36,7 @@ void init(char *title) { } appData.window = SDL_CreateWindow(title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, appData.screen_width, appData.screen_height, flags); - appData.renderer = SDL_CreateRenderer(appData.window, -1, 0); + appData.renderer = SDL_CreateRenderer(appData.window, -1, SDL_RENDERER_ACCELERATED); appData.mapTexture = SDL_CreateTexture(appData.renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_TARGET, diff --git a/mapdata.h b/mapdata.h index d349a79..5d384ca 100644 --- a/mapdata.h +++ b/mapdata.h @@ -4,8 +4,6 @@ float *mapPoints_relative; int mapPoints_count; -//extern float mapPoints[]; - float *mapPoints; typedef struct Point{ diff --git a/status.c b/status.c index cfd8a15..1d52d81 100644 --- a/status.c +++ b/status.c @@ -64,21 +64,8 @@ void updateStatus() { sigAccumulate += signalAverage; if (p->lon && p->lat) { - - - //distance measurements got borked during refactor - need to redo here - /* - double d = sqrt(p->dx * a->dx + a->dy * a->dy); - - if(d < appData.maxDist) { - if(d > maxDist) { - maxDist = d; - } - */ numVisiblePlanes++; - //} - } - + } totalCount++; @@ -95,22 +82,10 @@ void updateStatus() { } void drawStatusBox(int *left, int *top, char *label, char *message, SDL_Color color) { - //int labelWidth = ((strlen(label) > 0 ) ? 1.5 : 0) * appData.labelFont; int labelWidth = (strlen(label) + ((strlen(label) > 0 ) ? 1 : 0)) * appData.labelFontWidth; int messageWidth = (strlen(message) + ((strlen(message) > 0 ) ? 1 : 0)) * appData.messageFontWidth; - //newline if no message or label - // if(strlen(label) == 0 && strlen(message) == 0 ) { - // boxRGBA(appData.renderer, *left, *top, appData.screen_width - PAD, *top + appData.messageFontHeight,0, 0, 0, 0); - // *left = PAD; - // *top = *top - appData.messageFontHeight - PAD; - // return; - // } - if(*left + labelWidth + messageWidth + PAD > appData.screen_width) { - // if(*left + PAD < appData.screen_width) { - // boxRGBA(appData.screen, *left, *top, appData.screen_width - PAD, *top + appData.messageFontHeight, darkGrey.r, darkGrey.g, darkGrey.b, SDL_ALPHA_OPAQUE); - // } *left = PAD; *top = *top - appData.messageFontHeight - PAD; } @@ -130,9 +105,6 @@ void drawStatusBox(int *left, int *top, char *label, char *message, SDL_Color co roundedRectangleRGBA(appData.renderer, *left, *top, *left + labelWidth + messageWidth, *top + appData.messageFontHeight, ROUND_RADIUS,color.r, color.g, color.b, SDL_ALPHA_OPAQUE); } - // label - //drawString90(label, *left, *top + appData.labelFontWidth/2, appData.labelFont, black); - drawString(label, *left + appData.labelFontWidth/2, *top, appData.labelFont, black); //message @@ -205,18 +177,10 @@ void drawStatus() { snprintf(strLoc, 20, "%3.3fN %3.3f%c", appData.centerLat, fabs(appData.centerLon),(appData.centerLon > 0) ? 'E' : 'W'); drawStatusBox(&left, &top, "loc", strLoc, pink); - // drawBattery(&left, &top, 0.85); - char strPlaneCount[10] = " "; snprintf(strPlaneCount, 10,"%d/%d", Status.numVisiblePlanes, Status.numPlanes); drawStatusBox(&left, &top, "disp", strPlaneCount, yellow); - //distance measurements got borked during refactor - need to redo here - - // char strDMax[5] = " "; - // snprintf(strDMax, 5, "%.0fkm", Status.maxDist); - // drawStatusBox(&left, &top, "mDst", strDMax, blue); - char strMsgRate[18] = " "; snprintf(strMsgRate, 18,"%.0f/s", Status.msgRate); drawStatusBox(&left, &top, "rate", strMsgRate, orange); @@ -224,15 +188,4 @@ void drawStatus() { char strSig[18] = " "; snprintf(strSig, 18, "%.0f%%", 100.0 * Status.avgSig / 1024.0); drawStatusBox(&left, &top, "sAvg", strSig, green); - - //drawStatusBox(&left, &top, "x", "exit", grey); - - // if(Status.closeCall != NULL) { - // drawStatusBox(&left, &top, "", "", black); //this is effectively a newline - // if(strlen(Status.closeCall->flight)) { - // drawStatusBox(&left, &top, "near", Status.closeCall->flight, white); - // } else { - // drawStatusBox(&left, &top, "near", "", white); - // } - // } } diff --git a/structs.h b/structs.h index 0147f46..7e4b0d9 100644 --- a/structs.h +++ b/structs.h @@ -74,7 +74,7 @@ struct planeObj { uint64_t created; uint64_t msSeen; uint64_t msSeenLatLon; - int live; + int live; struct planeObj *next; // Next aircraft in our linked list diff --git a/view1090.REMOVED.git-id b/view1090.REMOVED.git-id index d9664a5..4d508f9 100644 --- a/view1090.REMOVED.git-id +++ b/view1090.REMOVED.git-id @@ -1 +1 @@ -6bd186af163808be339e2a911a4fbbd324e89f28 \ No newline at end of file +ade669691e5258a9db857adaedb879bb3c653d1e \ No newline at end of file diff --git a/view1090.c b/view1090.c index 2feb904..806ac66 100644 --- a/view1090.c +++ b/view1090.c @@ -54,9 +54,6 @@ void view1090InitConfig(void) { Modes.check_crc = 1; strcpy(View1090.net_input_beast_ipaddr,VIEW1090_NET_OUTPUT_IP_ADDRESS); Modes.net_input_beast_port = MODES_NET_OUTPUT_BEAST_PORT; - Modes.interactive_rows = MODES_INTERACTIVE_ROWS; - Modes.interactive_delete_ttl = MODES_INTERACTIVE_DELETE_TTL; - Modes.interactive_display_ttl = MODES_INTERACTIVE_DISPLAY_TTL; Modes.fUserLat = MODES_USER_LATITUDE_DFLT; Modes.fUserLon = MODES_USER_LONGITUDE_DFLT; @@ -170,15 +167,15 @@ void showHelp(void) { "-----------------------------------------------------------------------------\n" "| view1090 dump1090 Viewer Ver : "MODES_DUMP1090_VERSION " |\n" "-----------------------------------------------------------------------------\n" - "--server TCP Beast output listen IPv4 (default: 127.0.0.1)\n" - "--net-bo-port TCP Beast output listen port (default: 30005)\n" - "--lat Reference/receiver latitide for surface posn (opt)\n" - "--lon Reference/receiver longitude for surface posn (opt)\n" - "--metric Use metric units (meters, km/h, ...)\n" - "--help Show this help\n" - "--uiscale UI global scaling\n" - "--screensize \n" - "--fullscreen Start fullscreen\n" + "--server TCP Beast output listen IPv4 (default: 127.0.0.1)\n" + "--port TCP Beast output listen port (default: 30005)\n" + "--lat Reference/receiver latitide for surface posn (opt)\n" + "--lon Reference/receiver longitude for surface posn (opt)\n" + "--metric Use metric units (meters, km/h, ...)\n" + "--help Show this help\n" + "--uiscale UI global scaling (default: 1)\n" + "--screensize Set frame buffer resolution (default: screen resolution)\n" + "--fullscreen Start fullscreen\n" ); } @@ -193,6 +190,7 @@ void showCopyright(void) { "\n" " Copyright (C) 2012 by Salvatore Sanfilippo \n" " Copyright (C) 2014 by Malcolm Robb \n" +" Copyright (C) 2020 by Nathan Matsuda \n" "\n" " All rights reserved.\n" "\n" @@ -236,21 +234,12 @@ int main(int argc, char **argv) { if (!strcmp(argv[j],"--net-bo-port") && more) { Modes.net_input_beast_port = atoi(argv[++j]); + } else if (!strcmp(argv[j],"--port") && more) { + Modes.net_input_beast_port = atoi(argv[++j]); } else if (!strcmp(argv[j],"--net-bo-ipaddr") && more) { strcpy(View1090.net_input_beast_ipaddr, argv[++j]); } else if (!strcmp(argv[j],"--server") && more) { strcpy(View1090.net_input_beast_ipaddr, argv[++j]); - } else if (!strcmp(argv[j],"--modeac")) { - Modes.mode_ac = 1; - } else if (!strcmp(argv[j],"--interactive-rows") && more) { - Modes.interactive_rows = atoi(argv[++j]); - } else if (!strcmp(argv[j],"--interactive")) { - Modes.interactive = 1; - } else if (!strcmp(argv[j],"--interactive-ttl") && more) { - Modes.interactive_display_ttl = atoi(argv[++j]); - } else if (!strcmp(argv[j],"--interactive-rtl1090")) { - Modes.interactive = 1; - Modes.interactive_rtl1090 = 1; } else if (!strcmp(argv[j],"--lat") && more) { Modes.fUserLat = atof(argv[++j]); appData.centerLat = Modes.fUserLat; @@ -259,14 +248,6 @@ int main(int argc, char **argv) { appData.centerLon = Modes.fUserLon; } else if (!strcmp(argv[j],"--metric")) { Modes.metric = 1; - } else if (!strcmp(argv[j],"--no-crc-check")) { - Modes.check_crc = 0; - } else if (!strcmp(argv[j],"--fix")) { - Modes.nfix_crc = 1; - } else if (!strcmp(argv[j],"--no-fix")) { - Modes.nfix_crc = 0; - } else if (!strcmp(argv[j],"--aggressive")) { - Modes.nfix_crc = MODES_MAX_BITERRORS; } else if (!strcmp(argv[j],"--fullscreen")) { appData.fullscreen = 1; } else if (!strcmp(argv[j],"--uiscale") && more) { @@ -298,36 +279,10 @@ int main(int argc, char **argv) { } } - /* - // Keep going till the user does something that stops us - while (!Modes.exit) { - interactiveRemoveStaleAircrafts(); - interactiveShowData(); - if ((fd == ANET_ERR) || (recv(c->fd, pk_buf, sizeof(pk_buf), MSG_PEEK | MSG_DONTWAIT) == 0)) { - free(c); - usleep(1000000); - c = (struct client *) malloc(sizeof(*c)); - fd = setupConnection(c); - continue; - } - modesReadFromClient(c,"",decodeBinMessage); - usleep(100000); - } - */ - - int go; - -#ifdef RPI - fprintf(stderr,"RPI\n"); -#endif - - /* Start up SDL */ init("sdl1090"); - /* Call the cleanup function when the program exits */ - atexit(cleanup); go = 1; @@ -337,8 +292,7 @@ int main(int argc, char **argv) { getInput(); interactiveRemoveStaleAircrafts(); - // interactiveShowData(); - + draw(); if ((fd == ANET_ERR) || (recv(c->fd, pk_buf, sizeof(pk_buf), MSG_PEEK | MSG_DONTWAIT) == 0)) {