status boxes on map layout
Former-commit-id: 2c494dcf47da220f7dd081d4b3fe09a6c67b35f9 Former-commit-id: 587a33ba83cd4c661d7bcc8528c70ad723ca4066
This commit is contained in:
parent
4cc12f08e1
commit
96f0457439
|
@ -1 +0,0 @@
|
||||||
06aafc067310fba0d33b0a133654475ac73388ab
|
|
|
@ -1 +0,0 @@
|
||||||
985bd4002d7a293f50db1ab1d7b90f5a3da066b4
|
|
|
@ -1 +0,0 @@
|
||||||
838f2d125233f373f3b5cff30ae3fde7f1089514
|
|
|
@ -1 +0,0 @@
|
||||||
43505c164f6a77fc43068440a586c380296f0125
|
|
|
@ -1 +0,0 @@
|
||||||
ab68fb197d4479b3b6dec6e85bd5cbaf433a87c5
|
|
|
@ -1 +0,0 @@
|
||||||
940e255d0140b07a15ea0371695c25c02087f368
|
|
|
@ -25,8 +25,8 @@ all: view1090
|
||||||
%.o: %.c
|
%.o: %.c
|
||||||
$(CC) $(CFLAGS) $(EXTRACFLAGS) -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
|
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 list.o parula.o $(LIBS) $(LDFLAGS)
|
$(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:
|
clean:
|
||||||
rm -f *.o view1090
|
rm -f *.o view1090
|
||||||
|
|
|
@ -14,3 +14,10 @@
|
||||||
#define SCREEN_HEIGHT 480
|
#define SCREEN_HEIGHT 480
|
||||||
|
|
||||||
#define UPSCALE 3
|
#define UPSCALE 3
|
||||||
|
|
||||||
|
#define LOGMAXDIST 1000.0
|
||||||
|
#define MAXDIST 50.0
|
||||||
|
|
||||||
|
#define AA 0
|
||||||
|
|
||||||
|
#define MAGMA 0
|
|
@ -19,27 +19,32 @@ void draw() {
|
||||||
|
|
||||||
Modes.interactive_last_update = mstime();
|
Modes.interactive_last_update = mstime();
|
||||||
|
|
||||||
|
updateStatus();
|
||||||
|
|
||||||
SDL_FillRect(game.screen, NULL, 0);
|
SDL_FillRect(game.screen, NULL, 0);
|
||||||
|
|
||||||
if (Modes.map) {
|
if (Modes.map) {
|
||||||
drawMap();
|
drawMap();
|
||||||
//drawList(3,320);
|
drawStatus();
|
||||||
} else {
|
} else {
|
||||||
drawList(10,0);
|
drawList(10,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Modes.screen_upscale > 1) {
|
if(Modes.screen_upscale > 1) {
|
||||||
|
SDL_Surface *temp = zoomSurface(game.screen, Modes.screen_upscale, Modes.screen_upscale, 0);
|
||||||
|
SDL_Surface *temp2 = SDL_DisplayFormat(temp);
|
||||||
SDL_Rect clip;
|
SDL_Rect clip;
|
||||||
SDL_Surface *temp = SDL_DisplayFormat(zoomSurface(game.screen, Modes.screen_upscale, Modes.screen_upscale, 0));
|
|
||||||
|
|
||||||
clip.x = 0;
|
clip.x = 0;
|
||||||
clip.y = 0;
|
clip.y = 0;
|
||||||
clip.w = temp->w;
|
clip.w = temp2->w;
|
||||||
clip.h = temp->h;
|
clip.h = temp2->h;
|
||||||
|
|
||||||
SDL_BlitSurface(temp, &clip, game.bigScreen, 0);
|
SDL_BlitSurface(temp2, 0, game.bigScreen, 0);
|
||||||
|
|
||||||
SDL_Flip(game.bigScreen);
|
SDL_Flip(game.bigScreen);
|
||||||
|
|
||||||
|
SDL_FreeSurface(temp);
|
||||||
|
SDL_FreeSurface(temp2);
|
||||||
} else {
|
} else {
|
||||||
SDL_Flip(game.screen);
|
SDL_Flip(game.screen);
|
||||||
}
|
}
|
||||||
|
|
|
@ -209,10 +209,12 @@ struct aircraft {
|
||||||
int track; // Angle of flight
|
int track; // Angle of flight
|
||||||
int vert_rate; // Vertical rate.
|
int vert_rate; // Vertical rate.
|
||||||
time_t seen; // Time at which the last packet was received
|
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
|
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 timestamp; // Timestamp at which the last packet was received
|
||||||
uint64_t timestampLatLon;// Timestamp at which the last lat long was calculated
|
uint64_t timestampLatLon;// Timestamp at which the last lat long was calculated
|
||||||
long messages; // Number of Mode S messages received
|
long messages; // Number of Mode S messages received
|
||||||
|
double messageRate[8]; // Number of Mode S messages received
|
||||||
int modeA; // Squawk
|
int modeA; // Squawk
|
||||||
int modeC; // Altitude
|
int modeC; // Altitude
|
||||||
long modeAcount; // Mode A Squawk hit Count
|
long modeAcount; // Mode A Squawk hit Count
|
||||||
|
@ -235,6 +237,15 @@ struct aircraft {
|
||||||
struct aircraft *next; // Next aircraft in our linked list
|
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 {
|
||||||
struct stDF *pNext; // Pointer to next item in the linked list
|
struct stDF *pNext; // Pointer to next item in the linked list
|
||||||
struct stDF *pPrev; // Pointer to previous item in the linked list
|
struct stDF *pPrev; // Pointer to previous item in the linked list
|
||||||
|
|
1
sdl1090/font/Envy Code R Bold.ttf.REMOVED.git-id
Normal file
1
sdl1090/font/Envy Code R Bold.ttf.REMOVED.git-id
Normal file
|
@ -0,0 +1 @@
|
||||||
|
5e04b16605e6f165afada700fa09ec2c744bd4ca
|
1
sdl1090/font/Envy Code R Italic.ttf.REMOVED.git-id
Normal file
1
sdl1090/font/Envy Code R Italic.ttf.REMOVED.git-id
Normal file
|
@ -0,0 +1 @@
|
||||||
|
cf67fe0caf3e7853db2af48cdcd28a4522a15572
|
1
sdl1090/font/Envy Code R.ttf.REMOVED.git-id
Normal file
1
sdl1090/font/Envy Code R.ttf.REMOVED.git-id
Normal file
|
@ -0,0 +1 @@
|
||||||
|
e8e4a6045fa8374ca37fd7f53dfa95c61142ae98
|
1
sdl1090/font/Monoid-Bold.ttf.REMOVED.git-id
Normal file
1
sdl1090/font/Monoid-Bold.ttf.REMOVED.git-id
Normal file
|
@ -0,0 +1 @@
|
||||||
|
730c63d4b5435fc57d6551f5a71d64b7e7d60fbb
|
1
sdl1090/font/Monoid-Italic.ttf.REMOVED.git-id
Normal file
1
sdl1090/font/Monoid-Italic.ttf.REMOVED.git-id
Normal file
|
@ -0,0 +1 @@
|
||||||
|
97a5b8f6ed4324088d095d616a147d05cfe8917a
|
1
sdl1090/font/Monoid-Regular.ttf.REMOVED.git-id
Normal file
1
sdl1090/font/Monoid-Regular.ttf.REMOVED.git-id
Normal file
|
@ -0,0 +1 @@
|
||||||
|
a09e9faff2c39c9dc56f6a0101a300851922e78d
|
1
sdl1090/font/Monoid-Retina.ttf.REMOVED.git-id
Normal file
1
sdl1090/font/Monoid-Retina.ttf.REMOVED.git-id
Normal file
|
@ -0,0 +1 @@
|
||||||
|
ec881731ace782f1f692c4d9afabe1710ef6ac25
|
1
sdl1090/font/Ubuntu-B.ttf.REMOVED.git-id
Normal file
1
sdl1090/font/Ubuntu-B.ttf.REMOVED.git-id
Normal file
|
@ -0,0 +1 @@
|
||||||
|
b173da27417c00101dff72617f9b9a2b80ecc8f3
|
1
sdl1090/font/Ubuntu-BI.ttf.REMOVED.git-id
Normal file
1
sdl1090/font/Ubuntu-BI.ttf.REMOVED.git-id
Normal file
|
@ -0,0 +1 @@
|
||||||
|
72a5a99ac0c781eb60dd8721ae93eedda298e07e
|
1
sdl1090/font/Ubuntu-C.ttf.REMOVED.git-id
Normal file
1
sdl1090/font/Ubuntu-C.ttf.REMOVED.git-id
Normal file
|
@ -0,0 +1 @@
|
||||||
|
602a3ee4ab20743037eee6daa1b304fa680967b6
|
1
sdl1090/font/Ubuntu-L.ttf.REMOVED.git-id
Normal file
1
sdl1090/font/Ubuntu-L.ttf.REMOVED.git-id
Normal file
|
@ -0,0 +1 @@
|
||||||
|
ed0f5bce879796461ebb93969d28a2bbb35efd0f
|
1
sdl1090/font/Ubuntu-LI.ttf.REMOVED.git-id
Normal file
1
sdl1090/font/Ubuntu-LI.ttf.REMOVED.git-id
Normal file
|
@ -0,0 +1 @@
|
||||||
|
c6cec55fcd5d8e00347661eba8684f848065594e
|
1
sdl1090/font/Ubuntu-M.ttf.REMOVED.git-id
Normal file
1
sdl1090/font/Ubuntu-M.ttf.REMOVED.git-id
Normal file
|
@ -0,0 +1 @@
|
||||||
|
ca9c03a4767153b6d2f64c1d8909525ba39bb8d7
|
1
sdl1090/font/Ubuntu-MI.ttf.REMOVED.git-id
Normal file
1
sdl1090/font/Ubuntu-MI.ttf.REMOVED.git-id
Normal file
|
@ -0,0 +1 @@
|
||||||
|
e8d186c510a26f1b4319bbb797c3ee18cb104e26
|
1
sdl1090/font/Ubuntu-R.ttf.REMOVED.git-id
Normal file
1
sdl1090/font/Ubuntu-R.ttf.REMOVED.git-id
Normal file
|
@ -0,0 +1 @@
|
||||||
|
d748728a20789bf5f95e524f3d508f54c67f9475
|
1
sdl1090/font/Ubuntu-RI.ttf.REMOVED.git-id
Normal file
1
sdl1090/font/Ubuntu-RI.ttf.REMOVED.git-id
Normal file
|
@ -0,0 +1 @@
|
||||||
|
4f2d2bc7cb6ae34d90066e1b330dc18ae2386e38
|
1
sdl1090/font/UbuntuMono-B.ttf.REMOVED.git-id
Normal file
1
sdl1090/font/UbuntuMono-B.ttf.REMOVED.git-id
Normal file
|
@ -0,0 +1 @@
|
||||||
|
7bd6665765768ae885e2868623e7e9c2fd0cfc8a
|
1
sdl1090/font/UbuntuMono-BI.ttf.REMOVED.git-id
Normal file
1
sdl1090/font/UbuntuMono-BI.ttf.REMOVED.git-id
Normal file
|
@ -0,0 +1 @@
|
||||||
|
6c5b8ba023e41689a2e14dc3c88f978e3188a1de
|
1
sdl1090/font/UbuntuMono-R.ttf.REMOVED.git-id
Normal file
1
sdl1090/font/UbuntuMono-R.ttf.REMOVED.git-id
Normal file
|
@ -0,0 +1 @@
|
||||||
|
fdd309d716629f4e5339d5e5508225ed857a3ede
|
1
sdl1090/font/UbuntuMono-RI.ttf.REMOVED.git-id
Normal file
1
sdl1090/font/UbuntuMono-RI.ttf.REMOVED.git-id
Normal file
|
@ -0,0 +1 @@
|
||||||
|
18f81a29258d13e1d6f1ce98cdd167091ea9bd4a
|
|
@ -64,7 +64,7 @@ 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.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);
|
game.screen = SDL_CreateRGBSurface(0, Modes.screen_width, Modes.screen_height, Modes.screen_depth, 0, 0, 0, 0);
|
||||||
} else {
|
} 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)
|
if (game.screen == NULL)
|
||||||
|
@ -76,9 +76,12 @@ void init(char *title)
|
||||||
|
|
||||||
/* Load the font */
|
/* 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 */
|
/* Set the screen title */
|
||||||
|
|
||||||
|
|
|
@ -146,6 +146,8 @@ struct aircraft *interactiveCreateAircraft(struct modesMessage *mm) {
|
||||||
memset(a->signalLevel, mm->signalLevel, 8); // First time, initialise everything
|
memset(a->signalLevel, mm->signalLevel, 8); // First time, initialise everything
|
||||||
// to the first signal strength
|
// 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
|
// 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
|
// set them once here during initialisation, and don't bother to set them every
|
||||||
// time this ModeA/C is received again in the future
|
// time this ModeA/C is received again in the future
|
||||||
|
@ -273,6 +275,7 @@ struct aircraft *interactiveReceiveData(struct modesMessage *mm) {
|
||||||
a = interactiveFindAircraft(mm->addr);
|
a = interactiveFindAircraft(mm->addr);
|
||||||
if (!a) { // If it's a currently unknown aircraft....
|
if (!a) { // If it's a currently unknown aircraft....
|
||||||
a = interactiveCreateAircraft(mm); // ., create a new record for it,
|
a = interactiveCreateAircraft(mm); // ., create a new record for it,
|
||||||
|
a->prev_seen = time(NULL);
|
||||||
a->next = Modes.aircrafts; // .. and put it at the head of the list
|
a->next = Modes.aircrafts; // .. and put it at the head of the list
|
||||||
Modes.aircrafts = a;
|
Modes.aircrafts = a;
|
||||||
} else {
|
} else {
|
||||||
|
@ -292,11 +295,18 @@ struct aircraft *interactiveReceiveData(struct modesMessage *mm) {
|
||||||
a->next = Modes.aircrafts;
|
a->next = Modes.aircrafts;
|
||||||
Modes.aircrafts = a;
|
Modes.aircrafts = a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
a->prev_seen = a->seen;
|
||||||
}
|
}
|
||||||
|
|
||||||
a->signalLevel[a->messages & 7] = mm->signalLevel;// replace the 8th oldest signal strength
|
a->signalLevel[a->messages & 7] = mm->signalLevel;// replace the 8th oldest signal strength
|
||||||
a->seen = time(NULL);
|
a->seen = time(NULL);
|
||||||
a->timestamp = mm->timestampMsg;
|
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++;
|
a->messages++;
|
||||||
|
|
||||||
// If a (new) CALLSIGN has been received, copy it to the aircraft structure
|
// If a (new) CALLSIGN has been received, copy it to the aircraft structure
|
||||||
|
|
|
@ -1,19 +1,9 @@
|
||||||
#include "dump1090.h"
|
#include "dump1090.h"
|
||||||
#include "structs.h"
|
#include "structs.h"
|
||||||
#include "parula.h"
|
#include "parula.h"
|
||||||
|
#include "monokai.h"
|
||||||
#include "SDL/SDL_gfxPrimitives.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) {
|
void drawList(int rows, int top) {
|
||||||
struct aircraft *a = Modes.aircrafts;
|
struct aircraft *a = Modes.aircrafts;
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
|
|
|
@ -3,15 +3,9 @@
|
||||||
#include "structs.h"
|
#include "structs.h"
|
||||||
#include "parula.h"
|
#include "parula.h"
|
||||||
#include "magma.h"
|
#include "magma.h"
|
||||||
|
#include "monokai.h"
|
||||||
#include "SDL/SDL_gfxPrimitives.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)
|
void CROSSVP(double *v, double *u, double *w)
|
||||||
{
|
{
|
||||||
v[0] = u[1]*w[2] - u[2]*(w)[1];
|
v[0] = u[1]*w[2] - u[2]*(w)[1];
|
||||||
|
@ -49,22 +43,22 @@ SDL_Color signalToColor(int signal) {
|
||||||
|
|
||||||
int screenDist(double d) {
|
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) {
|
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 {
|
} 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) {
|
void screenCoords(int *outX, int *outY, double dx, double dy) {
|
||||||
*outX = (SCREEN_WIDTH>>1) + ((dx>0) ? 1 : -1) * screenDist(dx);
|
*outX = (Modes.screen_width>>1) + ((dx>0) ? 1 : -1) * screenDist(dx);
|
||||||
*outY = (SCREEN_HEIGHT>>1) + ((dy>0) ? 1 : -1) * screenDist(dy);
|
*outY = (Modes.screen_height * 0.4) + ((dy>0) ? 1 : -1) * screenDist(dy);
|
||||||
}
|
}
|
||||||
|
|
||||||
int outOfBounds(int x, int y) {
|
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;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -218,22 +212,22 @@ void drawGrid()
|
||||||
int p10km = screenDist(10.0);
|
int p10km = screenDist(10.0);
|
||||||
int p100km = screenDist(100.0);
|
int p100km = screenDist(100.0);
|
||||||
|
|
||||||
hlineRGBA (game.screen, 0, SCREEN_WIDTH, SCREEN_HEIGHT>>1, 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, SCREEN_WIDTH>>1, 0, SCREEN_HEIGHT, 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) {
|
if(AA) {
|
||||||
aacircleRGBA (game.screen, SCREEN_WIDTH>>1, SCREEN_HEIGHT>>1, p1km, 249,38,114, SDL_ALPHA_OPAQUE);
|
aacircleRGBA (game.screen, Modes.screen_width>>1, Modes.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, Modes.screen_width>>1, Modes.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, p100km, 125,19,57, SDL_ALPHA_OPAQUE);
|
||||||
} else {
|
} else {
|
||||||
circleRGBA (game.screen, SCREEN_WIDTH>>1, SCREEN_HEIGHT>>1, p1km, 249,38,114, 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, SCREEN_WIDTH>>1, SCREEN_HEIGHT>>1, p10km, 187,29,86, 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, 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, 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("1km", (Modes.screen_width>>1) + p1km + 5, (Modes.screen_height*0.4) + 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("10km", (Modes.screen_width>>1) + p10km + 5, (Modes.screen_height*0.4) + 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("100km", (Modes.screen_width>>1) + p100km + 5, (Modes.screen_height*0.4) + 5, game.font, setColor(125,19,57));
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawGeography() {
|
void drawGeography() {
|
||||||
|
@ -251,29 +245,10 @@ void drawGeography() {
|
||||||
continue;
|
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) {
|
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 {
|
} 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
14
sdl1090/monokai.c
Normal file
14
sdl1090/monokai.c
Normal file
|
@ -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};
|
14
sdl1090/monokai.h
Normal file
14
sdl1090/monokai.h
Normal file
|
@ -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;
|
143
sdl1090/status.c
Normal file
143
sdl1090/status.c
Normal file
|
@ -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);
|
||||||
|
}
|
|
@ -1,11 +1,17 @@
|
||||||
|
#ifndef STRUCTS
|
||||||
|
#define STRUCTS
|
||||||
|
|
||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
|
|
||||||
typedef struct Game
|
typedef struct Game
|
||||||
{
|
{
|
||||||
SDL_Surface *screen;
|
SDL_Surface *screen;
|
||||||
SDL_Surface *bigScreen;
|
SDL_Surface *bigScreen;
|
||||||
|
|
||||||
TTF_Font *font;
|
TTF_Font *font;
|
||||||
TTF_Font *listFont;
|
TTF_Font *listFont;
|
||||||
|
int fontWidth;
|
||||||
|
int fontHeight;
|
||||||
} Game;
|
} Game;
|
||||||
|
|
||||||
Game game;
|
Game game;
|
||||||
|
@ -33,3 +39,9 @@ void drawList(int rows, int top);
|
||||||
|
|
||||||
//draw.c
|
//draw.c
|
||||||
void draw();
|
void draw();
|
||||||
|
|
||||||
|
//status.c
|
||||||
|
void updateStatus();
|
||||||
|
void drawStatus();
|
||||||
|
|
||||||
|
#endif
|
|
@ -1 +1 @@
|
||||||
23e4c5e5e54051ba50828a644d9cec7f0c24d965
|
b7315d268ac28e2a67d8925acc46b6c0ada7c1c8
|
|
@ -94,6 +94,13 @@ void view1090InitConfig(void) {
|
||||||
Modes.screen_width = SCREEN_WIDTH;
|
Modes.screen_width = SCREEN_WIDTH;
|
||||||
Modes.screen_height = SCREEN_HEIGHT;
|
Modes.screen_height = SCREEN_HEIGHT;
|
||||||
Modes.screen_depth = 32;
|
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();
|
interactiveRemoveStaleAircrafts();
|
||||||
|
|
||||||
if (Modes.interactive) {
|
|
||||||
interactiveShowData();
|
|
||||||
}
|
|
||||||
|
|
||||||
draw();
|
draw();
|
||||||
|
|
||||||
if ((fd == ANET_ERR) || (recv(c->fd, pk_buf, sizeof(pk_buf), MSG_PEEK | MSG_DONTWAIT) == 0)) {
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
modesReadFromClient(c,"",decodeBinMessage);
|
modesReadFromClient(c,"",decodeBinMessage);
|
||||||
|
|
||||||
|
usleep(100000);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The user has stopped us, so close any socket we opened
|
// The user has stopped us, so close any socket we opened
|
||||||
|
|
20
sdl1090/view1090.dSYM/Contents/Info.plist
Normal file
20
sdl1090/view1090.dSYM/Contents/Info.plist
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleDevelopmentRegion</key>
|
||||||
|
<string>English</string>
|
||||||
|
<key>CFBundleIdentifier</key>
|
||||||
|
<string>com.apple.xcode.dsym.view1090</string>
|
||||||
|
<key>CFBundleInfoDictionaryVersion</key>
|
||||||
|
<string>6.0</string>
|
||||||
|
<key>CFBundlePackageType</key>
|
||||||
|
<string>dSYM</string>
|
||||||
|
<key>CFBundleSignature</key>
|
||||||
|
<string>????</string>
|
||||||
|
<key>CFBundleShortVersionString</key>
|
||||||
|
<string>1.0</string>
|
||||||
|
<key>CFBundleVersion</key>
|
||||||
|
<string>1</string>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
|
@ -0,0 +1 @@
|
||||||
|
8090a053ba2c7c31e5b2cfc5870918d933a99849
|
Loading…
Reference in a new issue