From aa8e3dca4b527cc228ba8b07a6c6886912343668 Mon Sep 17 00:00:00 2001 From: Nathan Date: Thu, 5 Oct 2017 22:25:30 -0500 Subject: [PATCH] status boxes on map layout Former-commit-id: 0ef788b2ddd092a1d30bdcc6d83bc0e972d5e229 Former-commit-id: 733d714f10f3ea03cf011aa4226c62a7784b2a36 --- sdl1090/Anonymous_Pro.ttf.REMOVED.git-id | 1 - sdl1090/Anonymous_Pro_B.ttf.REMOVED.git-id | 1 - sdl1090/Anonymous_Pro_BI.ttf.REMOVED.git-id | 1 - sdl1090/Anonymous_Pro_I.ttf.REMOVED.git-id | 1 - sdl1090/Arial.ttf.REMOVED.git-id | 1 - sdl1090/ArialBold.ttf.REMOVED.git-id | 1 - sdl1090/Makefile | 4 +- sdl1090/defs.h | 9 +- sdl1090/draw.c | 19 ++- sdl1090/dump1090.h | 11 ++ .../DroidSansMono.ttf.REMOVED.git-id | 0 .../font/Envy Code R Bold.ttf.REMOVED.git-id | 1 + .../Envy Code R Italic.ttf.REMOVED.git-id | 1 + sdl1090/font/Envy Code R.ttf.REMOVED.git-id | 1 + sdl1090/font/Monoid-Bold.ttf.REMOVED.git-id | 1 + sdl1090/font/Monoid-Italic.ttf.REMOVED.git-id | 1 + .../font/Monoid-Regular.ttf.REMOVED.git-id | 1 + sdl1090/font/Monoid-Retina.ttf.REMOVED.git-id | 1 + .../TerminusTTF-4.46.0.ttf.REMOVED.git-id | 0 ...TerminusTTF-Bold-4.46.0.ttf.REMOVED.git-id | 0 sdl1090/font/Ubuntu-B.ttf.REMOVED.git-id | 1 + sdl1090/font/Ubuntu-BI.ttf.REMOVED.git-id | 1 + sdl1090/font/Ubuntu-C.ttf.REMOVED.git-id | 1 + sdl1090/font/Ubuntu-L.ttf.REMOVED.git-id | 1 + sdl1090/font/Ubuntu-LI.ttf.REMOVED.git-id | 1 + sdl1090/font/Ubuntu-M.ttf.REMOVED.git-id | 1 + sdl1090/font/Ubuntu-MI.ttf.REMOVED.git-id | 1 + sdl1090/font/Ubuntu-R.ttf.REMOVED.git-id | 1 + sdl1090/font/Ubuntu-RI.ttf.REMOVED.git-id | 1 + sdl1090/font/UbuntuMono-B.ttf.REMOVED.git-id | 1 + sdl1090/font/UbuntuMono-BI.ttf.REMOVED.git-id | 1 + sdl1090/font/UbuntuMono-R.ttf.REMOVED.git-id | 1 + sdl1090/font/UbuntuMono-RI.ttf.REMOVED.git-id | 1 + sdl1090/{ => font}/unifont.ttf.REMOVED.git-id | 0 sdl1090/init.c | 11 +- sdl1090/interactive.c | 12 +- sdl1090/list.c | 12 +- sdl1090/maps.c | 65 +++----- sdl1090/monokai.c | 14 ++ sdl1090/monokai.h | 14 ++ sdl1090/status.c | 143 ++++++++++++++++++ sdl1090/structs.h | 16 +- sdl1090/view1090.REMOVED.git-id | 2 +- sdl1090/view1090.c | 13 +- sdl1090/view1090.dSYM/Contents/Info.plist | 20 +++ .../Resources/DWARF/view1090.REMOVED.git-id | 1 + 46 files changed, 308 insertions(+), 84 deletions(-) delete mode 100644 sdl1090/Anonymous_Pro.ttf.REMOVED.git-id delete mode 100644 sdl1090/Anonymous_Pro_B.ttf.REMOVED.git-id delete mode 100644 sdl1090/Anonymous_Pro_BI.ttf.REMOVED.git-id delete mode 100644 sdl1090/Anonymous_Pro_I.ttf.REMOVED.git-id delete mode 100644 sdl1090/Arial.ttf.REMOVED.git-id delete mode 100644 sdl1090/ArialBold.ttf.REMOVED.git-id rename sdl1090/{ => font}/DroidSansMono.ttf.REMOVED.git-id (100%) create mode 100644 sdl1090/font/Envy Code R Bold.ttf.REMOVED.git-id create mode 100644 sdl1090/font/Envy Code R Italic.ttf.REMOVED.git-id create mode 100644 sdl1090/font/Envy Code R.ttf.REMOVED.git-id create mode 100644 sdl1090/font/Monoid-Bold.ttf.REMOVED.git-id create mode 100644 sdl1090/font/Monoid-Italic.ttf.REMOVED.git-id create mode 100644 sdl1090/font/Monoid-Regular.ttf.REMOVED.git-id create mode 100644 sdl1090/font/Monoid-Retina.ttf.REMOVED.git-id rename sdl1090/{ => font}/TerminusTTF-4.46.0.ttf.REMOVED.git-id (100%) rename sdl1090/{ => font}/TerminusTTF-Bold-4.46.0.ttf.REMOVED.git-id (100%) create mode 100644 sdl1090/font/Ubuntu-B.ttf.REMOVED.git-id create mode 100644 sdl1090/font/Ubuntu-BI.ttf.REMOVED.git-id create mode 100644 sdl1090/font/Ubuntu-C.ttf.REMOVED.git-id create mode 100644 sdl1090/font/Ubuntu-L.ttf.REMOVED.git-id create mode 100644 sdl1090/font/Ubuntu-LI.ttf.REMOVED.git-id create mode 100644 sdl1090/font/Ubuntu-M.ttf.REMOVED.git-id create mode 100644 sdl1090/font/Ubuntu-MI.ttf.REMOVED.git-id create mode 100644 sdl1090/font/Ubuntu-R.ttf.REMOVED.git-id create mode 100644 sdl1090/font/Ubuntu-RI.ttf.REMOVED.git-id create mode 100644 sdl1090/font/UbuntuMono-B.ttf.REMOVED.git-id create mode 100644 sdl1090/font/UbuntuMono-BI.ttf.REMOVED.git-id create mode 100644 sdl1090/font/UbuntuMono-R.ttf.REMOVED.git-id create mode 100644 sdl1090/font/UbuntuMono-RI.ttf.REMOVED.git-id rename sdl1090/{ => font}/unifont.ttf.REMOVED.git-id (100%) create mode 100644 sdl1090/monokai.c create mode 100644 sdl1090/monokai.h create mode 100644 sdl1090/status.c create mode 100644 sdl1090/view1090.dSYM/Contents/Info.plist create mode 100644 sdl1090/view1090.dSYM/Contents/Resources/DWARF/view1090.REMOVED.git-id diff --git a/sdl1090/Anonymous_Pro.ttf.REMOVED.git-id b/sdl1090/Anonymous_Pro.ttf.REMOVED.git-id deleted file mode 100644 index ae86fa5..0000000 --- a/sdl1090/Anonymous_Pro.ttf.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -06aafc067310fba0d33b0a133654475ac73388ab \ No newline at end of file diff --git a/sdl1090/Anonymous_Pro_B.ttf.REMOVED.git-id b/sdl1090/Anonymous_Pro_B.ttf.REMOVED.git-id deleted file mode 100644 index ca3ac28..0000000 --- a/sdl1090/Anonymous_Pro_B.ttf.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -985bd4002d7a293f50db1ab1d7b90f5a3da066b4 \ No newline at end of file diff --git a/sdl1090/Anonymous_Pro_BI.ttf.REMOVED.git-id b/sdl1090/Anonymous_Pro_BI.ttf.REMOVED.git-id deleted file mode 100644 index 1f9d7fa..0000000 --- a/sdl1090/Anonymous_Pro_BI.ttf.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -838f2d125233f373f3b5cff30ae3fde7f1089514 \ No newline at end of file diff --git a/sdl1090/Anonymous_Pro_I.ttf.REMOVED.git-id b/sdl1090/Anonymous_Pro_I.ttf.REMOVED.git-id deleted file mode 100644 index dfd3b1c..0000000 --- a/sdl1090/Anonymous_Pro_I.ttf.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -43505c164f6a77fc43068440a586c380296f0125 \ No newline at end of file diff --git a/sdl1090/Arial.ttf.REMOVED.git-id b/sdl1090/Arial.ttf.REMOVED.git-id deleted file mode 100644 index 98f1e60..0000000 --- a/sdl1090/Arial.ttf.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -ab68fb197d4479b3b6dec6e85bd5cbaf433a87c5 \ No newline at end of file diff --git a/sdl1090/ArialBold.ttf.REMOVED.git-id b/sdl1090/ArialBold.ttf.REMOVED.git-id deleted file mode 100644 index 9b5c6b4..0000000 --- a/sdl1090/ArialBold.ttf.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -940e255d0140b07a15ea0371695c25c02087f368 \ No newline at end of file diff --git a/sdl1090/Makefile b/sdl1090/Makefile index b67b27a..2fb6528 100644 --- a/sdl1090/Makefile +++ b/sdl1090/Makefile @@ -25,8 +25,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 input.o draw.o font.o init.o maps.o mapdata.o list.o parula.o - $(CC) -g -o view1090 view1090.o anet.o interactive.o mode_ac.o mode_s.o net_io.o input.o draw.o font.o init.o maps.o mapdata.o list.o parula.o $(LIBS) $(LDFLAGS) +view1090: view1090.o anet.o interactive.o mode_ac.o mode_s.o net_io.o input.o draw.o font.o init.o maps.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 input.o draw.o font.o init.o maps.o mapdata.o status.o list.o parula.o monokai.o $(LIBS) $(LDFLAGS) clean: rm -f *.o view1090 diff --git a/sdl1090/defs.h b/sdl1090/defs.h index b552058..19b2070 100644 --- a/sdl1090/defs.h +++ b/sdl1090/defs.h @@ -13,4 +13,11 @@ #define SCREEN_WIDTH 320 #define SCREEN_HEIGHT 480 -#define UPSCALE 3 \ No newline at end of file +#define UPSCALE 3 + +#define LOGMAXDIST 1000.0 +#define MAXDIST 50.0 + +#define AA 0 + +#define MAGMA 0 \ No newline at end of file diff --git a/sdl1090/draw.c b/sdl1090/draw.c index 17439e4..318159d 100644 --- a/sdl1090/draw.c +++ b/sdl1090/draw.c @@ -19,27 +19,32 @@ void draw() { Modes.interactive_last_update = mstime(); + updateStatus(); + SDL_FillRect(game.screen, NULL, 0); if (Modes.map) { drawMap(); - //drawList(3,320); + drawStatus(); } else { drawList(10,0); } if(Modes.screen_upscale > 1) { - SDL_Rect clip; - SDL_Surface *temp = SDL_DisplayFormat(zoomSurface(game.screen, Modes.screen_upscale, Modes.screen_upscale, 0)); - + SDL_Surface *temp = zoomSurface(game.screen, Modes.screen_upscale, Modes.screen_upscale, 0); + SDL_Surface *temp2 = SDL_DisplayFormat(temp); + SDL_Rect clip; clip.x = 0; clip.y = 0; - clip.w = temp->w; - clip.h = temp->h; + clip.w = temp2->w; + clip.h = temp2->h; - SDL_BlitSurface(temp, &clip, game.bigScreen, 0); + SDL_BlitSurface(temp2, 0, game.bigScreen, 0); SDL_Flip(game.bigScreen); + + SDL_FreeSurface(temp); + SDL_FreeSurface(temp2); } else { SDL_Flip(game.screen); } diff --git a/sdl1090/dump1090.h b/sdl1090/dump1090.h index 6323ae4..e57bf73 100644 --- a/sdl1090/dump1090.h +++ b/sdl1090/dump1090.h @@ -209,10 +209,12 @@ struct aircraft { int track; // Angle of flight int vert_rate; // Vertical rate. time_t seen; // Time at which the last packet was received + time_t prev_seen; time_t seenLatLon; // Time at which the last lat long was calculated uint64_t timestamp; // Timestamp at which the last packet was received uint64_t timestampLatLon;// Timestamp at which the last lat long was calculated long messages; // Number of Mode S messages received + double messageRate[8]; // Number of Mode S messages received int modeA; // Squawk int modeC; // Altitude long modeAcount; // Mode A Squawk hit Count @@ -235,6 +237,15 @@ struct aircraft { struct aircraft *next; // Next aircraft in our linked list }; +struct { + double msgRate; + double avgSig; + int numPlanes; + int numVisiblePlanes; + double maxDist; + struct aircraft *closeCall; +} Status; + struct stDF { struct stDF *pNext; // Pointer to next item in the linked list struct stDF *pPrev; // Pointer to previous item in the linked list diff --git a/sdl1090/DroidSansMono.ttf.REMOVED.git-id b/sdl1090/font/DroidSansMono.ttf.REMOVED.git-id similarity index 100% rename from sdl1090/DroidSansMono.ttf.REMOVED.git-id rename to sdl1090/font/DroidSansMono.ttf.REMOVED.git-id diff --git a/sdl1090/font/Envy Code R Bold.ttf.REMOVED.git-id b/sdl1090/font/Envy Code R Bold.ttf.REMOVED.git-id new file mode 100644 index 0000000..aa348d6 --- /dev/null +++ b/sdl1090/font/Envy Code R Bold.ttf.REMOVED.git-id @@ -0,0 +1 @@ +5e04b16605e6f165afada700fa09ec2c744bd4ca \ No newline at end of file diff --git a/sdl1090/font/Envy Code R Italic.ttf.REMOVED.git-id b/sdl1090/font/Envy Code R Italic.ttf.REMOVED.git-id new file mode 100644 index 0000000..080db4a --- /dev/null +++ b/sdl1090/font/Envy Code R Italic.ttf.REMOVED.git-id @@ -0,0 +1 @@ +cf67fe0caf3e7853db2af48cdcd28a4522a15572 \ No newline at end of file diff --git a/sdl1090/font/Envy Code R.ttf.REMOVED.git-id b/sdl1090/font/Envy Code R.ttf.REMOVED.git-id new file mode 100644 index 0000000..5c6e31e --- /dev/null +++ b/sdl1090/font/Envy Code R.ttf.REMOVED.git-id @@ -0,0 +1 @@ +e8e4a6045fa8374ca37fd7f53dfa95c61142ae98 \ No newline at end of file diff --git a/sdl1090/font/Monoid-Bold.ttf.REMOVED.git-id b/sdl1090/font/Monoid-Bold.ttf.REMOVED.git-id new file mode 100644 index 0000000..aac093f --- /dev/null +++ b/sdl1090/font/Monoid-Bold.ttf.REMOVED.git-id @@ -0,0 +1 @@ +730c63d4b5435fc57d6551f5a71d64b7e7d60fbb \ No newline at end of file diff --git a/sdl1090/font/Monoid-Italic.ttf.REMOVED.git-id b/sdl1090/font/Monoid-Italic.ttf.REMOVED.git-id new file mode 100644 index 0000000..3e0aa9e --- /dev/null +++ b/sdl1090/font/Monoid-Italic.ttf.REMOVED.git-id @@ -0,0 +1 @@ +97a5b8f6ed4324088d095d616a147d05cfe8917a \ No newline at end of file diff --git a/sdl1090/font/Monoid-Regular.ttf.REMOVED.git-id b/sdl1090/font/Monoid-Regular.ttf.REMOVED.git-id new file mode 100644 index 0000000..bb7eaee --- /dev/null +++ b/sdl1090/font/Monoid-Regular.ttf.REMOVED.git-id @@ -0,0 +1 @@ +a09e9faff2c39c9dc56f6a0101a300851922e78d \ No newline at end of file diff --git a/sdl1090/font/Monoid-Retina.ttf.REMOVED.git-id b/sdl1090/font/Monoid-Retina.ttf.REMOVED.git-id new file mode 100644 index 0000000..e77b083 --- /dev/null +++ b/sdl1090/font/Monoid-Retina.ttf.REMOVED.git-id @@ -0,0 +1 @@ +ec881731ace782f1f692c4d9afabe1710ef6ac25 \ No newline at end of file diff --git a/sdl1090/TerminusTTF-4.46.0.ttf.REMOVED.git-id b/sdl1090/font/TerminusTTF-4.46.0.ttf.REMOVED.git-id similarity index 100% rename from sdl1090/TerminusTTF-4.46.0.ttf.REMOVED.git-id rename to sdl1090/font/TerminusTTF-4.46.0.ttf.REMOVED.git-id diff --git a/sdl1090/TerminusTTF-Bold-4.46.0.ttf.REMOVED.git-id b/sdl1090/font/TerminusTTF-Bold-4.46.0.ttf.REMOVED.git-id similarity index 100% rename from sdl1090/TerminusTTF-Bold-4.46.0.ttf.REMOVED.git-id rename to sdl1090/font/TerminusTTF-Bold-4.46.0.ttf.REMOVED.git-id diff --git a/sdl1090/font/Ubuntu-B.ttf.REMOVED.git-id b/sdl1090/font/Ubuntu-B.ttf.REMOVED.git-id new file mode 100644 index 0000000..d8c3702 --- /dev/null +++ b/sdl1090/font/Ubuntu-B.ttf.REMOVED.git-id @@ -0,0 +1 @@ +b173da27417c00101dff72617f9b9a2b80ecc8f3 \ No newline at end of file diff --git a/sdl1090/font/Ubuntu-BI.ttf.REMOVED.git-id b/sdl1090/font/Ubuntu-BI.ttf.REMOVED.git-id new file mode 100644 index 0000000..0a52557 --- /dev/null +++ b/sdl1090/font/Ubuntu-BI.ttf.REMOVED.git-id @@ -0,0 +1 @@ +72a5a99ac0c781eb60dd8721ae93eedda298e07e \ No newline at end of file diff --git a/sdl1090/font/Ubuntu-C.ttf.REMOVED.git-id b/sdl1090/font/Ubuntu-C.ttf.REMOVED.git-id new file mode 100644 index 0000000..cf2e7e8 --- /dev/null +++ b/sdl1090/font/Ubuntu-C.ttf.REMOVED.git-id @@ -0,0 +1 @@ +602a3ee4ab20743037eee6daa1b304fa680967b6 \ No newline at end of file diff --git a/sdl1090/font/Ubuntu-L.ttf.REMOVED.git-id b/sdl1090/font/Ubuntu-L.ttf.REMOVED.git-id new file mode 100644 index 0000000..fdcf7fa --- /dev/null +++ b/sdl1090/font/Ubuntu-L.ttf.REMOVED.git-id @@ -0,0 +1 @@ +ed0f5bce879796461ebb93969d28a2bbb35efd0f \ No newline at end of file diff --git a/sdl1090/font/Ubuntu-LI.ttf.REMOVED.git-id b/sdl1090/font/Ubuntu-LI.ttf.REMOVED.git-id new file mode 100644 index 0000000..7c9dda5 --- /dev/null +++ b/sdl1090/font/Ubuntu-LI.ttf.REMOVED.git-id @@ -0,0 +1 @@ +c6cec55fcd5d8e00347661eba8684f848065594e \ No newline at end of file diff --git a/sdl1090/font/Ubuntu-M.ttf.REMOVED.git-id b/sdl1090/font/Ubuntu-M.ttf.REMOVED.git-id new file mode 100644 index 0000000..fcce345 --- /dev/null +++ b/sdl1090/font/Ubuntu-M.ttf.REMOVED.git-id @@ -0,0 +1 @@ +ca9c03a4767153b6d2f64c1d8909525ba39bb8d7 \ No newline at end of file diff --git a/sdl1090/font/Ubuntu-MI.ttf.REMOVED.git-id b/sdl1090/font/Ubuntu-MI.ttf.REMOVED.git-id new file mode 100644 index 0000000..e28f8bb --- /dev/null +++ b/sdl1090/font/Ubuntu-MI.ttf.REMOVED.git-id @@ -0,0 +1 @@ +e8d186c510a26f1b4319bbb797c3ee18cb104e26 \ No newline at end of file diff --git a/sdl1090/font/Ubuntu-R.ttf.REMOVED.git-id b/sdl1090/font/Ubuntu-R.ttf.REMOVED.git-id new file mode 100644 index 0000000..f146cda --- /dev/null +++ b/sdl1090/font/Ubuntu-R.ttf.REMOVED.git-id @@ -0,0 +1 @@ +d748728a20789bf5f95e524f3d508f54c67f9475 \ No newline at end of file diff --git a/sdl1090/font/Ubuntu-RI.ttf.REMOVED.git-id b/sdl1090/font/Ubuntu-RI.ttf.REMOVED.git-id new file mode 100644 index 0000000..64b1304 --- /dev/null +++ b/sdl1090/font/Ubuntu-RI.ttf.REMOVED.git-id @@ -0,0 +1 @@ +4f2d2bc7cb6ae34d90066e1b330dc18ae2386e38 \ No newline at end of file diff --git a/sdl1090/font/UbuntuMono-B.ttf.REMOVED.git-id b/sdl1090/font/UbuntuMono-B.ttf.REMOVED.git-id new file mode 100644 index 0000000..45ccf0d --- /dev/null +++ b/sdl1090/font/UbuntuMono-B.ttf.REMOVED.git-id @@ -0,0 +1 @@ +7bd6665765768ae885e2868623e7e9c2fd0cfc8a \ No newline at end of file diff --git a/sdl1090/font/UbuntuMono-BI.ttf.REMOVED.git-id b/sdl1090/font/UbuntuMono-BI.ttf.REMOVED.git-id new file mode 100644 index 0000000..53e6806 --- /dev/null +++ b/sdl1090/font/UbuntuMono-BI.ttf.REMOVED.git-id @@ -0,0 +1 @@ +6c5b8ba023e41689a2e14dc3c88f978e3188a1de \ No newline at end of file diff --git a/sdl1090/font/UbuntuMono-R.ttf.REMOVED.git-id b/sdl1090/font/UbuntuMono-R.ttf.REMOVED.git-id new file mode 100644 index 0000000..86fed0a --- /dev/null +++ b/sdl1090/font/UbuntuMono-R.ttf.REMOVED.git-id @@ -0,0 +1 @@ +fdd309d716629f4e5339d5e5508225ed857a3ede \ No newline at end of file diff --git a/sdl1090/font/UbuntuMono-RI.ttf.REMOVED.git-id b/sdl1090/font/UbuntuMono-RI.ttf.REMOVED.git-id new file mode 100644 index 0000000..a1689b5 --- /dev/null +++ b/sdl1090/font/UbuntuMono-RI.ttf.REMOVED.git-id @@ -0,0 +1 @@ +18f81a29258d13e1d6f1ce98cdd167091ea9bd4a \ No newline at end of file diff --git a/sdl1090/unifont.ttf.REMOVED.git-id b/sdl1090/font/unifont.ttf.REMOVED.git-id similarity index 100% rename from sdl1090/unifont.ttf.REMOVED.git-id rename to sdl1090/font/unifont.ttf.REMOVED.git-id diff --git a/sdl1090/init.c b/sdl1090/init.c index 5570b11..b4c35a2 100644 --- a/sdl1090/init.c +++ b/sdl1090/init.c @@ -64,9 +64,9 @@ void init(char *title) game.bigScreen = SDL_SetVideoMode(Modes.screen_width * Modes.screen_upscale, Modes.screen_height * Modes.screen_upscale, Modes.screen_depth, SDL_HWPALETTE|SDL_DOUBLEBUF); game.screen = SDL_CreateRGBSurface(0, Modes.screen_width, Modes.screen_height, Modes.screen_depth, 0, 0, 0, 0); } else { - game.screen = SDL_SetVideoMode(Modes.screen_width, Modes.screen_width, Modes.screen_depth, SDL_HWPALETTE|SDL_DOUBLEBUF); + game.screen = SDL_SetVideoMode(Modes.screen_width, Modes.screen_height, Modes.screen_depth, SDL_HWPALETTE|SDL_DOUBLEBUF); } - + if (game.screen == NULL) { printf("Couldn't set screen mode to %d x %d: %s\n", Modes.screen_width, Modes.screen_height, SDL_GetError()); @@ -76,9 +76,12 @@ void init(char *title) /* Load the font */ - game.font = loadFont("TerminusTTF-Bold-4.46.0.ttf", 12); + game.font = loadFont("font/TerminusTTF-Bold-4.46.0.ttf", 12); - game.listFont = loadFont("TerminusTTF-Bold-4.46.0.ttf", 18); + game.listFont = loadFont("font/TerminusTTF-Bold-4.46.0.ttf", 18); + + game.fontWidth = 10; + game.fontHeight = 20; /* Set the screen title */ diff --git a/sdl1090/interactive.c b/sdl1090/interactive.c index ac3465d..e27e31d 100644 --- a/sdl1090/interactive.c +++ b/sdl1090/interactive.c @@ -146,6 +146,8 @@ struct aircraft *interactiveCreateAircraft(struct modesMessage *mm) { memset(a->signalLevel, mm->signalLevel, 8); // First time, initialise everything // to the first signal strength + memset(a->messageRate, 0, sizeof(a->messageRate)); + // mm->msgtype 32 is used to represent Mode A/C. These values can never change, so // set them once here during initialisation, and don't bother to set them every // time this ModeA/C is received again in the future @@ -273,7 +275,8 @@ struct aircraft *interactiveReceiveData(struct modesMessage *mm) { a = interactiveFindAircraft(mm->addr); if (!a) { // If it's a currently unknown aircraft.... a = interactiveCreateAircraft(mm); // ., create a new record for it, - a->next = Modes.aircrafts; // .. and put it at the head of the list + a->prev_seen = time(NULL); + a->next = Modes.aircrafts; // .. and put it at the head of the list Modes.aircrafts = a; } else { /* If it is an already known aircraft, move it on head @@ -292,11 +295,18 @@ struct aircraft *interactiveReceiveData(struct modesMessage *mm) { a->next = Modes.aircrafts; Modes.aircrafts = a; } + + a->prev_seen = a->seen; } a->signalLevel[a->messages & 7] = mm->signalLevel;// replace the 8th oldest signal strength a->seen = time(NULL); a->timestamp = mm->timestampMsg; + + if((a->seen - a->prev_seen) > 0) { + a->messageRate[a->messages & 7] = 1.0 / (double)(a->seen - a->prev_seen); + } + a->messages++; // If a (new) CALLSIGN has been received, copy it to the aircraft structure diff --git a/sdl1090/list.c b/sdl1090/list.c index 004fbb5..8ead030 100644 --- a/sdl1090/list.c +++ b/sdl1090/list.c @@ -1,19 +1,9 @@ #include "dump1090.h" #include "structs.h" #include "parula.h" +#include "monokai.h" #include "SDL/SDL_gfxPrimitives.h" -SDL_Color pink = {249,38,114,255}; -SDL_Color blue = {102,217,239,255}; -SDL_Color green = {166,226,46,255}; -SDL_Color yellow = {253,250,31,255}; -SDL_Color orange = {253,151,31,255}; -SDL_Color lightGrey = {196,196,196,255}; -SDL_Color grey = {127,127,127,255}; -SDL_Color darkGrey = {64,64,64,255}; -SDL_Color black = {0,0,0,255}; -SDL_Color white = {255,255,255,255}; - void drawList(int rows, int top) { struct aircraft *a = Modes.aircrafts; time_t now = time(NULL); diff --git a/sdl1090/maps.c b/sdl1090/maps.c index 758fd1b..e1d0c12 100644 --- a/sdl1090/maps.c +++ b/sdl1090/maps.c @@ -3,15 +3,9 @@ #include "structs.h" #include "parula.h" #include "magma.h" +#include "monokai.h" #include "SDL/SDL_gfxPrimitives.h" -#define LOGMAXDIST 1000.0 -#define MAXDIST 50.0 - -#define AA 0 - -#define MAGMA 0 - void CROSSVP(double *v, double *u, double *w) { v[0] = u[1]*w[2] - u[2]*(w)[1]; @@ -49,22 +43,22 @@ SDL_Color signalToColor(int signal) { int screenDist(double d) { - double scale_factor = (SCREEN_WIDTH > SCREEN_HEIGHT) ? SCREEN_WIDTH : SCREEN_HEIGHT; + double scale_factor = (Modes.screen_width > Modes.screen_height) ? Modes.screen_width : Modes.screen_height; if(Modes.mapLogDist) { - return round(scale_factor* 0.5 * log(1.0+fabs(d)) / log(1.0+LOGMAXDIST)); + return round(0.95 * scale_factor * 0.5 * log(1.0+fabs(d)) / log(1.0+LOGMAXDIST)); } else { - return round(scale_factor * 0.5 * fabs(d) / MAXDIST); + return round(0.95 * scale_factor * 0.5 * fabs(d) / MAXDIST); } } void screenCoords(int *outX, int *outY, double dx, double dy) { - *outX = (SCREEN_WIDTH>>1) + ((dx>0) ? 1 : -1) * screenDist(dx); - *outY = (SCREEN_HEIGHT>>1) + ((dy>0) ? 1 : -1) * screenDist(dy); + *outX = (Modes.screen_width>>1) + ((dx>0) ? 1 : -1) * screenDist(dx); + *outY = (Modes.screen_height * 0.4) + ((dy>0) ? 1 : -1) * screenDist(dy); } int outOfBounds(int x, int y) { - if(x < 0 || x >= SCREEN_WIDTH || y < 0 || y >= SCREEN_HEIGHT ) { + if(x < 0 || x >= Modes.screen_width || y < 0 || y >= Modes.screen_height ) { return 1; } else { return 0; @@ -218,22 +212,22 @@ void drawGrid() int p10km = screenDist(10.0); int p100km = screenDist(100.0); - hlineRGBA (game.screen, 0, SCREEN_WIDTH, SCREEN_HEIGHT>>1, 127, 127, 127, SDL_ALPHA_OPAQUE); - vlineRGBA (game.screen, SCREEN_WIDTH>>1, 0, SCREEN_HEIGHT, 127, 127, 127, SDL_ALPHA_OPAQUE); + hlineRGBA (game.screen, 0, Modes.screen_width, Modes.screen_height*0.4, 127, 127, 127, SDL_ALPHA_OPAQUE); + vlineRGBA (game.screen, Modes.screen_width>>1, 0, Modes.screen_height, 127, 127, 127, SDL_ALPHA_OPAQUE); if(AA) { - aacircleRGBA (game.screen, SCREEN_WIDTH>>1, SCREEN_HEIGHT>>1, p1km, 249,38,114, SDL_ALPHA_OPAQUE); - aacircleRGBA (game.screen, SCREEN_WIDTH>>1, SCREEN_HEIGHT>>1, p10km, 187,29,86, SDL_ALPHA_OPAQUE); - aacircleRGBA (game.screen, SCREEN_WIDTH>>1, SCREEN_HEIGHT>>1, p100km, 125,19,57, SDL_ALPHA_OPAQUE); + aacircleRGBA (game.screen, Modes.screen_width>>1, Modes.screen_height>>1, p1km, 249,38,114, SDL_ALPHA_OPAQUE); + aacircleRGBA (game.screen, Modes.screen_width>>1, Modes.screen_height>>1, p10km, 187,29,86, SDL_ALPHA_OPAQUE); + aacircleRGBA (game.screen, Modes.screen_width>>1, Modes.screen_height>>1, p100km, 125,19,57, SDL_ALPHA_OPAQUE); } else { - circleRGBA (game.screen, SCREEN_WIDTH>>1, SCREEN_HEIGHT>>1, p1km, 249,38,114, SDL_ALPHA_OPAQUE); - circleRGBA (game.screen, SCREEN_WIDTH>>1, SCREEN_HEIGHT>>1, p10km, 187,29,86, SDL_ALPHA_OPAQUE); - circleRGBA (game.screen, SCREEN_WIDTH>>1, SCREEN_HEIGHT>>1, p100km, 125,19,57, SDL_ALPHA_OPAQUE); + circleRGBA (game.screen, Modes.screen_width>>1, Modes.screen_height*0.4, p1km, 249,38,114, SDL_ALPHA_OPAQUE); + circleRGBA (game.screen, Modes.screen_width>>1, Modes.screen_height*0.4, p10km, 187,29,86, SDL_ALPHA_OPAQUE); + circleRGBA (game.screen, Modes.screen_width>>1, Modes.screen_height*0.4, p100km, 125,19,57, SDL_ALPHA_OPAQUE); } - drawString("1km", (SCREEN_WIDTH>>1) + p1km + 5, (SCREEN_HEIGHT>>1) + 5, game.font, setColor(249,38,114)); - drawString("10km", (SCREEN_WIDTH>>1) + p10km + 5, (SCREEN_HEIGHT>>1) + 5, game.font, setColor(187,29,86)); - drawString("100km", (SCREEN_WIDTH>>1) + p100km + 5, (SCREEN_HEIGHT>>1) + 5, game.font, setColor(125,19,57)); + drawString("1km", (Modes.screen_width>>1) + p1km + 5, (Modes.screen_height*0.4) + 5, game.font, setColor(249,38,114)); + drawString("10km", (Modes.screen_width>>1) + p10km + 5, (Modes.screen_height*0.4) + 5, game.font, setColor(187,29,86)); + drawString("100km", (Modes.screen_width>>1) + p100km + 5, (Modes.screen_height*0.4) + 5, game.font, setColor(125,19,57)); } void drawGeography() { @@ -251,29 +245,10 @@ void drawGeography() { continue; } - - SDL_Color geoColor; - - // double x1d = (double) abs(x1 - (SCREEN_WIDTH>>1)); - // double y1d = (double) abs(y1 - (SCREEN_HEIGHT>>1)); - - // double colorDist = sqrt(x1d * x1d + y1d * y1d) / (double) SCREEN_HEIGHT; - - // colorDist = (colorDist < 0.0) ? 0.0 : colorDist; - // colorDist = (colorDist > 1.0) ? 1.0 : colorDist; - - // geoColor.r = (uint8_t) (colorDist * 114.0 + (1.0 - colorDist) * 166.0); - // geoColor.g = (uint8_t) (colorDist * 29.0 + (1.0 - colorDist) * 266.0); - // geoColor.b = (uint8_t) (colorDist * 240.0 + (1.0 - colorDist) * 16.0); - - geoColor.r = 100; - geoColor.g = 0; - geoColor.b = 200; - if(AA) { - aalineRGBA(game.screen, x1, y1, x2, y2,geoColor.r,geoColor.g,geoColor.b, SDL_ALPHA_OPAQUE); + aalineRGBA(game.screen, x1, y1, x2, y2,purple.r,purple.g,purple.b, SDL_ALPHA_OPAQUE); } else { - lineRGBA(game.screen, x1, y1, x2, y2,geoColor.r,geoColor.g,geoColor.b, SDL_ALPHA_OPAQUE); + lineRGBA(game.screen, x1, y1, x2, y2,purple.r,purple.g,purple.b, SDL_ALPHA_OPAQUE); } } } diff --git a/sdl1090/monokai.c b/sdl1090/monokai.c new file mode 100644 index 0000000..51157bd --- /dev/null +++ b/sdl1090/monokai.c @@ -0,0 +1,14 @@ +#include "monokai.h" + +SDL_Color pink = {249,38,114,255}; +SDL_Color purple = {100,0,200,255}; +SDL_Color blue = {102,217,239,255}; +SDL_Color green = {166,226,46,255}; +SDL_Color yellow = {253,250,31,255}; +SDL_Color orange = {253,151,31,255}; +SDL_Color lightGrey = {196,196,196,255}; +SDL_Color grey = {127,127,127,255}; +SDL_Color darkGrey = {64,64,64,255}; +SDL_Color black = {0,0,0,255}; +SDL_Color white = {255,255,255,255}; +SDL_Color red = {255,0,0,255}; \ No newline at end of file diff --git a/sdl1090/monokai.h b/sdl1090/monokai.h new file mode 100644 index 0000000..06f752a --- /dev/null +++ b/sdl1090/monokai.h @@ -0,0 +1,14 @@ +#include "structs.h" + +SDL_Color pink; +SDL_Color purple; +SDL_Color blue; +SDL_Color green; +SDL_Color yellow; +SDL_Color orange; +SDL_Color lightGrey; +SDL_Color grey; +SDL_Color darkGrey; +SDL_Color black; +SDL_Color white; +SDL_Color red; \ No newline at end of file diff --git a/sdl1090/status.c b/sdl1090/status.c new file mode 100644 index 0000000..85e4ada --- /dev/null +++ b/sdl1090/status.c @@ -0,0 +1,143 @@ +#include "dump1090.h" +#include "structs.h" +#include "parula.h" +#include "monokai.h" +#include "SDL/SDL_gfxPrimitives.h" + +#define PAD 5 + +void updateStatus() { + struct aircraft *a = Modes.aircrafts; + + int numVisiblePlanes = 0; + double maxDist = 0; + int totalCount = 0; + double sigAccumulate = 0.0; + double msgRateAccumulate = 0.0; + + Status.closeCall = NULL; + + while(a) { + int flags = a->modeACflags; + int msgs = a->messages; + + 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) ) + ) { + + unsigned char * pSig = a->signalLevel; + unsigned int signalAverage = (pSig[0] + pSig[1] + pSig[2] + pSig[3] + + pSig[4] + pSig[5] + pSig[6] + pSig[7]); + + sigAccumulate += signalAverage; + + if (a->bFlags & MODES_ACFLAGS_LATLON_VALID) { + double d = sqrt(a->dx * a->dx + a->dy * a->dy); + + if(d < LOGMAXDIST) { + if(d > maxDist) { + maxDist = d; + } + + if(d < 100.0) { + Status.closeCall = a; + } + + numVisiblePlanes++; + } + } + totalCount++; + } + + + msgRateAccumulate += (a->messageRate[0] + a->messageRate[1] + a->messageRate[2] + a->messageRate[3] + + a->messageRate[4] + a->messageRate[5] + a->messageRate[6] + a->messageRate[7]); + + a = a->next; + } + + Status.msgRate = msgRateAccumulate; + Status.avgSig = sigAccumulate / (double) totalCount; + Status.numPlanes = totalCount; + Status.numVisiblePlanes = numVisiblePlanes; + Status.maxDist = maxDist; +} + +void drawStatusBox(int *left, int *top, char *label, char *message, SDL_Color color) { + int labelWidth = (strlen(label) + 2) * game.fontWidth; + int messageWidth = (strlen(message) + ((strlen(message) > 0) ? 2 : 0)) * game.fontWidth; + + if(strlen(label) == 0 && strlen(message) == 0) { + boxRGBA(game.screen, *left, *top, Modes.screen_width - PAD, *top + game.fontHeight, darkGrey.r, darkGrey.g, darkGrey.b, SDL_ALPHA_OPAQUE); + return; + } + + if(*left + labelWidth + messageWidth + PAD > Modes.screen_width) { + boxRGBA(game.screen, *left, *top, Modes.screen_width - PAD, *top + game.fontHeight, darkGrey.r, darkGrey.g, darkGrey.b, SDL_ALPHA_OPAQUE); + *left = PAD; + *top = *top - game.fontHeight - PAD; + } + + if(messageWidth) { + boxRGBA(game.screen, *left, *top, *left + labelWidth + messageWidth, *top + game.fontHeight, black.r, black.g, black.b, SDL_ALPHA_OPAQUE); + } + + boxRGBA(game.screen, *left, *top, *left + labelWidth, *top + game.fontHeight, color.r, color.g, color.b, SDL_ALPHA_OPAQUE); + + if(messageWidth) { + rectangleRGBA(game.screen, *left, *top, *left + labelWidth + messageWidth, *top + game.fontHeight, color.r, color.g, color.b, SDL_ALPHA_OPAQUE); + } + + drawString(label, *left + game.fontWidth, *top, game.listFont, black); + drawString(message, *left + labelWidth + game.fontWidth, *top, game.listFont, color); + + *left = *left + labelWidth + messageWidth + PAD; +} + +void drawStatus() { + + int left = PAD; + int top = Modes.screen_height - game.fontHeight - PAD; + + char strPlaneCount[10] = " "; + snprintf(strPlaneCount, 10,"%d/%d", Status.numVisiblePlanes, Status.numPlanes); + drawStatusBox(&left, &top, "disp", strPlaneCount, yellow); + + char strDMax[18] = " "; + snprintf(strDMax, 18, "%.1fkm", Status.maxDist); + drawStatusBox(&left, &top, "maxDist", strDMax, blue); + + char strMsgRate[18] = " "; + snprintf(strMsgRate, 18,"%.0f msg/s", Status.msgRate); + drawStatusBox(&left, &top, "rate", strMsgRate, pink); + + char strSig[18] = " "; + snprintf(strSig, 18, "%.0f%%", 100.0 * Status.avgSig / 1024.0); + drawStatusBox(&left, &top, "sigAvg", strSig, green); + + drawStatusBox(&left, &top, "GPS", "", purple); + + char strLoc[20] = " "; + snprintf(strLoc, 20, "%3.3fN %3.3f%c", Modes.fUserLat, fabs(Modes.fUserLon),(Modes.fUserLon > 0) ? 'E' : 'W'); + + drawStatusBox(&left, &top, "pos", strLoc, orange); + + if(Status.closeCall != NULL) { + char strSpeed[8] = " "; + snprintf(strSpeed, 8, "%.0fkm/h", Status.closeCall->speed * 1.852); + drawStatusBox(&left, &top, "vel", strSpeed, white); + + char strAlt[8] = " "; + snprintf(strAlt, 8, "%.0fm", Status.closeCall->altitude / 3.2828); + drawStatusBox(&left, &top, "alt", strAlt, white); + + drawStatusBox(&left, &top, "nearby", "", red); + + if(strlen(Status.closeCall->flight)) { + drawStatusBox(&left, &top, "id", Status.closeCall->flight, white); + } + } + + drawStatusBox(&left, &top, "", "", black); +} diff --git a/sdl1090/structs.h b/sdl1090/structs.h index d4d23f2..cc148d6 100644 --- a/sdl1090/structs.h +++ b/sdl1090/structs.h @@ -1,11 +1,17 @@ +#ifndef STRUCTS +#define STRUCTS + #include "defs.h" typedef struct Game { SDL_Surface *screen; SDL_Surface *bigScreen; + TTF_Font *font; - TTF_Font *listFont; + TTF_Font *listFont; + int fontWidth; + int fontHeight; } Game; Game game; @@ -32,4 +38,10 @@ void initMaps(); void drawList(int rows, int top); //draw.c -void draw(); \ No newline at end of file +void draw(); + +//status.c +void updateStatus(); +void drawStatus(); + +#endif \ No newline at end of file diff --git a/sdl1090/view1090.REMOVED.git-id b/sdl1090/view1090.REMOVED.git-id index 43f54ad..50e1fab 100644 --- a/sdl1090/view1090.REMOVED.git-id +++ b/sdl1090/view1090.REMOVED.git-id @@ -1 +1 @@ -23e4c5e5e54051ba50828a644d9cec7f0c24d965 \ No newline at end of file +b7315d268ac28e2a67d8925acc46b6c0ada7c1c8 \ No newline at end of file diff --git a/sdl1090/view1090.c b/sdl1090/view1090.c index ca540c4..9db2109 100644 --- a/sdl1090/view1090.c +++ b/sdl1090/view1090.c @@ -94,6 +94,13 @@ void view1090InitConfig(void) { Modes.screen_width = SCREEN_WIDTH; Modes.screen_height = SCREEN_HEIGHT; Modes.screen_depth = 32; + + // Initialize status + Status.msgRate = 0; + Status.avgSig = 0; + Status.numPlanes = 0; + Status.numVisiblePlanes = 0; + Status.maxDist = 0; } // //========================================================================= @@ -369,10 +376,6 @@ int main(int argc, char **argv) { interactiveRemoveStaleAircrafts(); - if (Modes.interactive) { - interactiveShowData(); - } - draw(); if ((fd == ANET_ERR) || (recv(c->fd, pk_buf, sizeof(pk_buf), MSG_PEEK | MSG_DONTWAIT) == 0)) { @@ -383,6 +386,8 @@ int main(int argc, char **argv) { continue; } modesReadFromClient(c,"",decodeBinMessage); + + usleep(100000); } // The user has stopped us, so close any socket we opened diff --git a/sdl1090/view1090.dSYM/Contents/Info.plist b/sdl1090/view1090.dSYM/Contents/Info.plist new file mode 100644 index 0000000..1ddd71d --- /dev/null +++ b/sdl1090/view1090.dSYM/Contents/Info.plist @@ -0,0 +1,20 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleIdentifier + com.apple.xcode.dsym.view1090 + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + dSYM + CFBundleSignature + ???? + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + + diff --git a/sdl1090/view1090.dSYM/Contents/Resources/DWARF/view1090.REMOVED.git-id b/sdl1090/view1090.dSYM/Contents/Resources/DWARF/view1090.REMOVED.git-id new file mode 100644 index 0000000..05b4fe9 --- /dev/null +++ b/sdl1090/view1090.dSYM/Contents/Resources/DWARF/view1090.REMOVED.git-id @@ -0,0 +1 @@ +8090a053ba2c7c31e5b2cfc5870918d933a99849 \ No newline at end of file