diff --git a/Aircraft.h b/Aircraft.h index 4eb0b5c..0877d42 100644 --- a/Aircraft.h +++ b/Aircraft.h @@ -1,5 +1,6 @@ #include #include "defs.h" +#include "dump1090.h" #include class Aircraft { diff --git a/AircraftData.cpp b/AircraftData.cpp index 3073b1d..d6a985e 100644 --- a/AircraftData.cpp +++ b/AircraftData.cpp @@ -86,7 +86,7 @@ void AircraftData::update() { interactiveRemoveStaleAircrafts(&modes); - aircraftList.update(); + aircraftList.update(&modes); } AircraftData::AircraftData(){ diff --git a/AircraftList.cpp b/AircraftList.cpp index 300e836..ff099cf 100644 --- a/AircraftList.cpp +++ b/AircraftList.cpp @@ -21,10 +21,9 @@ Aircraft *AircraftList::find(uint32_t addr) { return (NULL); } -void AircraftList::update -() { //instead of this, net_io should call this class directly to update info - struct aircraft *a = modes.aircrafts; +void AircraftList::update(Modes *modes) { + struct aircraft *a = modes->aircrafts; Aircraft *p = head; diff --git a/AircraftList.h b/AircraftList.h index 26dd452..36ce402 100644 --- a/AircraftList.h +++ b/AircraftList.h @@ -5,7 +5,7 @@ class AircraftList { Aircraft *head; Aircraft *find(uint32_t addr); - void update(); + void update(Modes *modes); AircraftList(); ~AircraftList(); diff --git a/View.cpp b/View.cpp index 156e65b..d1bb122 100644 --- a/View.cpp +++ b/View.cpp @@ -148,7 +148,7 @@ int View::screenDist(float d) { return round(0.95 * scale_factor * 0.5 * fabs(d) / appData.maxDist); } -void pxFromLonLat(float *dx, float *dy, float lon, float lat) { +void View::pxFromLonLat(float *dx, float *dy, float lon, float lat) { if(!lon || !lat) { *dx = 0; *dy = 0; @@ -391,7 +391,7 @@ void View::drawScaleBars() while(scaleBarDist < appData.screen_width) { lineRGBA(appData.renderer,10+scaleBarDist,8,10+scaleBarDist,16*appData.screen_uiscale,style.scaleBarColor.r, style.scaleBarColor.g, style.scaleBarColor.b, 255); - if (modes.metric) { + if (aircraftData->modes.metric) { snprintf(scaleLabel,13,"%dkm", (int)pow(10,scalePower)); } else { snprintf(scaleLabel,13,"%dmi", (int)pow(10,scalePower)); @@ -549,7 +549,7 @@ void View::drawPlaneText(Aircraft *p) { if(p->pressure * appData.screen_width < 0.2f) { char alt[10] = " "; - if (modes.metric) { + if (aircraftData->modes.metric) { currentCharCount = snprintf(alt,10," %dm", (int) (p->altitude / 3.2828)); } else { currentCharCount = snprintf(alt,10," %d'", p->altitude); @@ -565,7 +565,7 @@ void View::drawPlaneText(Aircraft *p) { } char speed[10] = " "; - if (modes.metric) { + if (aircraftData->modes.metric) { currentCharCount = snprintf(speed,10," %dkm/h", (int) (p->speed * 1.852)); } else { currentCharCount = snprintf(speed,10," %dmph", p->speed); @@ -627,7 +627,7 @@ void View::drawSelectedAircraftText(Aircraft *p) { } char alt[10] = " "; - if (modes.metric) { + if (aircraftData->modes.metric) { currentCharCount = snprintf(alt,10," %dm", (int) (p->altitude / 3.2828)); } else { currentCharCount = snprintf(alt,10," %d'", p->altitude); @@ -643,7 +643,7 @@ void View::drawSelectedAircraftText(Aircraft *p) { } char speed[10] = " "; - if (modes.metric) { + if (aircraftData->modes.metric) { currentCharCount = snprintf(speed,10," %dkm/h", (int) (p->speed * 1.852)); } else { currentCharCount = snprintf(speed,10," %dmph", p->speed); @@ -853,10 +853,7 @@ void View::drawPlanes() { // draw all trails first so they don't cover up planes and text // also find closest plane to selection point while(p) { - if ((now - p->seen) < modes.interactive_display_ttl) { - drawTrail(p->oldLon, p->oldLat, p->oldHeading, p->oldSeen, p->oldIdx); - } - + drawTrail(p->oldLon, p->oldLat, p->oldHeading, p->oldSeen, p->oldIdx); p = p->next; } @@ -868,80 +865,78 @@ void View::drawPlanes() { p = aircraftData->aircraftList.head; while(p) { - if ((now - p->seen) < modes.interactive_display_ttl) { - if (p->lon && p->lat) { - int x, y; + if (p->lon && p->lat) { + int x, y; - float dx, dy; - pxFromLonLat(&dx, &dy, p->lon, p->lat); - screenCoords(&x, &y, dx, dy); + float dx, dy; + pxFromLonLat(&dx, &dy, p->lon, p->lat); + screenCoords(&x, &y, dx, dy); - if(p->created == 0) { - p->created = mstime(); - } + if(p->created == 0) { + p->created = mstime(); + } - float age_ms = (float)(mstime() - p->created); - if(age_ms < 500) { - 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) { - int usex = x; - int usey = y; + float age_ms = (float)(mstime() - p->created); + if(age_ms < 500) { + 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) { + int usex = x; + int usey = y; - if(p->seenLatLon > p->oldSeen[p->oldIdx]) { - int oldx, oldy; - int idx = (p->oldIdx - 1) % TRAIL_LENGTH; + if(p->seenLatLon > p->oldSeen[p->oldIdx]) { + int oldx, oldy; + int idx = (p->oldIdx - 1) % TRAIL_LENGTH; - pxFromLonLat(&dx, &dy, p->oldLon[idx], p->oldLat[idx]); - screenCoords(&oldx, &oldy, dx, dy); + pxFromLonLat(&dx, &dy, p->oldLon[idx], p->oldLat[idx]); + screenCoords(&oldx, &oldy, dx, dy); - float velx = (x - oldx) / (1000.0 * (p->seenLatLon - p->oldSeen[idx])); - float vely = (y - oldy) / (1000.0 * (p->seenLatLon - p->oldSeen[idx])); + float velx = (x - oldx) / (1000.0 * (p->seenLatLon - p->oldSeen[idx])); + float vely = (y - oldy) / (1000.0 * (p->seenLatLon - p->oldSeen[idx])); - usex = x + (mstime() - p->msSeenLatLon) * velx; - usey = y + (mstime() - p->msSeenLatLon) * vely; - } + usex = x + (mstime() - p->msSeenLatLon) * velx; + usey = y + (mstime() - p->msSeenLatLon) * vely; + } - if(p == aircraftData->selectedAircraft) { - // this logic should be in input, register a callback for click? - float elapsed = mstime() - appData.touchDownTime; + if(p == aircraftData->selectedAircraft) { + // this logic should be in input, register a callback for click? + float elapsed = mstime() - appData.touchDownTime; - int boxSize; - if(elapsed < 300) { - boxSize = (int)(20.0 * (1.0 - (1.0 - elapsed / 300.0) * cos(sqrt(elapsed)))); - } else { - boxSize = 20; - } - //rectangleRGBA(appData.renderer, usex - boxSize, usey - boxSize, usex + boxSize, usey + boxSize, pink.r, pink.g, pink.b, 255); - lineRGBA(appData.renderer, usex - boxSize, usey - boxSize, usex - boxSize/2, usey - boxSize, pink.r, pink.g, pink.b, 255); - lineRGBA(appData.renderer, usex - boxSize, usey - boxSize, usex - boxSize, usey - boxSize/2, pink.r, pink.g, pink.b, 255); - - lineRGBA(appData.renderer, usex + boxSize, usey - boxSize, usex + boxSize/2, usey - boxSize, pink.r, pink.g, pink.b, 255); - lineRGBA(appData.renderer, usex + boxSize, usey - boxSize, usex + boxSize, usey - boxSize/2, pink.r, pink.g, pink.b, 255); - - lineRGBA(appData.renderer, usex + boxSize, usey + boxSize, usex + boxSize/2, usey + boxSize, pink.r, pink.g, pink.b, 255); - lineRGBA(appData.renderer, usex + boxSize, usey + boxSize, usex + boxSize, usey + boxSize/2, pink.r, pink.g, pink.b, 255); - - lineRGBA(appData.renderer, usex - boxSize, usey + boxSize, usex - boxSize/2, usey + boxSize, pink.r, pink.g, pink.b, 255); - lineRGBA(appData.renderer, usex - boxSize, usey + boxSize, usex - boxSize, usey + boxSize/2, pink.r, pink.g, pink.b, 255); - planeColor = lerpColor(style.selectedColor, style.planeGoneColor, (now - p->seen) / (float) DISPLAY_ACTIVE); + int boxSize; + if(elapsed < 300) { + boxSize = (int)(20.0 * (1.0 - (1.0 - elapsed / 300.0) * cos(sqrt(elapsed)))); } else { - planeColor = lerpColor(style.planeColor, style.planeGoneColor, (now - p->seen) / (float) DISPLAY_ACTIVE); + boxSize = 20; } + //rectangleRGBA(appData.renderer, usex - boxSize, usey - boxSize, usex + boxSize, usey + boxSize, pink.r, pink.g, pink.b, 255); + lineRGBA(appData.renderer, usex - boxSize, usey - boxSize, usex - boxSize/2, usey - boxSize, pink.r, pink.g, pink.b, 255); + lineRGBA(appData.renderer, usex - boxSize, usey - boxSize, usex - boxSize, usey - boxSize/2, pink.r, pink.g, pink.b, 255); - if(outOfBounds(x,y)) { - drawPlaneOffMap(x, y, &(p->cx), &(p->cy), planeColor); - } else { - drawPlaneIcon(usex, usey, p->track, planeColor); - p->cx = usex; - p->cy = usey; - } - - if(p != aircraftData->selectedAircraft) { - drawPlaneText(p); - } + lineRGBA(appData.renderer, usex + boxSize, usey - boxSize, usex + boxSize/2, usey - boxSize, pink.r, pink.g, pink.b, 255); + lineRGBA(appData.renderer, usex + boxSize, usey - boxSize, usex + boxSize, usey - boxSize/2, pink.r, pink.g, pink.b, 255); + lineRGBA(appData.renderer, usex + boxSize, usey + boxSize, usex + boxSize/2, usey + boxSize, pink.r, pink.g, pink.b, 255); + lineRGBA(appData.renderer, usex + boxSize, usey + boxSize, usex + boxSize, usey + boxSize/2, pink.r, pink.g, pink.b, 255); + + lineRGBA(appData.renderer, usex - boxSize, usey + boxSize, usex - boxSize/2, usey + boxSize, pink.r, pink.g, pink.b, 255); + lineRGBA(appData.renderer, usex - boxSize, usey + boxSize, usex - boxSize, usey + boxSize/2, pink.r, pink.g, pink.b, 255); + planeColor = lerpColor(style.selectedColor, style.planeGoneColor, (now - p->seen) / (float) DISPLAY_ACTIVE); + } else { + planeColor = lerpColor(style.planeColor, style.planeGoneColor, (now - p->seen) / (float) DISPLAY_ACTIVE); } + + if(outOfBounds(x,y)) { + drawPlaneOffMap(x, y, &(p->cx), &(p->cy), planeColor); + } else { + drawPlaneIcon(usex, usey, p->track, planeColor); + p->cx = usex; + p->cy = usey; + } + + if(p != aircraftData->selectedAircraft) { + drawPlaneText(p); + } + } } } diff --git a/View.h b/View.h index d924020..ee12b4e 100644 --- a/View.h +++ b/View.h @@ -34,6 +34,8 @@ public: void draw(); View(AircraftData *aircraftData); + + bool metric; }; #endif \ No newline at end of file diff --git a/map1090.REMOVED.git-id b/map1090.REMOVED.git-id new file mode 100644 index 0000000..5a4ef7c --- /dev/null +++ b/map1090.REMOVED.git-id @@ -0,0 +1 @@ +a18a4bc87ddef182cd7d61470daf952ae025186b \ No newline at end of file diff --git a/map1090.cpp b/map1090.cpp index e37c383..cd7c318 100644 --- a/map1090.cpp +++ b/map1090.cpp @@ -124,8 +124,7 @@ int main(int argc, char **argv) { exit(1); } } - - + int go; aircraftData.connect();