refactor in progress, builds currently

Former-commit-id: ad23161c72900be5a595ad004e133c67fa37df92
Former-commit-id: 284f7c0acd3b4322e33c215aa8a559c35f6daa65
This commit is contained in:
nathan 2020-03-07 20:28:55 -08:00
parent af9cfce3ff
commit 8b23d25dd1
8 changed files with 74 additions and 77 deletions

View file

@ -1,5 +1,6 @@
#include <stdint.h>
#include "defs.h"
#include "dump1090.h"
#include <ctime>
class Aircraft {

View file

@ -86,7 +86,7 @@ void AircraftData::update() {
interactiveRemoveStaleAircrafts(&modes);
aircraftList.update();
aircraftList.update(&modes);
}
AircraftData::AircraftData(){

View file

@ -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;

View file

@ -5,7 +5,7 @@ class AircraftList {
Aircraft *head;
Aircraft *find(uint32_t addr);
void update();
void update(Modes *modes);
AircraftList();
~AircraftList();

View file

@ -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);
}
p = p->next;
}
@ -868,7 +865,6 @@ 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;
@ -944,7 +940,6 @@ void View::drawPlanes() {
}
}
}
}
p = p->next;
}

2
View.h
View file

@ -34,6 +34,8 @@ public:
void draw();
View(AircraftData *aircraftData);
bool metric;
};
#endif

1
map1090.REMOVED.git-id Normal file
View file

@ -0,0 +1 @@
a18a4bc87ddef182cd7d61470daf952ae025186b

View file

@ -125,7 +125,6 @@ int main(int argc, char **argv) {
}
}
int go;
aircraftData.connect();