diff --git a/draw.c b/draw.c index 564296b..889f381 100644 --- a/draw.c +++ b/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); - 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 @@ -268,7 +268,7 @@ void drawTrail(double *oldDx, double *oldDy, double *oldHeading, time_t * oldSee int x1, y1, x2, y2; - int cross_size = 8 * appData.screen_uiscale; + int cross_size = 5 * appData.screen_uiscale; //forward cross x1 = currentX + round(-cross_size*vec[0]); @@ -351,6 +351,7 @@ void drawGeography() { } void drawPlaneText(struct planeObj *p, int x, int y) { + drawStringBG(p->flight, x + 5, y + appData.mapFontHeight, appData.mapBoldFont, white, black); 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); } +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() { struct planeObj *p = planes; time_t now = time(NULL); - + SDL_Color planeColor; drawGeography(); 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) { if ((now - p->seen) < Modes.interactive_display_ttl) { 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; - //screenCoords(&x, &y, p->dx, p->dy); double dx, dy; pxFromLonLat(&dx, &dy, p->lon, p->lat); screenCoords(&x, &y, dx, dy); + if((int)(now - p->seen) > DISPLAY_ACTIVE) { + planeColor = grey; + } else { + planeColor = white; + } + if(outOfBounds(x,y)) { int outx, outy; 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)); } else { 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 { drawPlane(x, y, planeColor); } diff --git a/draw.o.REMOVED.git-id b/draw.o.REMOVED.git-id index 001c031..d84e7d7 100644 --- a/draw.o.REMOVED.git-id +++ b/draw.o.REMOVED.git-id @@ -1 +1 @@ -fda1ba88522832395454de10738083bda8677b29 \ No newline at end of file +3329d96b9e8da09d38ac06e8cfcb2c9227d0593e \ No newline at end of file diff --git a/font.o b/font.o index 55e9ba8..eb8e2e3 100644 Binary files a/font.o and b/font.o differ diff --git a/init.o b/init.o index 8b08a1a..824f2eb 100644 Binary files a/init.o and b/init.o differ diff --git a/input.o.REMOVED.git-id b/input.o.REMOVED.git-id index b448a08..a79dc82 100644 --- a/input.o.REMOVED.git-id +++ b/input.o.REMOVED.git-id @@ -1 +1 @@ -ec05e242afe12d9af07fceff41a9689f66237a76 \ No newline at end of file +2c4ed2ab46ef6a542479d8c3c9ea7de7298325c1 \ No newline at end of file diff --git a/list.o b/list.o index a96d73c..e3a4518 100644 Binary files a/list.o and b/list.o differ diff --git a/monokai.o b/monokai.o index 529c746..2a29f32 100644 Binary files a/monokai.o and b/monokai.o differ diff --git a/planeObj.c b/planeObj.c index c8f518c..6380a15 100644 --- a/planeObj.c +++ b/planeObj.c @@ -1,6 +1,16 @@ #include "structs.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 *p = planes; @@ -57,12 +67,12 @@ void updatePlanes() { } p->seen = a->seen; + p->msSeen = mstime(); if((p->seen - p->prev_seen) > 0) { p->messageRate = 1.0 / (double)(p->seen - p->prev_seen); } - memcpy(p->flight, a->flight, sizeof(p->flight)); memcpy(p->signalLevel, a->signalLevel, sizeof(p->signalLevel)); @@ -70,11 +80,12 @@ void updatePlanes() { p->speed = a->speed; p->track = a->track; p->vert_rate = a->vert_rate; - p->lon = a->lon; - p->lat = a->lat; - - if(time(NULL) - p->oldSeen[p->oldIdx] > TRAIL_TTL_STEP) { + p->lon = a->lon; + p->lat = a->lat; + if(p->seenLatLon < a->seenLatLon) { + p->msSeenLatLon = mstime(); + p->oldIdx = (p->oldIdx+1) % 32; p->oldLon[p->oldIdx] = p->lon; @@ -82,8 +93,10 @@ void updatePlanes() { 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; } diff --git a/planeObj.o b/planeObj.o index 0b63cf4..56be23f 100644 Binary files a/planeObj.o and b/planeObj.o differ diff --git a/status.o.REMOVED.git-id b/status.o.REMOVED.git-id index f8fd904..ca6393a 100644 --- a/status.o.REMOVED.git-id +++ b/status.o.REMOVED.git-id @@ -1 +1 @@ -7626e2885663816ca0afea4b99f4464dbaa595f7 \ No newline at end of file +e28b70359d329c69b61d0da196a74552ba4f6f8f \ No newline at end of file diff --git a/structs.h b/structs.h index 2f3be7f..93da617 100644 --- a/structs.h +++ b/structs.h @@ -56,6 +56,7 @@ struct planeObj { int track; // Angle of flight int vert_rate; // Vertical rate. 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; double lat, lon; // Coordinated obtained from CPR encoded data @@ -66,6 +67,8 @@ struct planeObj { time_t oldSeen[TRAIL_LENGTH]; uint8_t oldIdx; uint64_t created; + uint64_t msSeen; + uint64_t msSeenLatLon; int live; struct planeObj *next; // Next aircraft in our linked list diff --git a/view1090.REMOVED.git-id b/view1090.REMOVED.git-id index f0478ea..d5f630d 100644 --- a/view1090.REMOVED.git-id +++ b/view1090.REMOVED.git-id @@ -1 +1 @@ -68fb7031fcec17eff186d2abd88b6bf9f0726707 \ No newline at end of file +ae65e041076e061971bc7b3d686bee6c5f471abd \ No newline at end of file diff --git a/view1090.o.REMOVED.git-id b/view1090.o.REMOVED.git-id index 66035d0..75ee653 100644 --- a/view1090.o.REMOVED.git-id +++ b/view1090.o.REMOVED.git-id @@ -1 +1 @@ -56d4666551743e2bb5da41ccce658ff2be58cdf2 \ No newline at end of file +566004a350fc256a0bc6ab112a14b09c91e6cc18 \ No newline at end of file