diff --git a/draw.c b/draw.c index aabdba7..564296b 100644 --- a/draw.c +++ b/draw.c @@ -350,6 +350,26 @@ 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] = " "; + if (Modes.metric) { + snprintf(alt,10,"%dm", (int) (p->altitude / 3.2828)); + } else { + snprintf(alt,10,"%d'", p->altitude); + } + drawStringBG(alt, x + 5, y + 2*appData.mapFontHeight, appData.mapFont, grey, black); + + char speed[10] = " "; + if (Modes.metric) { + snprintf(speed,10,"%dkm/h", (int) (p->speed * 1.852)); + } else { + snprintf(speed,10,"%dmph", p->speed); + } + drawStringBG(speed, x + 5, y + 3*appData.mapFontHeight, appData.mapFont, grey, black); +} + void drawMap() { struct planeObj *p = planes; time_t now = time(NULL); @@ -386,18 +406,7 @@ void drawMap() { if(outOfBounds(x,y)) { int outx, outy; drawPlaneOffMap(x, y, &outx, &outy, planeColor); - - drawStringBG(p->flight, outx + 5, outy + appData.mapFontHeight, appData.mapBoldFont, white, black); - - char alt[10] = " "; - snprintf(alt,10,"%dm", p->altitude); - drawStringBG(alt, outx + 5, outy + 2*appData.mapFontHeight, appData.mapFont, grey, black); - - char speed[10] = " "; - snprintf(speed,10,"%dkm/h", p->speed); - drawStringBG(speed, outx + 5, outy + 3*appData.mapFontHeight, appData.mapFont, grey, black); - - // continue; + drawPlaneText(p, outx, outy); } @@ -412,18 +421,7 @@ void drawMap() { if(MODES_ACFLAGS_HEADING_VALID) { drawPlaneHeading(x, y,p->track, planeColor); - //char flight[11] = " "; - //snprintf(flight,11," %s ", p->flight); - //drawStringBG(flight, x, y + appData.mapFontHeight, appData.mapBoldFont, black, planeColor); - drawStringBG(p->flight, x + 5, y + appData.mapFontHeight, appData.mapBoldFont, white, black); - - char alt[10] = " "; - snprintf(alt,10,"%dm", p->altitude); - drawStringBG(alt, x + 5, y + 2*appData.mapFontHeight, appData.mapFont, grey, black); - - char speed[10] = " "; - snprintf(speed,10,"%dkm/h", p->speed); - drawStringBG(speed, x + 5, y + 3*appData.mapFontHeight, appData.mapFont, grey, black); + drawPlaneText(p, x, y); lineRGBA(appData.renderer, x, y, x, y + 4*appData.mapFontHeight, grey.r, grey.g, grey.b, SDL_ALPHA_OPAQUE); } else { diff --git a/draw.o.REMOVED.git-id b/draw.o.REMOVED.git-id index 901f5ae..001c031 100644 --- a/draw.o.REMOVED.git-id +++ b/draw.o.REMOVED.git-id @@ -1 +1 @@ -935a39fc34ea31bd03a177786917177c0d74191a \ No newline at end of file +fda1ba88522832395454de10738083bda8677b29 \ No newline at end of file diff --git a/font.o b/font.o index 3132bb4..55e9ba8 100644 Binary files a/font.o and b/font.o differ diff --git a/init.o b/init.o index fe767d7..8b08a1a 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 c590db3..b448a08 100644 --- a/input.o.REMOVED.git-id +++ b/input.o.REMOVED.git-id @@ -1 +1 @@ -a9f8d1424252b1371bb410c58e63a5ec55a7fcb3 \ No newline at end of file +ec05e242afe12d9af07fceff41a9689f66237a76 \ No newline at end of file diff --git a/list.c b/list.c index d86cc76..839fc6d 100644 --- a/list.c +++ b/list.c @@ -112,7 +112,7 @@ void drawList(int top) { } } - snprintf(strDir,3,"%c%c",cLat,cLon); + //snprintf(strDir,3,"%c%c",cLat,cLon); //distance is borked during refactor diff --git a/list.o b/list.o index 8005c6e..a96d73c 100644 Binary files a/list.o and b/list.o differ diff --git a/monokai.o b/monokai.o index 11cca75..529c746 100644 Binary files a/monokai.o and b/monokai.o differ diff --git a/planeObj.c b/planeObj.c index 958baf5..c8f518c 100644 --- a/planeObj.c +++ b/planeObj.c @@ -19,11 +19,11 @@ struct planeObj *createPlaneObj(struct aircraft *a) { p->addr = a->addr; p->created = 0; p->oldIdx = 0; + p->prev_seen = 0; memset(p->oldLon, 0, sizeof(p->oldLon)); memset(p->oldLat, 0, sizeof(p->oldLat)); memset(p->oldHeading, 0, sizeof(p->oldHeading)); - memset(p->messageRate, 0, sizeof(p->messageRate)); return (p); } @@ -45,6 +45,8 @@ void updatePlanes() { p = createPlaneObj(a); p->next = planes; planes = p; + } else { + p->prev_seen = p->seen; } p->live = 1; @@ -53,7 +55,14 @@ void updatePlanes() { a = a->next; continue; } - + + p->seen = a->seen; + + 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)); @@ -61,7 +70,6 @@ void updatePlanes() { p->speed = a->speed; p->track = a->track; p->vert_rate = a->vert_rate; - p->seen = a->seen; p->lon = a->lon; p->lat = a->lat; diff --git a/planeObj.o b/planeObj.o index b23c413..0b63cf4 100644 Binary files a/planeObj.o and b/planeObj.o differ diff --git a/status.c b/status.c index 0609655..f9e09bb 100644 --- a/status.c +++ b/status.c @@ -64,27 +64,27 @@ void updateStatus() { pSig[4] + pSig[5] + pSig[6] + pSig[7]); sigAccumulate += signalAverage; - - - //distance measurements got borked during refactor - need to redo here - /* + 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++; - msgRateAccumulate += (p->messageRate[0] + p->messageRate[1] + p->messageRate[2] + p->messageRate[3] + - p->messageRate[4] + p->messageRate[5] + p->messageRate[6] + p->messageRate[7]); + msgRateAccumulate += p->messageRate; p = p->next; } diff --git a/status.o.REMOVED.git-id b/status.o.REMOVED.git-id index 301bdea..f8fd904 100644 --- a/status.o.REMOVED.git-id +++ b/status.o.REMOVED.git-id @@ -1 +1 @@ -73f15d7f49718ad2118fa30449dffa3f088a20bd \ No newline at end of file +7626e2885663816ca0afea4b99f4464dbaa595f7 \ No newline at end of file diff --git a/structs.h b/structs.h index 9791424..2f3be7f 100644 --- a/structs.h +++ b/structs.h @@ -50,12 +50,13 @@ struct planeObj { uint32_t addr; // ICAO address char flight[16]; // Flight number unsigned char signalLevel[8]; // Last 8 Signal Amplitudes - double messageRate[8]; + double messageRate; int altitude; // Altitude int speed; // Velocity 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; double lat, lon; // Coordinated obtained from CPR encoded data //history diff --git a/view1090.REMOVED.git-id b/view1090.REMOVED.git-id index a619b91..f0478ea 100644 --- a/view1090.REMOVED.git-id +++ b/view1090.REMOVED.git-id @@ -1 +1 @@ -cc7b8e99972e34a43bebde90a9679815d2219511 \ No newline at end of file +68fb7031fcec17eff186d2abd88b6bf9f0726707 \ No newline at end of file diff --git a/view1090.o.REMOVED.git-id b/view1090.o.REMOVED.git-id index 743b1f9..66035d0 100644 --- a/view1090.o.REMOVED.git-id +++ b/view1090.o.REMOVED.git-id @@ -1 +1 @@ -6a3d6fb29439db4b118b48c859c390d687566a2d \ No newline at end of file +56d4666551743e2bb5da41ccce658ff2be58cdf2 \ No newline at end of file