new signal markings, new timing numbers for LatLon reception (doesn't seem to be working on dump1090 end though), basic plane velocity animation
Former-commit-id: 0fead3636422b4fcc2bc0dee8a30a137de50d69b Former-commit-id: b6345e37645d23a82edbb99859c51c1ff207a5c9
This commit is contained in:
parent
d630b24033
commit
df727c8d04
78
draw.c
78
draw.c
|
@ -250,7 +250,7 @@ void drawTrail(double *oldDx, double *oldDy, double *oldHeading, time_t * oldSee
|
||||||
|
|
||||||
uint8_t colorVal = (uint8_t)floor(255.0 * age);
|
uint8_t colorVal = (uint8_t)floor(255.0 * age);
|
||||||
|
|
||||||
thickLineRGBA(appData.renderer, prevX, prevY, currentX, currentY, 4 * appData.screen_uiscale, colorVal, colorVal, colorVal, 127);
|
//thickLineRGBA(appData.renderer, prevX, prevY, currentX, currentY, 4 * appData.screen_uiscale, colorVal, colorVal, colorVal, 127);
|
||||||
|
|
||||||
//tick marks
|
//tick marks
|
||||||
|
|
||||||
|
@ -268,7 +268,7 @@ void drawTrail(double *oldDx, double *oldDy, double *oldHeading, time_t * oldSee
|
||||||
|
|
||||||
int x1, y1, x2, y2;
|
int x1, y1, x2, y2;
|
||||||
|
|
||||||
int cross_size = 8 * appData.screen_uiscale;
|
int cross_size = 5 * appData.screen_uiscale;
|
||||||
|
|
||||||
//forward cross
|
//forward cross
|
||||||
x1 = currentX + round(-cross_size*vec[0]);
|
x1 = currentX + round(-cross_size*vec[0]);
|
||||||
|
@ -351,6 +351,7 @@ void drawGeography() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawPlaneText(struct planeObj *p, int x, int y) {
|
void drawPlaneText(struct planeObj *p, int x, int y) {
|
||||||
|
|
||||||
drawStringBG(p->flight, x + 5, y + appData.mapFontHeight, appData.mapBoldFont, white, black);
|
drawStringBG(p->flight, x + 5, y + appData.mapFontHeight, appData.mapBoldFont, white, black);
|
||||||
|
|
||||||
char alt[10] = " ";
|
char alt[10] = " ";
|
||||||
|
@ -370,39 +371,59 @@ void drawPlaneText(struct planeObj *p, int x, int y) {
|
||||||
drawStringBG(speed, x + 5, y + 3*appData.mapFontHeight, appData.mapFont, grey, black);
|
drawStringBG(speed, x + 5, y + 3*appData.mapFontHeight, appData.mapFont, grey, black);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void drawSignalMarks(struct planeObj *p, int x, int y) {
|
||||||
|
unsigned char * pSig = p->signalLevel;
|
||||||
|
unsigned int signalAverage = (pSig[0] + pSig[1] + pSig[2] + pSig[3] +
|
||||||
|
pSig[4] + pSig[5] + pSig[6] + pSig[7] + 3) >> 3;
|
||||||
|
|
||||||
|
SDL_Color barColor = signalToColor(signalAverage);
|
||||||
|
|
||||||
|
Uint8 seenFade = (Uint8) (255.0 - (mstime() - p->msSeen) / 4.0);
|
||||||
|
|
||||||
|
circleRGBA(appData.renderer, x + 5 * appData.screen_uiscale, y + 10 * appData.screen_uiscale, 2 * appData.screen_uiscale, barColor.r, barColor.g, barColor.b, seenFade);
|
||||||
|
|
||||||
|
seenFade = (Uint8) (255.0 - (mstime() - p->msSeenLatLon) / 4.0);
|
||||||
|
|
||||||
|
hlineRGBA(appData.renderer, x + 10 * appData.screen_uiscale, x + 14 * appData.screen_uiscale, y + 10 * appData.screen_uiscale, barColor.r, barColor.g, barColor.b, seenFade);
|
||||||
|
vlineRGBA(appData.renderer, x + 12 * appData.screen_uiscale, y + 8 * appData.screen_uiscale, y + 12 * appData.screen_uiscale, barColor.r, barColor.g, barColor.b, seenFade);
|
||||||
|
}
|
||||||
|
|
||||||
void drawMap() {
|
void drawMap() {
|
||||||
struct planeObj *p = planes;
|
struct planeObj *p = planes;
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
|
SDL_Color planeColor;
|
||||||
drawGeography();
|
drawGeography();
|
||||||
|
|
||||||
drawGrid();
|
drawGrid();
|
||||||
|
|
||||||
|
//draw all trails first so they don't cover up planes and text
|
||||||
|
|
||||||
|
while(p) {
|
||||||
|
if ((now - p->seen) < Modes.interactive_display_ttl) {
|
||||||
|
drawTrail(p->oldLon, p->oldLat, p->oldHeading, p->oldSeen, p->oldIdx);
|
||||||
|
}
|
||||||
|
p = p->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
p = planes;
|
||||||
|
|
||||||
while(p) {
|
while(p) {
|
||||||
if ((now - p->seen) < Modes.interactive_display_ttl) {
|
if ((now - p->seen) < Modes.interactive_display_ttl) {
|
||||||
if (p->lon && p->lat) {
|
if (p->lon && p->lat) {
|
||||||
|
|
||||||
unsigned char * pSig = p->signalLevel;
|
|
||||||
unsigned int signalAverage = (pSig[0] + pSig[1] + pSig[2] + pSig[3] +
|
|
||||||
pSig[4] + pSig[5] + pSig[6] + pSig[7] + 3) >> 3;
|
|
||||||
|
|
||||||
drawTrail(p->oldLon, p->oldLat, p->oldHeading, p->oldSeen, p->oldIdx);
|
|
||||||
|
|
||||||
int colorIdx;
|
|
||||||
if((int)(now - p->seen) > DISPLAY_ACTIVE) {
|
|
||||||
colorIdx = -1;
|
|
||||||
} else {
|
|
||||||
colorIdx = signalAverage;
|
|
||||||
}
|
|
||||||
|
|
||||||
SDL_Color planeColor = signalToColor(colorIdx);
|
|
||||||
int x, y;
|
int x, y;
|
||||||
//screenCoords(&x, &y, p->dx, p->dy);
|
|
||||||
|
|
||||||
double dx, dy;
|
double dx, dy;
|
||||||
pxFromLonLat(&dx, &dy, p->lon, p->lat);
|
pxFromLonLat(&dx, &dy, p->lon, p->lat);
|
||||||
screenCoords(&x, &y, dx, dy);
|
screenCoords(&x, &y, dx, dy);
|
||||||
|
|
||||||
|
if((int)(now - p->seen) > DISPLAY_ACTIVE) {
|
||||||
|
planeColor = grey;
|
||||||
|
} else {
|
||||||
|
planeColor = white;
|
||||||
|
}
|
||||||
|
|
||||||
if(outOfBounds(x,y)) {
|
if(outOfBounds(x,y)) {
|
||||||
int outx, outy;
|
int outx, outy;
|
||||||
drawPlaneOffMap(x, y, &outx, &outy, planeColor);
|
drawPlaneOffMap(x, y, &outx, &outy, planeColor);
|
||||||
|
@ -419,11 +440,28 @@ void drawMap() {
|
||||||
circleRGBA(appData.renderer, x, y, 500 - age_ms, 255,255, 255, (uint8_t)(255.0 * age_ms / 500.0));
|
circleRGBA(appData.renderer, x, y, 500 - age_ms, 255,255, 255, (uint8_t)(255.0 * age_ms / 500.0));
|
||||||
} else {
|
} else {
|
||||||
if(MODES_ACFLAGS_HEADING_VALID) {
|
if(MODES_ACFLAGS_HEADING_VALID) {
|
||||||
drawPlaneHeading(x, y,p->track, planeColor);
|
int usex = x;
|
||||||
|
int usey = y;
|
||||||
|
|
||||||
drawPlaneText(p, x, y);
|
if(p->seenLatLon > p->oldSeen[p->oldIdx]) {
|
||||||
|
int oldx, oldy;
|
||||||
|
int idx = (p->oldIdx - 1) % TRAIL_LENGTH;
|
||||||
|
|
||||||
lineRGBA(appData.renderer, x, y, x, y + 4*appData.mapFontHeight, grey.r, grey.g, grey.b, SDL_ALPHA_OPAQUE);
|
pxFromLonLat(&dx, &dy, p->oldLon[idx], p->oldLat[idx]);
|
||||||
|
screenCoords(&oldx, &oldy, dx, dy);
|
||||||
|
|
||||||
|
double velx = (x - oldx) / (1000.0 * (p->seenLatLon - p->oldSeen[idx]));
|
||||||
|
double vely = (y - oldy) / (1000.0 * (p->seenLatLon - p->oldSeen[idx]));
|
||||||
|
|
||||||
|
usex = x + (mstime() - p->msSeenLatLon) * velx;
|
||||||
|
usey = y + (mstime() - p->msSeenLatLon) * vely;
|
||||||
|
}
|
||||||
|
|
||||||
|
drawPlaneHeading(usex, usey, p->track, planeColor);
|
||||||
|
drawSignalMarks(p, usex, usey);
|
||||||
|
drawPlaneText(p, usex, usey);
|
||||||
|
lineRGBA(appData.renderer, usex, usey, usex, usey + 4*appData.mapFontHeight, grey.r, grey.g, grey.b, SDL_ALPHA_OPAQUE);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
drawPlane(x, y, planeColor);
|
drawPlane(x, y, planeColor);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
fda1ba88522832395454de10738083bda8677b29
|
3329d96b9e8da09d38ac06e8cfcb2c9227d0593e
|
|
@ -1 +1 @@
|
||||||
ec05e242afe12d9af07fceff41a9689f66237a76
|
2c4ed2ab46ef6a542479d8c3c9ea7de7298325c1
|
25
planeObj.c
25
planeObj.c
|
@ -1,6 +1,16 @@
|
||||||
#include "structs.h"
|
#include "structs.h"
|
||||||
#include "dump1090.h"
|
#include "dump1090.h"
|
||||||
|
|
||||||
|
static uint64_t mstime(void) {
|
||||||
|
struct timeval tv;
|
||||||
|
uint64_t mst;
|
||||||
|
|
||||||
|
gettimeofday(&tv, NULL);
|
||||||
|
mst = ((uint64_t)tv.tv_sec)*1000;
|
||||||
|
mst += tv.tv_usec/1000;
|
||||||
|
return mst;
|
||||||
|
}
|
||||||
|
|
||||||
struct planeObj *findPlaneObj(uint32_t addr) {
|
struct planeObj *findPlaneObj(uint32_t addr) {
|
||||||
struct planeObj *p = planes;
|
struct planeObj *p = planes;
|
||||||
|
|
||||||
|
@ -57,12 +67,12 @@ void updatePlanes() {
|
||||||
}
|
}
|
||||||
|
|
||||||
p->seen = a->seen;
|
p->seen = a->seen;
|
||||||
|
p->msSeen = mstime();
|
||||||
|
|
||||||
if((p->seen - p->prev_seen) > 0) {
|
if((p->seen - p->prev_seen) > 0) {
|
||||||
p->messageRate = 1.0 / (double)(p->seen - p->prev_seen);
|
p->messageRate = 1.0 / (double)(p->seen - p->prev_seen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
memcpy(p->flight, a->flight, sizeof(p->flight));
|
memcpy(p->flight, a->flight, sizeof(p->flight));
|
||||||
memcpy(p->signalLevel, a->signalLevel, sizeof(p->signalLevel));
|
memcpy(p->signalLevel, a->signalLevel, sizeof(p->signalLevel));
|
||||||
|
|
||||||
|
@ -70,11 +80,12 @@ void updatePlanes() {
|
||||||
p->speed = a->speed;
|
p->speed = a->speed;
|
||||||
p->track = a->track;
|
p->track = a->track;
|
||||||
p->vert_rate = a->vert_rate;
|
p->vert_rate = a->vert_rate;
|
||||||
p->lon = a->lon;
|
p->lon = a->lon;
|
||||||
p->lat = a->lat;
|
p->lat = a->lat;
|
||||||
|
|
||||||
if(time(NULL) - p->oldSeen[p->oldIdx] > TRAIL_TTL_STEP) {
|
|
||||||
|
|
||||||
|
if(p->seenLatLon < a->seenLatLon) {
|
||||||
|
p->msSeenLatLon = mstime();
|
||||||
|
|
||||||
p->oldIdx = (p->oldIdx+1) % 32;
|
p->oldIdx = (p->oldIdx+1) % 32;
|
||||||
|
|
||||||
p->oldLon[p->oldIdx] = p->lon;
|
p->oldLon[p->oldIdx] = p->lon;
|
||||||
|
@ -82,8 +93,10 @@ void updatePlanes() {
|
||||||
|
|
||||||
p->oldHeading[p->oldIdx] = p->track;
|
p->oldHeading[p->oldIdx] = p->track;
|
||||||
|
|
||||||
p->oldSeen[p->oldIdx] = p->seen;
|
p->oldSeen[p->oldIdx] = p->seenLatLon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p->seenLatLon = a->seenLatLon;
|
||||||
|
|
||||||
a = a->next;
|
a = a->next;
|
||||||
}
|
}
|
||||||
|
|
BIN
planeObj.o
BIN
planeObj.o
Binary file not shown.
|
@ -1 +1 @@
|
||||||
7626e2885663816ca0afea4b99f4464dbaa595f7
|
e28b70359d329c69b61d0da196a74552ba4f6f8f
|
|
@ -56,6 +56,7 @@ struct planeObj {
|
||||||
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 seenLatLon; // Time at which the last packet was received
|
||||||
time_t prev_seen;
|
time_t prev_seen;
|
||||||
double lat, lon; // Coordinated obtained from CPR encoded data
|
double lat, lon; // Coordinated obtained from CPR encoded data
|
||||||
|
|
||||||
|
@ -66,6 +67,8 @@ struct planeObj {
|
||||||
time_t oldSeen[TRAIL_LENGTH];
|
time_t oldSeen[TRAIL_LENGTH];
|
||||||
uint8_t oldIdx;
|
uint8_t oldIdx;
|
||||||
uint64_t created;
|
uint64_t created;
|
||||||
|
uint64_t msSeen;
|
||||||
|
uint64_t msSeenLatLon;
|
||||||
int live;
|
int live;
|
||||||
|
|
||||||
struct planeObj *next; // Next aircraft in our linked list
|
struct planeObj *next; // Next aircraft in our linked list
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
68fb7031fcec17eff186d2abd88b6bf9f0726707
|
ae65e041076e061971bc7b3d686bee6c5f471abd
|
|
@ -1 +1 @@
|
||||||
56d4666551743e2bb5da41ccce658ff2be58cdf2
|
566004a350fc256a0bc6ab112a14b09c91e6cc18
|
Loading…
Reference in a new issue