Compare commits
18 commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
0467c09598 | ||
![]() |
90bf09b331 | ||
![]() |
71d9546124 | ||
![]() |
8c3ab912f6 | ||
![]() |
0440a5c393 | ||
![]() |
c80f55141c | ||
![]() |
49fcc50a1d | ||
![]() |
26a6f001c9 | ||
![]() |
2179ca7810 | ||
![]() |
cd80aec3ab | ||
![]() |
4bcaa46c4e | ||
![]() |
a003086fb2 | ||
![]() |
cf422f480d | ||
![]() |
66385a328f | ||
![]() |
03fd9ec4df | ||
![]() |
e6e372c019 | ||
![]() |
b7b5b69914 | ||
![]() |
472aa85cb7 |
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -25,5 +25,3 @@ mapnames
|
|||
|
||||
|
||||
viz1090
|
||||
|
||||
result
|
||||
|
|
18
Aircraft.cpp
18
Aircraft.cpp
|
@ -32,6 +32,24 @@
|
|||
#include "Aircraft.h"
|
||||
#include "AircraftLabel.h"
|
||||
|
||||
float Aircraft::getLastLon() {
|
||||
if(lonHistory.size() > 1) {
|
||||
return lonHistory.end()[-2];
|
||||
}
|
||||
}
|
||||
|
||||
float Aircraft::getLastLat() {
|
||||
if(latHistory.size() > 1) {
|
||||
return latHistory.end()[-2];
|
||||
}
|
||||
}
|
||||
|
||||
float Aircraft::getLastHeading() {
|
||||
if(headingHistory.size() > 1) {
|
||||
return headingHistory.end()[-2];
|
||||
}
|
||||
}
|
||||
|
||||
Aircraft::Aircraft(uint32_t addr) {
|
||||
this->addr = addr;
|
||||
prev_seen = 0;
|
||||
|
|
|
@ -39,6 +39,12 @@ class AircraftLabel;
|
|||
|
||||
class Aircraft {
|
||||
public:
|
||||
float getLastLon();
|
||||
float getLastLat();
|
||||
float getLastHeading();
|
||||
|
||||
|
||||
|
||||
uint32_t addr; // ICAO address
|
||||
char flight[16]; // Flight number
|
||||
unsigned char signalLevel[8]; // Last 8 Signal Amplitudes
|
||||
|
|
|
@ -132,20 +132,20 @@ float AircraftLabel::calculateDensity(Aircraft *check_p, int labelLevel) {
|
|||
}
|
||||
|
||||
void AircraftLabel::calculateForces(Aircraft *check_p) {
|
||||
if(w == 0 || h == 0) {
|
||||
return;
|
||||
}
|
||||
//if(w == 0 || h == 0) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
Aircraft *head = check_p;
|
||||
|
||||
int p_left = x;
|
||||
int p_right = x + w;
|
||||
int p_top = y;
|
||||
int p_bottom = y + h;
|
||||
float p_left = static_cast<float>(x);
|
||||
float p_right = static_cast<float>(x + w);
|
||||
float p_top = static_cast<float>(y);
|
||||
float p_bottom = static_cast<float>(y + h);
|
||||
|
||||
|
||||
float boxmid_x = static_cast<float>(p_left + p_right) / 2.0f;
|
||||
float boxmid_y = static_cast<float>(p_top + p_bottom) / 2.0f;
|
||||
float boxmid_x = (p_left + p_right) / 2.0f;
|
||||
float boxmid_y = (p_top + p_bottom) / 2.0f;
|
||||
|
||||
float offset_x = boxmid_x - p->x;
|
||||
float offset_y = boxmid_y - p->y;
|
||||
|
@ -162,19 +162,19 @@ void AircraftLabel::calculateForces(Aircraft *check_p) {
|
|||
// screen edge
|
||||
|
||||
if(p_left < edge_margin) {
|
||||
ddx += boundary_force * static_cast<float>(edge_margin - p_left);
|
||||
ddx += boundary_force * (edge_margin - p_left);
|
||||
}
|
||||
|
||||
if(p_right > screen_width - edge_margin) {
|
||||
ddx += boundary_force * static_cast<float>(screen_width - edge_margin - p_right);
|
||||
ddx += boundary_force * (screen_width - edge_margin - p_right);
|
||||
}
|
||||
|
||||
if(p_top < edge_margin) {
|
||||
ddy += boundary_force * static_cast<float>(edge_margin - p_top);
|
||||
ddy += boundary_force * (edge_margin - p_top);
|
||||
}
|
||||
|
||||
if(p_bottom > screen_height - edge_margin) {
|
||||
ddy += boundary_force * static_cast<float>(screen_height - edge_margin - p_bottom);
|
||||
ddy += boundary_force * (screen_height - edge_margin - p_bottom);
|
||||
}
|
||||
|
||||
|
||||
|
@ -194,10 +194,10 @@ void AircraftLabel::calculateForces(Aircraft *check_p) {
|
|||
continue;
|
||||
}
|
||||
|
||||
int check_left = check_p->label->x;
|
||||
int check_right = check_p->label->x + check_p->label->w;
|
||||
int check_top = check_p->label->y;
|
||||
int check_bottom = check_p->label->y + check_p->label->h;
|
||||
float check_left = static_cast<float>(check_p->label->x);
|
||||
float check_right = static_cast<float>(check_p->label->x + check_p->label->w);
|
||||
float check_top = static_cast<float>(check_p->label->y);
|
||||
float check_bottom = static_cast<float>(check_p->label->y + check_p->label->h);
|
||||
|
||||
float icon_x = static_cast<float>(check_p->x);
|
||||
float icon_y = static_cast<float>(check_p->y);
|
||||
|
@ -205,6 +205,7 @@ void AircraftLabel::calculateForces(Aircraft *check_p) {
|
|||
float checkboxmid_x = static_cast<float>(check_left + check_right) / 2.0f;
|
||||
float checkboxmid_y = static_cast<float>(check_top + check_bottom) / 2.0f;
|
||||
|
||||
/*
|
||||
float offset_x = boxmid_x - checkboxmid_x;
|
||||
float offset_y = boxmid_y - checkboxmid_y;
|
||||
|
||||
|
@ -214,15 +215,82 @@ void AircraftLabel::calculateForces(Aircraft *check_p) {
|
|||
float x_mag = std::max(0.0f,(target_length_x - fabs(offset_x)));
|
||||
float y_mag = std::max(0.0f,(target_length_y - fabs(offset_y)));
|
||||
|
||||
*/
|
||||
|
||||
bool overlap = true;
|
||||
|
||||
if (p_left >= check_right + 10 || check_left >= p_right + 10)
|
||||
overlap = false;
|
||||
|
||||
if (p_top >= check_bottom + 10|| check_top >= p_bottom + 10)
|
||||
overlap = false;
|
||||
|
||||
if(overlap) {
|
||||
|
||||
float td = fabs(p_top - check_bottom);
|
||||
float bd = fabs(p_bottom - check_top);
|
||||
float ld = fabs(p_left - check_right);
|
||||
float rd = fabs(p_right - check_left);
|
||||
|
||||
float x_mag, y_mag;
|
||||
|
||||
if(boxmid_y > checkboxmid_y) {
|
||||
y_mag = check_bottom - p_top + 10;
|
||||
} else {
|
||||
y_mag = check_top - p_bottom - 10;
|
||||
td = bd;
|
||||
}
|
||||
|
||||
if(boxmid_x > checkboxmid_x) {
|
||||
x_mag = check_right - p_left + 10;
|
||||
} else {
|
||||
x_mag = check_left - p_right - 10;
|
||||
ld = rd;
|
||||
}
|
||||
|
||||
if(td < ld) {
|
||||
x_mag = 0;
|
||||
} else {
|
||||
y_mag = 0;
|
||||
}
|
||||
|
||||
ddx += label_force * x_mag;
|
||||
ddy += label_force * y_mag;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// stay at least label_dist away from other icons
|
||||
|
||||
if(p_right >= check_p->x && check_p->x >= p_left && p_bottom >= check_p->y && check_p->y >= p_top) {
|
||||
float x_mag, y_mag;
|
||||
|
||||
if(boxmid_x - check_p->x > 0) {
|
||||
x_mag = check_p->x - p_left + 10;
|
||||
} else {
|
||||
x_mag = check_p->x - p_right - 10;
|
||||
}
|
||||
|
||||
if(boxmid_y - check_p->y > 0) {
|
||||
y_mag = check_p->y - p_top + 10;
|
||||
} else {
|
||||
y_mag = check_p->y - p_bottom - 10;
|
||||
}
|
||||
|
||||
ddx += icon_force * x_mag;
|
||||
ddy += icon_force * y_mag;
|
||||
|
||||
}
|
||||
/*
|
||||
if(x_mag > 0 && y_mag > 0) {
|
||||
ddx += sign(offset_x) * label_force * x_mag;
|
||||
ddy += sign(offset_y) * label_force * y_mag;
|
||||
}
|
||||
|
||||
// stay at least icon_dist away from other icons
|
||||
*/
|
||||
|
||||
// stay at least icon_dist away from other icons
|
||||
/*
|
||||
offset_x = boxmid_x - check_p->x;
|
||||
offset_y = boxmid_y - check_p->y;
|
||||
|
||||
|
@ -237,6 +305,7 @@ void AircraftLabel::calculateForces(Aircraft *check_p) {
|
|||
ddy += sign(offset_y) * icon_force * y_mag;
|
||||
}
|
||||
|
||||
*/
|
||||
all_x += sign(boxmid_x - checkboxmid_x);
|
||||
all_y += sign(boxmid_y - checkboxmid_y);
|
||||
|
||||
|
@ -250,33 +319,64 @@ void AircraftLabel::calculateForces(Aircraft *check_p) {
|
|||
ddy += density_force * all_y / count;
|
||||
|
||||
// char buff[100];
|
||||
// snprintf(buff, sizeof(buff), "%2.2f", labelLevel);
|
||||
// snprintf(buff, sizeof(buff), "l:%2.2f d:%2.2f", labelLevel, calculateDensity(head, labelLevel));
|
||||
// debugLabel.setText(buff);
|
||||
|
||||
float density_mult = 0.5f;
|
||||
float density_mult = 0.15f;
|
||||
float level_rate = 0.25f;
|
||||
|
||||
if(elapsed(lastLevelChange) > 1000.0) {
|
||||
if(labelLevel < 0.8f * density_mult * calculateDensity(head, labelLevel + 1)) {
|
||||
float randtime = 5000.0f + 5000.0f * static_cast <float> (rand()) / static_cast <float> (RAND_MAX);
|
||||
if(elapsed(lastLevelChange) > randtime) {
|
||||
if(labelLevel < -1.2f + density_mult * calculateDensity(head, labelLevel - 1)) {
|
||||
if(labelLevel <= 2) {
|
||||
if(ceil(labelLevel) - labelLevel <= level_rate) {
|
||||
labelLevel += 0.5f;
|
||||
}
|
||||
|
||||
labelLevel += level_rate;
|
||||
isChanging = true;
|
||||
lastLevelChange = now();
|
||||
}
|
||||
} else if (labelLevel > 1.2f * density_mult * calculateDensity(head, labelLevel - 1)) {
|
||||
} else if (labelLevel > 1.2f + density_mult * calculateDensity(head, labelLevel + 1)) {
|
||||
if(labelLevel >= 0) {
|
||||
if(labelLevel - floor(labelLevel) <= level_rate) {
|
||||
labelLevel -= 0.5f;
|
||||
}
|
||||
|
||||
labelLevel -= level_rate;
|
||||
isChanging = true;
|
||||
lastLevelChange = now();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//add drag force
|
||||
ddx -= drag_force * dx * dx * sign(dx);
|
||||
ddy -= drag_force * dy * dy * sign(dy);
|
||||
}
|
||||
|
||||
void AircraftLabel::applyForces() {
|
||||
dx += ddx;
|
||||
dy += ddy;
|
||||
float new_dx = dx + ddx;
|
||||
float new_dy = dy + ddy;
|
||||
|
||||
dx *= damping_force;
|
||||
dy *= damping_force;
|
||||
new_dx *= damping_force;
|
||||
new_dy *= damping_force;
|
||||
|
||||
/*
|
||||
if(sign(new_dx) != sign(dx) && dx != 0) {
|
||||
new_dx = 0;
|
||||
}
|
||||
|
||||
if(sign(new_dy) != sign(dy) && dy != 0) {
|
||||
new_dy = 0;
|
||||
}
|
||||
*/
|
||||
|
||||
//if(dx > 0 || dy > 0 || new_dx > 0.01 || new_dy > 0.01) {
|
||||
dx = new_dx;
|
||||
dy = new_dy;
|
||||
//}
|
||||
|
||||
if(fabs(dx) > velocity_limit) {
|
||||
dx = sign(dx) * velocity_limit;
|
||||
|
@ -294,8 +394,36 @@ void AircraftLabel::applyForces() {
|
|||
dy = 0;
|
||||
}
|
||||
|
||||
x += dx;
|
||||
y += dy;
|
||||
if(dx < 1 || dy < 1) {
|
||||
isChanging = true;
|
||||
}
|
||||
|
||||
float new_x = 0;
|
||||
float new_y = 0;
|
||||
|
||||
for(int i = 0; i < buffer_length; i++) {
|
||||
new_x += x_buffer[i] / static_cast<float>(buffer_length);
|
||||
new_y += y_buffer[i] / static_cast<float>(buffer_length);
|
||||
}
|
||||
|
||||
x_buffer[buffer_idx] = new_x + dx;
|
||||
y_buffer[buffer_idx] = new_y + dy;
|
||||
|
||||
buffer_idx = (buffer_idx + 1) % buffer_length;
|
||||
|
||||
//new_x += dx;
|
||||
//new_y += dy;
|
||||
|
||||
//new_x = x + dx;
|
||||
//new_y = y + dy;
|
||||
|
||||
//if(abs(new_x - x) > 1 || abs(new_y - y) > 1) {
|
||||
x = new_x;
|
||||
y = new_y;
|
||||
//}
|
||||
|
||||
//x += dx;
|
||||
//y += dy;
|
||||
|
||||
if(isnan(x)) {
|
||||
x = 0;
|
||||
|
@ -347,6 +475,15 @@ void AircraftLabel::applyForces() {
|
|||
// }
|
||||
// }
|
||||
|
||||
void AircraftLabel::move(float dx, float dy) {
|
||||
for(int i = 0; i < buffer_length; i++ ){
|
||||
x_buffer[i] += dx;
|
||||
y_buffer[i] += dy;
|
||||
}
|
||||
|
||||
x+=dx;
|
||||
y+=dy;
|
||||
}
|
||||
|
||||
void AircraftLabel::draw(SDL_Renderer *renderer, bool selected) {
|
||||
if(x == 0 || y == 0) {
|
||||
|
@ -374,9 +511,9 @@ void AircraftLabel::draw(SDL_Renderer *renderer, bool selected) {
|
|||
target_opacity = 0.0f;
|
||||
}
|
||||
|
||||
opacity += 0.25f * (target_opacity - opacity);
|
||||
opacity += 0.15f * (target_opacity - opacity);
|
||||
|
||||
if(opacity < 0.05f) {
|
||||
if(opacity < 0.005f) {
|
||||
opacity = 0;
|
||||
}
|
||||
|
||||
|
@ -502,6 +639,13 @@ void AircraftLabel::draw(SDL_Renderer *renderer, bool selected) {
|
|||
if(h < 0.05f) {
|
||||
h = 0;
|
||||
}
|
||||
|
||||
isChanging = false;
|
||||
}
|
||||
|
||||
|
||||
bool AircraftLabel::getIsChanging() {
|
||||
return isChanging;
|
||||
}
|
||||
|
||||
AircraftLabel::AircraftLabel(Aircraft *p, bool metric, int screen_width, int screen_height, TTF_Font *font) {
|
||||
|
@ -516,19 +660,27 @@ AircraftLabel::AircraftLabel(Aircraft *p, bool metric, int screen_width, int scr
|
|||
target_w = 0;
|
||||
target_h = 0;
|
||||
|
||||
opacity = 0;
|
||||
target_opacity = 0;
|
||||
opacity = 0.0f;
|
||||
target_opacity = 0.0f;
|
||||
|
||||
dx = 0;
|
||||
dy = 0;
|
||||
ddx = 0;
|
||||
ddy = 0;
|
||||
|
||||
for(int i = 0; i < buffer_length; i++) {
|
||||
x_buffer[i] = x;
|
||||
y_buffer[i] = y;
|
||||
}
|
||||
buffer_idx = 0;
|
||||
|
||||
this->screen_width = screen_width;
|
||||
this->screen_height = screen_height;
|
||||
|
||||
labelLevel = 0;
|
||||
|
||||
isChanging = false;
|
||||
|
||||
flightLabel.setFont(font);
|
||||
altitudeLabel.setFont(font);
|
||||
speedLabel.setFont(font);
|
||||
|
|
|
@ -15,6 +15,8 @@ class AircraftLabel {
|
|||
void clearAcceleration();
|
||||
void calculateForces(Aircraft *check_p);
|
||||
void applyForces();
|
||||
void move(float dx, float dy);
|
||||
bool getIsChanging();
|
||||
|
||||
void draw(SDL_Renderer *renderer, bool selected);
|
||||
|
||||
|
@ -45,6 +47,12 @@ class AircraftLabel {
|
|||
|
||||
float dx;
|
||||
float dy;
|
||||
|
||||
float x_buffer[15];
|
||||
float y_buffer[15];
|
||||
int buffer_idx;
|
||||
int buffer_length = 15;
|
||||
|
||||
float ddx;
|
||||
float ddy;
|
||||
|
||||
|
@ -56,21 +64,25 @@ class AircraftLabel {
|
|||
int screen_width;
|
||||
int screen_height;
|
||||
|
||||
bool isChanging;
|
||||
|
||||
std::chrono::high_resolution_clock::time_point lastLevelChange;
|
||||
|
||||
///////////
|
||||
|
||||
float label_force = 0.001f;
|
||||
float label_force = 0.01f;
|
||||
float label_dist = 2.0f;
|
||||
float density_force = 0.05f;
|
||||
float attachment_force = 0.0015f;
|
||||
float density_force = 0.01f;
|
||||
float attachment_force = 0.01f;
|
||||
float attachment_dist = 10.0f;
|
||||
float icon_force = 0.001f;
|
||||
float icon_force = 0.01f;
|
||||
float icon_dist = 15.0f;
|
||||
float boundary_force = 0.01f;
|
||||
float damping_force = 0.85f;
|
||||
float velocity_limit = 2.0f;
|
||||
float damping_force = 0.65f;
|
||||
float velocity_limit = 1.0f;
|
||||
float edge_margin = 15.0f;
|
||||
float drag_force = 0.00f;
|
||||
|
||||
|
||||
Style style;
|
||||
};
|
||||
|
|
|
@ -51,16 +51,11 @@ void AircraftList::update(Modes *modes) {
|
|||
struct aircraft *a = modes->aircrafts;
|
||||
|
||||
Aircraft *p = head;
|
||||
|
||||
while(p) {
|
||||
p->live = 0;
|
||||
p = p->next;
|
||||
}
|
||||
|
||||
//debug
|
||||
//find(1)->live = 1;
|
||||
|
||||
|
||||
while(a) {
|
||||
|
||||
p = find(a->addr);
|
||||
|
|
|
@ -91,6 +91,7 @@ void AppData::update() {
|
|||
}
|
||||
|
||||
if ((fd == ANET_ERR) || (recv(c->fd, pk_buf, sizeof(pk_buf), MSG_PEEK | MSG_DONTWAIT) == 0)) {
|
||||
connected = false;
|
||||
free(c);
|
||||
usleep(1000000);
|
||||
c = (struct client *) malloc(sizeof(*c));
|
||||
|
@ -152,9 +153,9 @@ AppData::AppData(){
|
|||
memset(&modes, 0, sizeof(Modes));
|
||||
|
||||
modes.check_crc = 1;
|
||||
strcpy(server,VIEW1090_NET_OUTPUT_IP_ADDRESS);
|
||||
strcpy(server,"127.0.0.1");
|
||||
modes.net_input_beast_port = MODES_NET_OUTPUT_BEAST_PORT;
|
||||
modes.interactive_rows = MODES_INTERACTIVE_ROWS;
|
||||
// modes.interactive_rows = MODES_INTERACTIVE_ROWS;
|
||||
modes.interactive_delete_ttl = MODES_INTERACTIVE_DELETE_TTL;
|
||||
modes.interactive_display_ttl = MODES_INTERACTIVE_DISPLAY_TTL;
|
||||
modes.fUserLat = MODES_USER_LATITUDE_DFLT;
|
||||
|
|
|
@ -32,9 +32,8 @@
|
|||
#ifndef APPDATA_H
|
||||
#define APPDATA_H
|
||||
|
||||
#include "view1090.h" //for Modes
|
||||
|
||||
#include "AircraftList.h"
|
||||
#include "dump1090.h"
|
||||
|
||||
class AppData {
|
||||
private:
|
||||
|
@ -45,7 +44,6 @@ class AppData {
|
|||
//
|
||||
|
||||
struct client *c;
|
||||
bool connected;
|
||||
int fd;
|
||||
char pk_buf[8];
|
||||
|
||||
|
@ -57,6 +55,8 @@ class AppData {
|
|||
void updateStatus();
|
||||
AppData();
|
||||
|
||||
bool connected;
|
||||
|
||||
AircraftList aircraftList;
|
||||
Modes modes;
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ void Label::setColor(SDL_Color color) {
|
|||
}
|
||||
//
|
||||
Label::Label() {
|
||||
this->color = {255,255,255,255};
|
||||
this->color = {0,0,0,0};
|
||||
surface = NULL;
|
||||
}
|
||||
|
||||
|
|
11
Makefile
11
Makefile
|
@ -4,7 +4,7 @@
|
|||
#
|
||||
|
||||
CXXFLAGS=-O2 -std=c++11 -g
|
||||
LIBS= -lm -lSDL2 -lSDL2_ttf -lSDL2_gfx -g
|
||||
LIBS= -lm -lSDL2 -lSDL2_ttf -lSDL2_gfx -lpthread -g
|
||||
CXX=g++
|
||||
|
||||
all: viz1090
|
||||
|
@ -16,11 +16,4 @@ viz1090: viz1090.o AppData.o AircraftList.o Aircraft.o Label.o AircraftLabel.o a
|
|||
$(CXX) -o viz1090 viz1090.o AppData.o AircraftList.o Aircraft.o Label.o AircraftLabel.o anet.o interactive.o mode_ac.o mode_s.o net_io.o Input.o View.o Map.o parula.o monokai.o $(LIBS) $(LDFLAGS)
|
||||
|
||||
clean:
|
||||
rm -f \
|
||||
airportdata.bin \
|
||||
airportnames \
|
||||
mapdata/* \
|
||||
mapdata.bin \
|
||||
mapnames \
|
||||
*.o \
|
||||
viz1090
|
||||
rm -f *.o viz1090
|
||||
|
|
67
Map.cpp
67
Map.cpp
|
@ -36,7 +36,7 @@
|
|||
#include <fstream>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
#include <cmath>
|
||||
bool Map::QTInsert(QuadTree *tree, Line *line, int depth) {
|
||||
|
||||
// if(depth > 25) {
|
||||
|
@ -186,7 +186,8 @@ std::vector<Line*> Map::getLines(float screen_lat_min, float screen_lat_max, flo
|
|||
return getLinesRecursive(&root, screen_lat_min, screen_lat_max, screen_lon_min, screen_lon_max);
|
||||
};
|
||||
|
||||
Map::Map() {
|
||||
|
||||
void Map::load() {
|
||||
FILE *fileptr;
|
||||
|
||||
if((fileptr = fopen("mapdata.bin", "rb"))) {
|
||||
|
@ -205,9 +206,31 @@ Map::Map() {
|
|||
fclose(fileptr);
|
||||
|
||||
printf("Read %d map points.\n",mapPoints_count / 2);
|
||||
}
|
||||
|
||||
|
||||
if((fileptr = fopen("airportdata.bin", "rb"))) {
|
||||
fseek(fileptr, 0, SEEK_END);
|
||||
airportPoints_count = ftell(fileptr) / sizeof(float);
|
||||
rewind(fileptr);
|
||||
|
||||
airportPoints = (float *)malloc(airportPoints_count * sizeof(float));
|
||||
if(!fread(airportPoints, sizeof(float), airportPoints_count, fileptr)){
|
||||
printf("Map read error\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
fclose(fileptr);
|
||||
|
||||
printf("Read %d airport points.\n",airportPoints_count / 2);
|
||||
}
|
||||
|
||||
|
||||
int total = mapPoints_count / 2 + airportPoints_count / 2;
|
||||
int processed = 0;
|
||||
|
||||
// load quad tree
|
||||
|
||||
if(mapPoints_count > 0) {
|
||||
for(int i = 0; i < mapPoints_count; i+=2) {
|
||||
if(mapPoints[i] == 0)
|
||||
continue;
|
||||
|
@ -248,6 +271,10 @@ Map::Map() {
|
|||
// printf("inserting [%f %f] -> [%f %f]\n",currentPoint.lon,currentPoint.lat,nextPoint.lon,nextPoint.lat);
|
||||
|
||||
QTInsert(&root, new Line(currentPoint, nextPoint), 0);
|
||||
|
||||
processed++;
|
||||
|
||||
loaded = floor(100.0f * (float)processed / (float)total);
|
||||
}
|
||||
} else {
|
||||
printf("No map file found\n");
|
||||
|
@ -255,23 +282,9 @@ Map::Map() {
|
|||
//
|
||||
|
||||
|
||||
if((fileptr = fopen("airportdata.bin", "rb"))) {
|
||||
fseek(fileptr, 0, SEEK_END);
|
||||
airportPoints_count = ftell(fileptr) / sizeof(float);
|
||||
rewind(fileptr);
|
||||
|
||||
airportPoints = (float *)malloc(airportPoints_count * sizeof(float));
|
||||
if(!fread(airportPoints, sizeof(float), airportPoints_count, fileptr)){
|
||||
printf("Map read error\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
fclose(fileptr);
|
||||
|
||||
printf("Read %d airport points.\n",airportPoints_count / 2);
|
||||
|
||||
// load quad tree
|
||||
|
||||
if(airportPoints_count > 0) {
|
||||
for(int i = 0; i < airportPoints_count; i+=2) {
|
||||
if(airportPoints[i] == 0)
|
||||
continue;
|
||||
|
@ -312,6 +325,10 @@ Map::Map() {
|
|||
//printf("inserting [%f %f] -> [%f %f]\n",currentPoint.lon,currentPoint.lat,nextPoint.lon,nextPoint.lat);
|
||||
|
||||
QTInsert(&airport_root, new Line(currentPoint, nextPoint), 0);
|
||||
|
||||
processed++;
|
||||
|
||||
loaded = floor(100.0f * (float)processed / (float)total);
|
||||
}
|
||||
} else {
|
||||
printf("No airport file found\n");
|
||||
|
@ -379,7 +396,17 @@ Map::Map() {
|
|||
|
||||
infile.close();
|
||||
|
||||
|
||||
|
||||
printf("done\n");
|
||||
|
||||
loaded = 100;
|
||||
}
|
||||
|
||||
Map::Map() {
|
||||
loaded = 0;
|
||||
|
||||
mapPoints_count = 0;
|
||||
mapPoints = NULL;
|
||||
|
||||
airportPoints_count = 0;
|
||||
airportPoints = NULL;
|
||||
}
|
||||
|
|
2
Map.h
2
Map.h
|
@ -128,6 +128,8 @@ public:
|
|||
std::vector<MapLabel*> mapnames;
|
||||
std::vector<MapLabel*> airportnames;
|
||||
|
||||
void load();
|
||||
int loaded;
|
||||
Map();
|
||||
|
||||
int mapPoints_count;
|
||||
|
|
37
README.md
37
README.md
|
@ -29,10 +29,41 @@ sudo apt-get install build-essential
|
|||
|
||||
1. Install SDL and RTL-SDR libraries
|
||||
```
|
||||
sudo apt-get install libsdl2-dev libsdl2-ttf-dev libsdl2-gfx-dev librtlsdr-dev libgdal-dev
|
||||
sudo apt-get install libsdl2-dev libsdl2-ttf-dev libsdl2-gfx-dev libgdal-dev
|
||||
```
|
||||
1b. (Raspberry Pi only)
|
||||
If you are running viz1090 on the Raspbian desktop (or any form of X) you can skip this step, but if you want to be able to start it directly from the command line, do the following to build SDL with KMS driver support. This is taken from [this stackoverflow question](https://stackoverflow.com/questions/57672568/sdl2-on-raspberry-pi-without-x)
|
||||
|
||||
Note: On Raspbian the SDL2 package requires X to be running. See the Raspberry Pi section for notes on running from the terminal and other improvements.
|
||||
```
|
||||
git clone https://github.com/libsdl-org/SDL
|
||||
sudo apt build-dep libsdl2
|
||||
sudo apt install libdrm-dev libgbm-dev
|
||||
cd ~/SDL
|
||||
git checkout SDL2
|
||||
./configure --enable-video-kmsdrm
|
||||
make -j4 && sudo make install
|
||||
```
|
||||
Then download and build SDL2_gfx
|
||||
```
|
||||
wget http://www.ferzkopp.net/Software/SDL2_gfx/SDL2_gfx-1.0.4.tar.gz
|
||||
tar -zxvf SDL2_gfx-1.0.4.tar.gz
|
||||
cd SDL2_gfx-1.0.4
|
||||
./configure --build=arm-linux-gnueabihf --disable-mmx
|
||||
make -j4 && sudo make install
|
||||
```
|
||||
And finally SDL2_ttf
|
||||
```
|
||||
git clone https://github.com/libsdl-org/SDL_ttf.git
|
||||
cd SDL_ttf
|
||||
git checkout SDL2
|
||||
./configure --disable-freetype-builtin --without-x --enable-harfbuzz=no
|
||||
make -j4 && sudo make install
|
||||
```
|
||||
Now make sure that you are using the "Fake KMS" driver, not the newer "KMS" driver in /boot/config.txt:
|
||||
```
|
||||
dtoverlay=vc4-fkms-v3d
|
||||
#dtoverlay=vc4-kms-v3d
|
||||
```
|
||||
|
||||
2. Download and build viz1090
|
||||
```
|
||||
|
@ -54,8 +85,6 @@ This will produce files for map and airport geometry, with labels, that viz1090
|
|||
|
||||
The default parameters for mapconverter should render reasonably quickly on a Raspberry Pi 4. See the mapconverter section below for other options and more information about map sources.
|
||||
|
||||
|
||||
|
||||
3. (Windows only)
|
||||
|
||||
As WSL does not have an X server built in, you will need to install a 3rd party X server, such as https://sourceforge.net/projects/vcxsrv/
|
||||
|
|
19
Style.h
19
Style.h
|
@ -35,6 +35,9 @@ typedef struct Style {
|
|||
SDL_Color red;
|
||||
SDL_Color green;
|
||||
SDL_Color blue;
|
||||
SDL_Color orange;
|
||||
SDL_Color grey;
|
||||
SDL_Color grey_dark;
|
||||
|
||||
//
|
||||
// todo separate style stuff
|
||||
|
@ -56,10 +59,10 @@ typedef struct Style {
|
|||
SDL_Color yellow = {216,255,0,255};
|
||||
SDL_Color yellow_dark = {90,133,50,255};
|
||||
|
||||
SDL_Color orange = {253,151,31,255};
|
||||
orange = {253,151,31,255};
|
||||
SDL_Color grey_light = {196,196,196,255};
|
||||
SDL_Color grey = {127,127,127,255};
|
||||
SDL_Color grey_dark = {64,64,64,255};
|
||||
grey = {127,127,127,255};
|
||||
grey_dark = {64,64,64,255};
|
||||
|
||||
black = {0,0,0,255};
|
||||
white = {255,255,255,255};
|
||||
|
@ -68,15 +71,15 @@ typedef struct Style {
|
|||
blue = {0,0,255,255};
|
||||
|
||||
|
||||
backgroundColor = black;
|
||||
backgroundColor = {0,0,0,255};
|
||||
|
||||
selectedColor = pink;
|
||||
planeColor = yellow;
|
||||
planeColor = {0,255,174};
|
||||
planeGoneColor = grey;
|
||||
trailColor = yellow_dark;
|
||||
trailColor = {0,255,174};
|
||||
|
||||
geoColor = purple_dark;
|
||||
airportColor = purple;
|
||||
geoColor = grey_dark;
|
||||
airportColor = grey;
|
||||
|
||||
labelColor = white;
|
||||
labelLineColor = grey_dark;
|
||||
|
|
236
View.cpp
236
View.cpp
|
@ -68,6 +68,7 @@ static float clamp(float in, float min, float max) {
|
|||
return out;
|
||||
}
|
||||
|
||||
|
||||
static void CROSSVP(float *v, float *u, float *w)
|
||||
{
|
||||
v[0] = u[1]*w[2] - u[2]*(w)[1];
|
||||
|
@ -83,6 +84,40 @@ SDL_Color setColor(uint8_t r, uint8_t g, uint8_t b) {
|
|||
return out;
|
||||
}
|
||||
|
||||
float lerp(float a, float b, float factor) {
|
||||
if(factor > 1.0f) {
|
||||
factor = 1.0f;
|
||||
}
|
||||
|
||||
if(factor < 0.0f) {
|
||||
factor = 0.0f;
|
||||
}
|
||||
|
||||
return (1.0f - factor) * a + factor * b;
|
||||
}
|
||||
|
||||
float lerpAngle(float a, float b, float factor) {
|
||||
float diff = fabs(b - a);
|
||||
if (diff > 180.0f)
|
||||
{
|
||||
if (b > a)
|
||||
{
|
||||
a += 360.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
b += 360.0f;
|
||||
}
|
||||
}
|
||||
|
||||
float value = (a + ((b - a) * factor));
|
||||
|
||||
if (value >= 0.0f && value <= 360.0f)
|
||||
return value;
|
||||
|
||||
return fmod(value,360.0f);
|
||||
}
|
||||
|
||||
SDL_Color lerpColor(SDL_Color aColor, SDL_Color bColor, float factor) {
|
||||
if(factor > 1.0f) {
|
||||
factor = 1.0f;
|
||||
|
@ -199,7 +234,6 @@ void View::font_init() {
|
|||
//
|
||||
|
||||
void View::SDL_init() {
|
||||
|
||||
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
|
||||
printf("Could not initialize SDL: %s\n", SDL_GetError());
|
||||
exit(1);
|
||||
|
@ -226,7 +260,7 @@ void View::SDL_init() {
|
|||
}
|
||||
|
||||
window = SDL_CreateWindow("viz1090", SDL_WINDOWPOS_CENTERED_DISPLAY(screen_index), SDL_WINDOWPOS_CENTERED_DISPLAY(screen_index), screen_width, screen_height, flags);
|
||||
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
|
||||
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
|
||||
mapTexture = SDL_CreateTexture(renderer,
|
||||
SDL_PIXELFORMAT_ARGB8888,
|
||||
SDL_TEXTUREACCESS_TARGET,
|
||||
|
@ -288,11 +322,34 @@ void View::drawStatusBox(int *left, int *top, std::string label, std::string mes
|
|||
*left = *left + labelWidth + messageWidth + PAD;
|
||||
}
|
||||
|
||||
void View::drawCenteredStatusBox(std::string label, std::string message, SDL_Color color) {
|
||||
|
||||
int labelWidth = (label.length() + ((label.length() > 0 ) ? 1 : 0)) * labelFontWidth;
|
||||
int messageWidth = (message.length() + ((message.length() > 0 ) ? 1 : 0)) * messageFontWidth;
|
||||
|
||||
int left = (screen_width - (labelWidth + messageWidth)) / 2;
|
||||
int top = (screen_height - labelFontHeight) / 2;
|
||||
|
||||
drawStatusBox(&left, &top, label, message, color);
|
||||
}
|
||||
|
||||
|
||||
void View::drawStatus() {
|
||||
|
||||
int left = PAD;
|
||||
int top = screen_height - messageFontHeight - PAD;
|
||||
|
||||
if(fps) {
|
||||
char fps[60] = " ";
|
||||
snprintf(fps,40,"%.1f", 1000.0 / lastFrameTime);
|
||||
|
||||
drawStatusBox(&left, &top, "fps", fps, style.grey_dark);
|
||||
}
|
||||
|
||||
|
||||
if(!appData->connected) {
|
||||
drawStatusBox(&left,&top,"init", "connecting", style.red);
|
||||
} else {
|
||||
char strLoc[20] = " ";
|
||||
snprintf(strLoc, 20, "%3.3fN %3.3f%c", centerLat, fabs(centerLon),(centerLon > 0) ? 'E' : 'W');
|
||||
drawStatusBox(&left, &top, "loc", strLoc, style.buttonColor);
|
||||
|
@ -308,7 +365,13 @@ void View::drawStatus() {
|
|||
char strSig[18] = " ";
|
||||
snprintf(strSig, 18, "%.0f%%", 100.0 * appData->avgSig / 1024.0);
|
||||
drawStatusBox(&left, &top, "sAvg", strSig, style.buttonColor);
|
||||
}
|
||||
|
||||
if(map.loaded < 100) {
|
||||
char loaded[20] = " ";
|
||||
snprintf(loaded, 20, "loading map %d%%", map.loaded);
|
||||
drawStatusBox(&left,&top,"init", loaded, style.orange);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -358,7 +421,7 @@ void View::drawPlaneOffMap(int x, int y, int *returnx, int *returny, SDL_Color p
|
|||
y2 = (screen_height>>1) + outy - 2.0 * arrowWidth * vec[1] + round(arrowWidth*out[1]);
|
||||
x3 = (screen_width>>1) + outx - arrowWidth * vec[0];
|
||||
y3 = (screen_height>>1) + outy - arrowWidth * vec[1];
|
||||
trigonRGBA(renderer, x1, y1, x2, y2, x3, y3, planeColor.r,planeColor.g,planeColor.b,SDL_ALPHA_OPAQUE);
|
||||
filledTrigonRGBA(renderer, x1, y1, x2, y2, x3, y3, planeColor.r,planeColor.g,planeColor.b,SDL_ALPHA_OPAQUE);
|
||||
|
||||
// arrow 2
|
||||
x1 = (screen_width>>1) + outx - 3.0 * arrowWidth * vec[0] + round(-arrowWidth*out[0]);
|
||||
|
@ -367,7 +430,7 @@ void View::drawPlaneOffMap(int x, int y, int *returnx, int *returny, SDL_Color p
|
|||
y2 = (screen_height>>1) + outy - 3.0 * arrowWidth * vec[1] + round(arrowWidth*out[1]);
|
||||
x3 = (screen_width>>1) + outx - 2.0 * arrowWidth * vec[0];
|
||||
y3 = (screen_height>>1) + outy - 2.0 * arrowWidth * vec[1];
|
||||
trigonRGBA(renderer, x1, y1, x2, y2, x3, y3, planeColor.r,planeColor.g,planeColor.b,SDL_ALPHA_OPAQUE);
|
||||
filledTrigonRGBA(renderer, x1, y1, x2, y2, x3, y3, planeColor.r,planeColor.g,planeColor.b,SDL_ALPHA_OPAQUE);
|
||||
|
||||
*returnx = x3;
|
||||
*returny = y3;
|
||||
|
@ -377,9 +440,9 @@ void View::drawPlaneIcon(int x, int y, float heading, SDL_Color planeColor)
|
|||
{
|
||||
float body = 8.0 * screen_uiscale;
|
||||
float wing = 6.0 * screen_uiscale;
|
||||
float wingThick = 0.35;
|
||||
float wingThick = 0.5;
|
||||
float tail = 3.0 * screen_uiscale;
|
||||
float tailThick = 0.5;
|
||||
float tailThick = 0.35;
|
||||
float bodyWidth = screen_uiscale;
|
||||
|
||||
float vec[3];
|
||||
|
@ -401,15 +464,15 @@ void View::drawPlaneIcon(int x, int y, float heading, SDL_Color planeColor)
|
|||
x2 = x + round(bodyWidth*out[0]);
|
||||
y2 = y + round(bodyWidth*out[1]);
|
||||
|
||||
trigonRGBA (renderer, x1, y1, x2, y2, x+round(-body * vec[0]), y+round(-body*vec[1]),planeColor.r,planeColor.g,planeColor.b,SDL_ALPHA_OPAQUE);
|
||||
trigonRGBA (renderer, x1, y1, x2, y2, x+round(body * vec[0]), y+round(body*vec[1]),planeColor.r,planeColor.g,planeColor.b,SDL_ALPHA_OPAQUE);
|
||||
filledTrigonRGBA (renderer, x1, y1, x2, y2, x+round(-body * vec[0]), y+round(-body*vec[1]),planeColor.r,planeColor.g,planeColor.b,SDL_ALPHA_OPAQUE);
|
||||
filledTrigonRGBA (renderer, x1, y1, x2, y2, x+round(body * vec[0]), y+round(body*vec[1]),planeColor.r,planeColor.g,planeColor.b,SDL_ALPHA_OPAQUE);
|
||||
|
||||
// x1 = x + round(-body*vec[0] - bodyWidth*out[0]);
|
||||
// y1 = y + round(-body*vec[1] - bodyWidth*out[1]);
|
||||
// x2 = x + round(body*vec[0] - bodyWidth*out[0]);
|
||||
// y2 = y + round(body*vec[1] - bodyWidth*out[1]);
|
||||
//x1 = x + round(8*vec[0]);
|
||||
//y1 = y + round(8*vec[1]);
|
||||
//x2 = x + round(16*vec[0]);
|
||||
//y2 = y + round(16*vec[1]);
|
||||
|
||||
// lineRGBA(renderer,x,y,x2,y2,planeColor.r,planeColor.g,planeColor.b,SDL_ALPHA_OPAQUE);
|
||||
//lineRGBA(renderer,x1,y1,x2,y2, style.white.r, style.white.g, style.white.b, SDL_ALPHA_OPAQUE);
|
||||
|
||||
// x1 = x + round(-body*vec[0] + bodyWidth*out[0]);
|
||||
// y1 = y + round(-body*vec[1] + bodyWidth*out[1]);
|
||||
|
@ -427,7 +490,7 @@ void View::drawPlaneIcon(int x, int y, float heading, SDL_Color planeColor)
|
|||
x2 = x + round(wing*out[0]);
|
||||
y2 = y + round(wing*out[1]);
|
||||
|
||||
trigonRGBA(renderer, x1, y1, x2, y2, x+round(body*wingThick*vec[0]), y+round(body*wingThick*vec[1]),planeColor.r,planeColor.g,planeColor.b,SDL_ALPHA_OPAQUE);
|
||||
filledTrigonRGBA(renderer, x1, y1, x2, y2, x+round(body*wingThick*vec[0]), y+round(body*wingThick*vec[1]),planeColor.r,planeColor.g,planeColor.b,SDL_ALPHA_OPAQUE);
|
||||
|
||||
//tail
|
||||
x1 = x + round(-body*.75*vec[0] - tail*out[0]);
|
||||
|
@ -435,25 +498,19 @@ void View::drawPlaneIcon(int x, int y, float heading, SDL_Color planeColor)
|
|||
x2 = x + round(-body*.75*vec[0] + tail*out[0]);
|
||||
y2 = y + round(-body*.75*vec[1] + tail*out[1]);
|
||||
|
||||
trigonRGBA (renderer, x1, y1, x2, y2, x+round(-body*tailThick*vec[0]), y+round(-body*tailThick*vec[1]),planeColor.r,planeColor.g,planeColor.b,SDL_ALPHA_OPAQUE);
|
||||
filledTrigonRGBA (renderer, x1, y1, x2, y2, x+round(-body*tailThick*vec[0]), y+round(-body*tailThick*vec[1]),planeColor.r,planeColor.g,planeColor.b,SDL_ALPHA_OPAQUE);
|
||||
}
|
||||
|
||||
void View::drawTrails(int left, int top, int right, int bottom) {
|
||||
int currentX, currentY, prevX, prevY;
|
||||
int currentX, currentY, prevX, prevY, colorVal;
|
||||
float dx, dy;
|
||||
|
||||
Aircraft *p = appData->aircraftList.head;
|
||||
|
||||
int count = 0;
|
||||
while(p) {
|
||||
if (p->lon && p->lat) {
|
||||
if(p->lonHistory.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
SDL_Color color = lerpColor(style.trailColor, style.planeGoneColor, static_cast<float>(elapsed_s(p->msSeen)) / DISPLAY_ACTIVE);
|
||||
|
||||
if(p == selectedAircraft) {
|
||||
color = style.selectedColor;
|
||||
p = p->next;
|
||||
continue;
|
||||
}
|
||||
|
||||
std::vector<float>::iterator lon_idx = p->lonHistory.begin();
|
||||
|
@ -474,12 +531,22 @@ void View::drawTrails(int left, int top, int right, int bottom) {
|
|||
continue;
|
||||
}
|
||||
|
||||
uint8_t colorVal = (uint8_t)floor(127.0 * (age / static_cast<float>(p->lonHistory.size())));
|
||||
|
||||
//thickLineRGBA(renderer, prevX, prevY, currentX, currentY, 2 * screen_uiscale, 255, 255, 255, colorVal);
|
||||
SDL_Color color = lerpColor({255,0,0,255}, {255,200,0,255}, age / static_cast<float>(p->lonHistory.size()));
|
||||
|
||||
color = lerpColor(color, style.planeGoneColor, elapsed_s(p->msSeen) / DISPLAY_ACTIVE);
|
||||
color = lerpColor(color, style.black, -1.0f + (elapsed_s(p->msSeen) / DISPLAY_ACTIVE));
|
||||
|
||||
colorVal = (uint8_t)clamp(512.0 * (age / static_cast<float>(p->lonHistory.size())), 0, 255);
|
||||
|
||||
lineRGBA(renderer, prevX, prevY, currentX, currentY, color.r, color.g, color.b, colorVal);
|
||||
|
||||
}
|
||||
|
||||
if(elapsed_s(p->msSeen) > DISPLAY_ACTIVE) {
|
||||
//lineRGBA(renderer, currentX-4, currentY-4, currentX+4, currentY+4, style.planeGoneColor.r, style.planeGoneColor.g, style.planeGoneColor.b, colorVal);
|
||||
//lineRGBA(renderer, currentX+4, currentY-4, currentX-4, currentY+4, style.planeGoneColor.r, style.planeGoneColor.g, style.planeGoneColor.b, colorVal);
|
||||
SDL_Color color = lerpColor(style.planeGoneColor, style.black, -1.0f + (elapsed_s(p->msSeen) / DISPLAY_ACTIVE));
|
||||
circleRGBA(renderer, currentX, currentY, 5, color.r, color.g, color.b, colorVal);
|
||||
}
|
||||
p = p->next;
|
||||
}
|
||||
|
@ -569,8 +636,6 @@ void View::drawLinesRecursive(QuadTree *tree, float screen_lat_min, float screen
|
|||
pxFromLonLat(&dx, &dy, (*currentLine)->end.lon, (*currentLine)->end.lat);
|
||||
screenCoords(&x2, &y2, dx, dy);
|
||||
|
||||
lineCount++;
|
||||
|
||||
if(outOfBounds(x1,y1) && outOfBounds(x2,y2)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -654,7 +719,7 @@ void View::drawPlaceNames() {
|
|||
|
||||
void View::drawGeography() {
|
||||
|
||||
if((mapRedraw && !mapMoved) || (mapAnimating && elapsed(lastRedraw) > 8 * FRAMETIME) || elapsed(lastRedraw) > 2000) {
|
||||
if((mapRedraw && !mapMoved) || (mapAnimating && elapsed(lastRedraw) > 8 * FRAMETIME) || elapsed(lastRedraw) > 2000 || (map.loaded < 100 && elapsed(lastRedraw) > 250)) {
|
||||
|
||||
SDL_SetRenderTarget(renderer, mapTexture);
|
||||
|
||||
|
@ -744,9 +809,20 @@ void View::drawPlaneText(Aircraft *p) {
|
|||
p->label->draw(renderer, (p == selectedAircraft));
|
||||
}
|
||||
|
||||
float View::resolveLabelConflicts() {
|
||||
float maxV = 0.0f;
|
||||
void View::moveLabels(float dx, float dy) {
|
||||
Aircraft *p = appData->aircraftList.head;
|
||||
|
||||
while(p) {
|
||||
if(p->label) {
|
||||
p->label->move(dx,dy);
|
||||
}
|
||||
|
||||
p = p->next;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void View::resolveLabelConflicts() {
|
||||
Aircraft *p = appData->aircraftList.head;
|
||||
|
||||
while(p) {
|
||||
|
@ -773,12 +849,14 @@ float View::resolveLabelConflicts() {
|
|||
|
||||
if(p->label) {
|
||||
p->label->applyForces();
|
||||
|
||||
// if(p->label->getIsChanging()) {
|
||||
// highFramerate = true;
|
||||
// }
|
||||
}
|
||||
|
||||
p = p->next;
|
||||
}
|
||||
|
||||
return maxV;
|
||||
}
|
||||
|
||||
void View::drawPlanes() {
|
||||
|
@ -809,40 +887,55 @@ void View::drawPlanes() {
|
|||
|
||||
float age_ms = elapsed(p->created);
|
||||
if(age_ms < 500) {
|
||||
//highFramerate = true;
|
||||
float ratio = age_ms / 500.0f;
|
||||
float radius = (1.0f - ratio * ratio) * screen_width / 8;
|
||||
for(float theta = 0; theta < 2*M_PI; theta += M_PI / 4) {
|
||||
pixelRGBA(renderer, x + radius * cos(theta), y + radius * sin(theta), style.planeColor.r, style.planeColor.g, style.planeColor.b, 255 * ratio);
|
||||
}
|
||||
// circleRGBA(renderer, x, y, 500 - age_ms, 255,255, 255, (uint8_t)(255.0 * age_ms / 500.0));
|
||||
} else {
|
||||
} else if(1000 * DISPLAY_ACTIVE - elapsed(p->msSeen) > 500) {
|
||||
if(MODES_ACFLAGS_HEADING_VALID) {
|
||||
int usex = x;
|
||||
int usey = y;
|
||||
float useHeading = static_cast<float>(p->track);
|
||||
|
||||
p->x = usex;
|
||||
p->y = usey;
|
||||
|
||||
planeColor = lerpColor(style.planeColor, style.planeGoneColor, elapsed_s(p->msSeen) / DISPLAY_ACTIVE);
|
||||
|
||||
if(elapsed_s(p->msSeen) > DISPLAY_ACTIVE / 2) {
|
||||
arcRGBA(renderer, x, y, 8, 0, 360 * 2.0 * (elapsed_s(p->msSeen) / DISPLAY_ACTIVE - 0.5), planeColor.r, planeColor.g, planeColor.b, 255);
|
||||
}
|
||||
|
||||
if(p == selectedAircraft) {
|
||||
planeColor = style.selectedColor;
|
||||
}
|
||||
|
||||
|
||||
if(outOfBounds(x,y)) {
|
||||
drawPlaneOffMap(x, y, &(p->x), &(p->y), planeColor);
|
||||
} else {
|
||||
drawPlaneIcon(usex, usey, p->track, planeColor);
|
||||
if(elapsed(p->msSeenLatLon) < 500) {
|
||||
//highFramerate = true;
|
||||
circleRGBA(renderer, p->x, p->y, elapsed(p->msSeenLatLon) * screen_width / (8192), 127,127, 127, 255 - (uint8_t)(255.0 * elapsed(p->msSeenLatLon) / 500.0));
|
||||
|
||||
p->x = usex;
|
||||
p->y = usey;
|
||||
pxFromLonLat(&dx, &dy, p->getLastLon(), p->getLastLat());
|
||||
screenCoords(&x, &y, dx, dy);
|
||||
|
||||
usex = lerp(x,usex,elapsed(p->msSeenLatLon) / 500.0);
|
||||
usey = lerp(y,usey,elapsed(p->msSeenLatLon) / 500.0);
|
||||
useHeading = lerpAngle(p->getLastHeading(),useHeading,elapsed(p->msSeenLatLon) / 500.0);
|
||||
}
|
||||
|
||||
|
||||
//show latlon ping
|
||||
if(elapsed(p->msSeenLatLon) < 500) {
|
||||
circleRGBA(renderer, p->x, p->y, elapsed(p->msSeenLatLon) * screen_width / (8192), 127,127, 127, 255 - (uint8_t)(255.0 * elapsed(p->msSeenLatLon) / 500.0));
|
||||
drawPlaneIcon(usex, usey, useHeading, planeColor);
|
||||
}
|
||||
|
||||
drawPlaneText(p);
|
||||
}
|
||||
} else {
|
||||
circleRGBA(renderer, x, y, 8 * (1000 * DISPLAY_ACTIVE - elapsed(p->msSeen)) / 500, style.planeGoneColor.r, style.planeGoneColor.g, style.planeGoneColor.b, 255);
|
||||
}
|
||||
}
|
||||
p = p->next;
|
||||
|
@ -855,6 +948,8 @@ void View::animateCenterAbsolute(float x, float y) {
|
|||
float dx = -1.0 * (0.75*(double)screen_width / (double)screen_height) * (x - screen_width/2) * maxDist / (0.95 * scale_factor * 0.5);
|
||||
float dy = 1.0 * (y - screen_height/2) * maxDist / (0.95 * scale_factor * 0.5);
|
||||
|
||||
moveLabels(x,y);
|
||||
|
||||
float outLat = dy * (1.0/6371.0) * (180.0f / M_PI);
|
||||
|
||||
float outLon = dx * (1.0/6371.0) * (180.0f / M_PI) / cos(((centerLat)/2.0f) * M_PI / 180.0f);
|
||||
|
@ -865,6 +960,8 @@ void View::animateCenterAbsolute(float x, float y) {
|
|||
mapTargetMaxDist = 0.25 * maxDist;
|
||||
|
||||
mapMoved = 1;
|
||||
highFramerate = true;
|
||||
|
||||
}
|
||||
|
||||
void View::moveCenterAbsolute(float x, float y) {
|
||||
|
@ -873,6 +970,8 @@ void View::moveCenterAbsolute(float x, float y) {
|
|||
float dx = -1.0 * (0.75*(double)screen_width / (double)screen_height) * (x - screen_width/2) * maxDist / (0.95 * scale_factor * 0.5);
|
||||
float dy = 1.0 * (y - screen_height/2) * maxDist / (0.95 * scale_factor * 0.5);
|
||||
|
||||
moveLabels(x,y);
|
||||
|
||||
float outLat = dy * (1.0/6371.0) * (180.0f / M_PI);
|
||||
|
||||
float outLon = dx * (1.0/6371.0) * (180.0f / M_PI) / cos(((centerLat)/2.0f) * M_PI / 180.0f);
|
||||
|
@ -884,6 +983,7 @@ void View::moveCenterAbsolute(float x, float y) {
|
|||
mapTargetLat = 0;
|
||||
|
||||
mapMoved = 1;
|
||||
highFramerate = true;
|
||||
}
|
||||
|
||||
void View::moveCenterRelative(float dx, float dy) {
|
||||
|
@ -891,6 +991,8 @@ void View::moveCenterRelative(float dx, float dy) {
|
|||
// need to make lonlat to screen conversion class - this is just the inverse of the stuff in draw.c, without offsets
|
||||
//
|
||||
|
||||
moveLabels(dx,dy);
|
||||
|
||||
float scale_factor = (screen_width > screen_height) ? screen_width : screen_height;
|
||||
|
||||
dx = -1.0 * dx * maxDist / (0.95 * scale_factor * 0.5);
|
||||
|
@ -907,6 +1009,7 @@ void View::moveCenterRelative(float dx, float dy) {
|
|||
mapTargetLat = 0;
|
||||
|
||||
mapMoved = 1;
|
||||
highFramerate = true;
|
||||
}
|
||||
|
||||
void View::zoomMapToTarget() {
|
||||
|
@ -915,6 +1018,7 @@ void View::zoomMapToTarget() {
|
|||
maxDist += 0.1 * (mapTargetMaxDist - maxDist);
|
||||
mapAnimating = 1;
|
||||
mapMoved = 1;
|
||||
highFramerate = true;
|
||||
} else {
|
||||
mapTargetMaxDist = 0;
|
||||
}
|
||||
|
@ -929,6 +1033,7 @@ void View::moveMapToTarget() {
|
|||
|
||||
mapAnimating = 1;
|
||||
mapMoved = 1;
|
||||
highFramerate = true;
|
||||
} else {
|
||||
mapTargetLon = 0;
|
||||
mapTargetLat = 0;
|
||||
|
@ -954,6 +1059,7 @@ void View::moveMapToTarget() {
|
|||
|
||||
void View::drawClick() {
|
||||
if(clickx && clicky) {
|
||||
highFramerate = true;
|
||||
|
||||
int radius = .25 * elapsed(clickTime);
|
||||
int alpha = 128 - static_cast<int>(0.5 * elapsed(clickTime));
|
||||
|
@ -1036,6 +1142,7 @@ void View::registerMouseMove(int x, int y) {
|
|||
// latLonFromScreenCoords(&(mouse->lat), &(mouse->lon), x, screen_height-y);
|
||||
// mouse->live = 1;
|
||||
// }
|
||||
highFramerate = true;
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -1045,10 +1152,24 @@ void View::registerMouseMove(int x, int y) {
|
|||
void View::draw() {
|
||||
drawStartTime = now();
|
||||
|
||||
int targetFrameTime = 30;
|
||||
|
||||
// if(highFramerate) {
|
||||
// targetFrameTime = 15;
|
||||
// }
|
||||
// highFramerate = false;
|
||||
|
||||
if (lastFrameTime < targetFrameTime) {
|
||||
SDL_Delay(static_cast<Uint32>(targetFrameTime - lastFrameTime));
|
||||
}
|
||||
|
||||
moveMapToTarget();
|
||||
zoomMapToTarget();
|
||||
drawGeography();
|
||||
|
||||
drawGeography();
|
||||
drawScaleBars();
|
||||
|
||||
if(appData->connected) {
|
||||
for(int i = 0; i < 8; i++) {
|
||||
// if(resolveLabelConflicts() < 0.001f) {
|
||||
// break;
|
||||
|
@ -1056,43 +1177,35 @@ void View::draw() {
|
|||
resolveLabelConflicts();
|
||||
}
|
||||
|
||||
lineCount = 0;
|
||||
|
||||
drawScaleBars();
|
||||
drawPlanes();
|
||||
}
|
||||
|
||||
drawStatus();
|
||||
//drawMouse();
|
||||
drawClick();
|
||||
|
||||
// if(fps) {
|
||||
// char fps[60] = " ";
|
||||
// snprintf(fps,40," %d lines @ %.1ffps", lineCount, 1000.0 / elapsed(lastFrameTime));
|
||||
|
||||
// drawStringBG(fps, 0,0, mapFont, style.subLabelColor, style.backgroundColor);
|
||||
// }
|
||||
|
||||
SDL_RenderPresent(renderer);
|
||||
|
||||
if (elapsed(drawStartTime) < FRAMETIME) {
|
||||
std::this_thread::sleep_for(fmilliseconds{FRAMETIME} - (now() - drawStartTime));
|
||||
}
|
||||
|
||||
lastFrameTime = now();
|
||||
lastFrameTime = elapsed(drawStartTime);
|
||||
}
|
||||
|
||||
View::View(AppData *appData){
|
||||
this->appData = appData;
|
||||
|
||||
startupState = 0;
|
||||
|
||||
// Display options
|
||||
screen_uiscale = 1;
|
||||
screen_width = 0;
|
||||
screen_height = 0;
|
||||
screen_depth = 32;
|
||||
metric = 0;
|
||||
fps = 0;
|
||||
fullscreen = 0;
|
||||
screen_index = 0;
|
||||
|
||||
highFramerate = false;
|
||||
lastFrameTime = 0;
|
||||
|
||||
centerLon = 0;
|
||||
centerLat = 0;
|
||||
|
||||
|
@ -1102,6 +1215,9 @@ View::View(AppData *appData){
|
|||
mapRedraw = 1;
|
||||
|
||||
selectedAircraft = NULL;
|
||||
|
||||
std::thread t1(&Map::load, &map);
|
||||
t1.detach();
|
||||
}
|
||||
|
||||
View::~View() {
|
||||
|
|
10
View.h
10
View.h
|
@ -84,7 +84,9 @@ class View {
|
|||
SDL_Rect drawString(std::string text, int x, int y, TTF_Font *font, SDL_Color color);
|
||||
SDL_Rect drawStringBG(std::string text, int x, int y, TTF_Font *font, SDL_Color color, SDL_Color bgColor);
|
||||
void drawStatusBox(int *left, int *top, std::string label, std::string message, SDL_Color color);
|
||||
void drawCenteredStatusBox(std::string label, std::string message, SDL_Color color);
|
||||
void drawStatus();
|
||||
void moveLabels(float dx, float dy);
|
||||
|
||||
Aircraft *selectedAircraft;
|
||||
|
||||
|
@ -107,7 +109,7 @@ class View {
|
|||
void drawGeography();
|
||||
void drawSignalMarks(Aircraft *p, int x, int y);
|
||||
void drawPlaneText(Aircraft *p);
|
||||
float resolveLabelConflicts();
|
||||
void resolveLabelConflicts();
|
||||
void drawPlanes();
|
||||
void animateCenterAbsolute(float x, float y);
|
||||
void moveCenterAbsolute(float x, float y);
|
||||
|
@ -132,6 +134,8 @@ class View {
|
|||
|
||||
bool fps;
|
||||
|
||||
int startupState;
|
||||
|
||||
float maxDist;
|
||||
float currentMaxDist;
|
||||
|
||||
|
@ -146,9 +150,11 @@ class View {
|
|||
int mapRedraw;
|
||||
int mapAnimating;
|
||||
|
||||
bool highFramerate;
|
||||
|
||||
float currentLon;
|
||||
float currentLat;
|
||||
std::chrono::high_resolution_clock::time_point lastFrameTime;
|
||||
float lastFrameTime;
|
||||
std::chrono::high_resolution_clock::time_point drawStartTime;
|
||||
std::chrono::high_resolution_clock::time_point lastRedraw;
|
||||
|
||||
|
|
203
dump1090.h
203
dump1090.h
|
@ -1,47 +1,47 @@
|
|||
// dump1090, a Mode S messages decoder for RTLSDR devices.
|
||||
//
|
||||
// Copyright (C) 2012 by Salvatore Sanfilippo <antirez@gmail.com>
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// // dump1090, a Mode S messages decoder for RTLSDR devices.
|
||||
// //
|
||||
// // Copyright (C) 2012 by Salvatore Sanfilippo <antirez@gmail.com>
|
||||
// //
|
||||
// // All rights reserved.
|
||||
// //
|
||||
// // Redistribution and use in source and binary forms, with or without
|
||||
// // modification, are permitted provided that the following conditions are
|
||||
// // met:
|
||||
// //
|
||||
// // * Redistributions of source code must retain the above copyright
|
||||
// // notice, this list of conditions and the following disclaimer.
|
||||
// //
|
||||
// // * Redistributions in binary form must reproduce the above copyright
|
||||
// // notice, this list of conditions and the following disclaimer in the
|
||||
// // documentation and/or other materials provided with the distribution.
|
||||
// //
|
||||
// // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// // HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// //
|
||||
#ifndef __DUMP1090_H
|
||||
#define __DUMP1090_H
|
||||
|
||||
// File Version number
|
||||
// ====================
|
||||
// Format is : MajorVer.MinorVer.DayMonth.Year"
|
||||
// MajorVer changes only with significant changes
|
||||
// MinorVer changes when additional features are added, but not for bug fixes (range 00-99)
|
||||
// DayDate & Year changes for all changes, including for bug fixes. It represent the release date of the update
|
||||
//
|
||||
#define MODES_DUMP1090_VERSION "1.10.3010.14"
|
||||
// // File Version number
|
||||
// // ====================
|
||||
// // Format is : MajorVer.MinorVer.DayMonth.Year"
|
||||
// // MajorVer changes only with significant changes
|
||||
// // MinorVer changes when additional features are added, but not for bug fixes (range 00-99)
|
||||
// // DayDate & Year changes for all changes, including for bug fixes. It represent the release date of the update
|
||||
// //
|
||||
// #define MODES_DUMP1090_VERSION "1.10.3010.14"
|
||||
|
||||
// ============================= Include files ==========================
|
||||
// // ============================= Include files ==========================
|
||||
|
||||
#ifndef _WIN32
|
||||
// #ifndef _WIN32
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -50,26 +50,28 @@
|
|||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <math.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
// #include <sys/time.h>
|
||||
#include <sys/timeb.h>
|
||||
#include <signal.h>
|
||||
#include <fcntl.h>
|
||||
// #include <fcntl.h>
|
||||
#include <ctype.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include "rtl-sdr.h"
|
||||
// #include <sys/ioctl.h>
|
||||
// // #include "rtl-sdr.h"
|
||||
#include "anet.h"
|
||||
#else
|
||||
#include "winstubs.h" //Put everything Windows specific in here
|
||||
#include "rtl-sdr.h"
|
||||
#include "anet.h"
|
||||
#endif
|
||||
// #else
|
||||
// #include "winstubs.h" //Put everything Windows specific in here
|
||||
// #include "rtl-sdr.h"
|
||||
// #include "anet.h"
|
||||
// #endif
|
||||
|
||||
// ============================= #defines ===============================
|
||||
//
|
||||
// If you have a valid coaa.h, these values will come from it. If not,
|
||||
// then you can enter your own values in the #else section here
|
||||
//
|
||||
// // ============================= #defines ===============================
|
||||
// //
|
||||
// // If you have a valid coaa.h, these values will come from it. If not,
|
||||
// // then you can enter your own values in the #else section here
|
||||
// //
|
||||
#ifdef USER_LATITUDE
|
||||
#define MODES_USER_LATITUDE_DFLT (USER_LATITUDE)
|
||||
#define MODES_USER_LONGITUDE_DFLT (USER_LONGITUDE)
|
||||
|
@ -78,27 +80,27 @@
|
|||
#define MODES_USER_LONGITUDE_DFLT (0.0)
|
||||
#endif
|
||||
|
||||
#define MODES_DEFAULT_PPM 52
|
||||
#define MODES_DEFAULT_RATE 2000000
|
||||
#define MODES_DEFAULT_FREQ 1090000000
|
||||
#define MODES_DEFAULT_WIDTH 1000
|
||||
#define MODES_DEFAULT_HEIGHT 700
|
||||
// #define MODES_DEFAULT_PPM 52
|
||||
// #define MODES_DEFAULT_RATE 2000000
|
||||
// #define MODES_DEFAULT_FREQ 1090000000
|
||||
// #define MODES_DEFAULT_WIDTH 1000
|
||||
// #define MODES_DEFAULT_HEIGHT 700
|
||||
#define MODES_ASYNC_BUF_NUMBER 16
|
||||
#define MODES_ASYNC_BUF_SIZE (16*16384) // 256k
|
||||
#define MODES_ASYNC_BUF_SAMPLES (MODES_ASYNC_BUF_SIZE / 2) // Each sample is 2 bytes
|
||||
#define MODES_AUTO_GAIN -100 // Use automatic gain
|
||||
#define MODES_MAX_GAIN 999999 // Use max available gain
|
||||
#define MODES_MSG_SQUELCH_LEVEL 0x02FF // Average signal strength limit
|
||||
#define MODES_MSG_ENCODER_ERRS 3 // Maximum number of encoding errors
|
||||
// #define MODES_ASYNC_BUF_SIZE (16*16384) // 256k
|
||||
// #define MODES_ASYNC_BUF_SAMPLES (MODES_ASYNC_BUF_SIZE / 2) // Each sample is 2 bytes
|
||||
// #define MODES_AUTO_GAIN -100 // Use automatic gain
|
||||
// #define MODES_MAX_GAIN 999999 // Use max available gain
|
||||
// #define MODES_MSG_SQUELCH_LEVEL 0x02FF // Average signal strength limit
|
||||
// #define MODES_MSG_ENCODER_ERRS 3 // Maximum number of encoding errors
|
||||
|
||||
// When changing, change also fixBitErrors() and modesInitErrorTable() !!
|
||||
// // When changing, change also fixBitErrors() and modesInitErrorTable() !!
|
||||
#define MODES_MAX_BITERRORS 2 // Global max for fixable bit erros
|
||||
|
||||
#define MODEAC_MSG_SAMPLES (25 * 2) // include up to the SPI bit
|
||||
// #define MODEAC_MSG_SAMPLES (25 * 2) // include up to the SPI bit
|
||||
#define MODEAC_MSG_BYTES 2
|
||||
#define MODEAC_MSG_SQUELCH_LEVEL 0x07FF // Average signal strength limit
|
||||
#define MODEAC_MSG_FLAG (1<<0)
|
||||
#define MODEAC_MSG_MODES_HIT (1<<1)
|
||||
// #define MODEAC_MSG_MODES_HIT (1<<1)
|
||||
#define MODEAC_MSG_MODEA_HIT (1<<2)
|
||||
#define MODEAC_MSG_MODEC_HIT (1<<3)
|
||||
#define MODEAC_MSG_MODEA_ONLY (1<<4)
|
||||
|
@ -112,13 +114,13 @@
|
|||
#define MODES_LONG_MSG_BITS (MODES_LONG_MSG_BYTES * 8)
|
||||
#define MODES_SHORT_MSG_BITS (MODES_SHORT_MSG_BYTES * 8)
|
||||
#define MODES_LONG_MSG_SAMPLES (MODES_LONG_MSG_BITS * 2)
|
||||
#define MODES_SHORT_MSG_SAMPLES (MODES_SHORT_MSG_BITS * 2)
|
||||
#define MODES_LONG_MSG_SIZE (MODES_LONG_MSG_SAMPLES * sizeof(uint16_t))
|
||||
#define MODES_SHORT_MSG_SIZE (MODES_SHORT_MSG_SAMPLES * sizeof(uint16_t))
|
||||
// #define MODES_SHORT_MSG_SAMPLES (MODES_SHORT_MSG_BITS * 2)
|
||||
// #define MODES_LONG_MSG_SIZE (MODES_LONG_MSG_SAMPLES * sizeof(uint16_t))
|
||||
// #define MODES_SHORT_MSG_SIZE (MODES_SHORT_MSG_SAMPLES * sizeof(uint16_t))
|
||||
|
||||
#define MODES_RAWOUT_BUF_SIZE (1500)
|
||||
#define MODES_RAWOUT_BUF_FLUSH (MODES_RAWOUT_BUF_SIZE - 200)
|
||||
#define MODES_RAWOUT_BUF_RATE (1000) // 1000 * 64mS = 1 Min approx
|
||||
// #define MODES_RAWOUT_BUF_SIZE (1500)
|
||||
// #define MODES_RAWOUT_BUF_FLUSH (MODES_RAWOUT_BUF_SIZE - 200)
|
||||
// #define MODES_RAWOUT_BUF_RATE (1000) // 1000 * 64mS = 1 Min approx
|
||||
|
||||
#define MODES_ICAO_CACHE_LEN 1024 // Power of two required
|
||||
#define MODES_ICAO_CACHE_TTL 60 // Time to live of cached addresses
|
||||
|
@ -146,45 +148,45 @@
|
|||
|
||||
#define MODES_ACFLAGS_LLEITHER_VALID (MODES_ACFLAGS_LLEVEN_VALID | MODES_ACFLAGS_LLODD_VALID)
|
||||
#define MODES_ACFLAGS_LLBOTH_VALID (MODES_ACFLAGS_LLEVEN_VALID | MODES_ACFLAGS_LLODD_VALID)
|
||||
#define MODES_ACFLAGS_AOG_GROUND (MODES_ACFLAGS_AOG_VALID | MODES_ACFLAGS_AOG)
|
||||
// #define MODES_ACFLAGS_AOG_GROUND (MODES_ACFLAGS_AOG_VALID | MODES_ACFLAGS_AOG)
|
||||
|
||||
#define MODES_DEBUG_DEMOD (1<<0)
|
||||
#define MODES_DEBUG_DEMODERR (1<<1)
|
||||
#define MODES_DEBUG_BADCRC (1<<2)
|
||||
#define MODES_DEBUG_GOODCRC (1<<3)
|
||||
#define MODES_DEBUG_NOPREAMBLE (1<<4)
|
||||
// #define MODES_DEBUG_DEMOD (1<<0)
|
||||
// #define MODES_DEBUG_DEMODERR (1<<1)
|
||||
// #define MODES_DEBUG_BADCRC (1<<2)
|
||||
// #define MODES_DEBUG_GOODCRC (1<<3)
|
||||
// #define MODES_DEBUG_NOPREAMBLE (1<<4)
|
||||
#define MODES_DEBUG_NET (1<<5)
|
||||
#define MODES_DEBUG_JS (1<<6)
|
||||
// #define MODES_DEBUG_JS (1<<6)
|
||||
|
||||
// When debug is set to MODES_DEBUG_NOPREAMBLE, the first sample must be
|
||||
// at least greater than a given level for us to dump the signal.
|
||||
#define MODES_DEBUG_NOPREAMBLE_LEVEL 25
|
||||
// // When debug is set to MODES_DEBUG_NOPREAMBLE, the first sample must be
|
||||
// // at least greater than a given level for us to dump the signal.
|
||||
// #define MODES_DEBUG_NOPREAMBLE_LEVEL 25
|
||||
|
||||
#define MODES_INTERACTIVE_REFRESH_TIME 250 // Milliseconds
|
||||
#define MODES_INTERACTIVE_ROWS 22 // Rows on screen
|
||||
// #define MODES_INTERACTIVE_REFRESH_TIME 250 // Milliseconds
|
||||
// #define MODES_INTERACTIVE_ROWS 22 // Rows on screen
|
||||
#define MODES_INTERACTIVE_DELETE_TTL 300 // Delete from the list after 300 seconds
|
||||
#define MODES_INTERACTIVE_DISPLAY_TTL 60 // Delete from display after 60 seconds
|
||||
|
||||
#define MODES_NET_HEARTBEAT_RATE 900 // Each block is approx 65mS - default is > 1 min
|
||||
// #define MODES_NET_HEARTBEAT_RATE 900 // Each block is approx 65mS - default is > 1 min
|
||||
|
||||
#define MODES_NET_SERVICES_NUM 6
|
||||
#define MODES_NET_INPUT_RAW_PORT 30001
|
||||
#define MODES_NET_OUTPUT_RAW_PORT 30002
|
||||
#define MODES_NET_OUTPUT_SBS_PORT 30003
|
||||
#define MODES_NET_INPUT_BEAST_PORT 30004
|
||||
// #define MODES_NET_INPUT_RAW_PORT 30001
|
||||
// #define MODES_NET_OUTPUT_RAW_PORT 30002
|
||||
// #define MODES_NET_OUTPUT_SBS_PORT 30003
|
||||
// #define MODES_NET_INPUT_BEAST_PORT 30004
|
||||
#define MODES_NET_OUTPUT_BEAST_PORT 30005
|
||||
#define MODES_NET_HTTP_PORT 8080
|
||||
// #define MODES_NET_HTTP_PORT 8080
|
||||
#define MODES_CLIENT_BUF_SIZE 1024
|
||||
#define MODES_NET_SNDBUF_SIZE (1024*64)
|
||||
#define MODES_NET_SNDBUF_MAX (7)
|
||||
// #define MODES_NET_SNDBUF_SIZE (1024*64)
|
||||
// #define MODES_NET_SNDBUF_MAX (7)
|
||||
|
||||
#ifndef HTMLPATH
|
||||
#define HTMLPATH "./public_html" // default path for gmap.html etc
|
||||
#endif
|
||||
// #ifndef HTMLPATH
|
||||
// #define HTMLPATH "./public_html" // default path for gmap.html etc
|
||||
// #endif
|
||||
|
||||
#define MODES_NOTUSED(V) ((void) V)
|
||||
|
||||
//======================== structure declarations =========================
|
||||
// //======================== structure declarations =========================
|
||||
|
||||
// Structure used to describe a networking client
|
||||
struct client {
|
||||
|
@ -263,7 +265,7 @@ typedef struct Modes{ // Internal state
|
|||
int dev_index;
|
||||
int gain;
|
||||
int enable_agc;
|
||||
rtlsdr_dev_t *dev;
|
||||
// rtlsdr_dev_t *dev;
|
||||
int freq;
|
||||
int ppm_error;
|
||||
|
||||
|
@ -418,7 +420,7 @@ struct modesMessage {
|
|||
int bFlags; // Flags related to fields in this structure
|
||||
};
|
||||
|
||||
// ======================== function declarations =========================
|
||||
// // ======================== function declarations =========================
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -449,7 +451,8 @@ struct aircraft* interactiveReceiveData(Modes *modes, struct modesMessage *mm);
|
|||
void interactiveShowData(void);
|
||||
void interactiveRemoveStaleAircrafts(Modes *modes);
|
||||
int decodeBinMessage (Modes *modes, struct client *c, char *p);
|
||||
// struct aircraft *interactiveFindAircraft(uint32_t addr);
|
||||
struct aircraft *interactiveFindAircraft(Modes *modes, uint32_t addr);
|
||||
|
||||
struct stDF *interactiveFindDF (uint32_t addr);
|
||||
|
||||
//
|
||||
|
|
61
flake.lock
61
flake.lock
|
@ -1,61 +0,0 @@
|
|||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1731533236,
|
||||
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1739758141,
|
||||
"narHash": "sha256-uq6A2L7o1/tR6VfmYhZWoVAwb3gTy7j4Jx30MIrH0rE=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "c618e28f70257593de75a7044438efc1c1fc0791",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-24.11",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
50
flake.nix
50
flake.nix
|
@ -1,50 +0,0 @@
|
|||
{
|
||||
# TODO desc
|
||||
description = "viz1090";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
};
|
||||
|
||||
outputs = {
|
||||
self,
|
||||
nixpkgs,
|
||||
flake-utils,
|
||||
}:
|
||||
flake-utils.lib.eachDefaultSystem (system: let
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
};
|
||||
in rec
|
||||
{
|
||||
# Nix formatter, run using `$ nix fmt`
|
||||
formatter = pkgs.alejandra;
|
||||
|
||||
# Exports the package
|
||||
# Build with `$ nix build`
|
||||
packages.viz1090 = pkgs.callPackage ./nix/viz1090.nix {inherit self system;};
|
||||
packages.viz1090-mapdata = pkgs.callPackage ./nix/viz1090-mapdata.nix {};
|
||||
packages.default = packages.viz1090;
|
||||
|
||||
# Creates a shell with the necessary dependencies
|
||||
# Enter using `$ nix develop`
|
||||
devShell = pkgs.mkShell {
|
||||
buildInputs = with pkgs; [
|
||||
rtl-sdr-librtlsdr
|
||||
SDL2
|
||||
SDL2_ttf
|
||||
SDL2_gfx
|
||||
gdal
|
||||
python3
|
||||
python312Packages.pip
|
||||
python312Packages.shapely
|
||||
python312Packages.fiona
|
||||
python312Packages.tqdm
|
||||
unzip
|
||||
python312Packages.requests
|
||||
git
|
||||
];
|
||||
};
|
||||
});
|
||||
}
|
24
getmap.sh
24
getmap.sh
|
@ -1,24 +1,12 @@
|
|||
#!/bin/bash
|
||||
|
||||
mkdir -p mapdata
|
||||
pushd mapdata > /dev/null
|
||||
|
||||
wget --no-verbose https://naciscdn.org/naturalearth/10m/cultural/ne_10m_admin_1_states_provinces.zip
|
||||
wget --no-verbose https://naciscdn.org/naturalearth/10m/cultural/ne_10m_populated_places.zip
|
||||
wget --no-verbose https://naciscdn.org/naturalearth/10m/cultural/ne_10m_airports.zip
|
||||
wget https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/10m/cultural/ne_10m_admin_1_states_provinces.zip
|
||||
wget https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/10m/cultural/ne_10m_populated_places.zip
|
||||
wget https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/10m/cultural/ne_10m_airports.zip
|
||||
|
||||
#this may not be up to date
|
||||
wget --no-verbose https://opendata.arcgis.com/datasets/4d8fa46181aa470d809776c57a8ab1f6_0.zip
|
||||
wget https://opendata.arcgis.com/datasets/4d8fa46181aa470d809776c57a8ab1f6_0.zip
|
||||
|
||||
for file in *.zip; do
|
||||
unzip -o "${file}"
|
||||
rm "${file}"
|
||||
done
|
||||
unzip '*.zip'
|
||||
|
||||
popd > /dev/null
|
||||
|
||||
python3 mapconverter.py \
|
||||
--mapfile mapdata/ne_10m_admin_1_states_provinces.shp \
|
||||
--mapnames mapdata/ne_10m_populated_places.shp \
|
||||
--airportfile mapdata/Runways.shp \
|
||||
--airportnames mapdata/ne_10m_airports.shp
|
||||
python3 mapconverter.py --mapfile ne_10m_admin_1_states_provinces.shp --mapnames ne_10m_populated_places.shp --airportfile Runways.shp --airportnames ne_10m_airports.shp
|
|
@ -38,7 +38,7 @@ def extractLines(shapefile, tolerance):
|
|||
elif(simplified.geom_type == "MultiPolygon" or simplified.geom_type == "Polygon"):
|
||||
|
||||
if(simplified.boundary.geom_type == "MultiLineString"):
|
||||
for boundary in simplified.boundary.geoms:
|
||||
for boundary in simplified.boundary:
|
||||
outlist.extend(convertLinestring(boundary))
|
||||
else:
|
||||
outlist.extend(convertLinestring(simplified.boundary))
|
||||
|
|
|
@ -1,69 +0,0 @@
|
|||
{
|
||||
lib,
|
||||
pkgs,
|
||||
stdenv,
|
||||
fetchFromGitea,
|
||||
}: let
|
||||
runways = fetchTarball {
|
||||
url = "https://opendata.arcgis.com/datasets/4d8fa46181aa470d809776c57a8ab1f6_0.zip";
|
||||
sha256 = "sha256:1ivwx8glk8yk68nmqz467yzvlb3l66l1s3ibmd9p41wz737lmz88";
|
||||
};
|
||||
provinces = fetchTarball {
|
||||
url = "https://naciscdn.org/naturalearth/10m/cultural/ne_10m_admin_1_states_provinces.zip";
|
||||
sha256 = "sha256:06ai02b8rfsfzpa0gq4nsg29lxvwy4zvjw44099hc78vr7dkfsdp";
|
||||
};
|
||||
places = fetchTarball {
|
||||
url = "https://naciscdn.org/naturalearth/10m/cultural/ne_10m_populated_places.zip";
|
||||
sha256 = "sha256:1dhh569520f02yml1m5zp2znjv85cqbccl4nvpmigynxd37kid3j";
|
||||
};
|
||||
airports = fetchTarball {
|
||||
url = "https://naciscdn.org/naturalearth/10m/cultural/ne_10m_airports.zip";
|
||||
sha256 = "sha256:0893zg63ygr2l2d1wpyigls1syfkryjlygvnbbjikpqk5i5cwr56";
|
||||
};
|
||||
in
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "viz1090-mapdata";
|
||||
version = "0.1.0";
|
||||
|
||||
src = fetchFromGitea {
|
||||
domain = "git.vulpecula.zone";
|
||||
owner = "tasiaiso";
|
||||
repo = pname;
|
||||
rev = "d1f53019b22a9e605506bed90fcffcdc5f7e6186";
|
||||
hash = "sha256-gtv0u7o+5fqVgA0CHDWdZr0h9A1Nbky1+okHvSv1cVU=";
|
||||
};
|
||||
|
||||
nativeBuildInputs = with pkgs; [
|
||||
python3
|
||||
python312Packages.pip
|
||||
python312Packages.shapely
|
||||
python312Packages.fiona
|
||||
python312Packages.tqdm
|
||||
python312Packages.requests
|
||||
];
|
||||
|
||||
buildPhase = ''
|
||||
mkdir -p mapdata
|
||||
|
||||
cp ${runways}/* mapdata
|
||||
cp ${provinces}/* mapdata
|
||||
cp ${places}/* mapdata
|
||||
cp ${airports}/* mapdata
|
||||
# ls -al mapdata
|
||||
|
||||
python3 mapconverter.py \
|
||||
--mapfile mapdata/ne_10m_admin_1_states_provinces.shp \
|
||||
--mapnames mapdata/ne_10m_populated_places.shp \
|
||||
--airportfile mapdata/Runways.shp \
|
||||
--airportnames mapdata/ne_10m_airports.shp
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out
|
||||
|
||||
cp airportdata.bin $out
|
||||
cp airportnames $out
|
||||
cp mapdata.bin $out
|
||||
cp mapnames $out
|
||||
'';
|
||||
}
|
|
@ -1,93 +0,0 @@
|
|||
{
|
||||
lib,
|
||||
pkgs,
|
||||
stdenv,
|
||||
fetchFromGitea,
|
||||
self,
|
||||
system,
|
||||
}: let
|
||||
viz1090-mapdata = self.packages.${system}.viz1090-mapdata;
|
||||
in
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "viz1090";
|
||||
version = "0.1.0";
|
||||
|
||||
src = fetchFromGitea {
|
||||
domain = "git.vulpecula.zone";
|
||||
owner = "tasiaiso";
|
||||
repo = pname;
|
||||
rev = "1922324b40f84fd449cec3fbfdade8aa33597bf6";
|
||||
hash = "sha256-bPVFKbGtPXOitzzHb3yJ6XW3fRh8PF/7kfP7EJkJX3c=";
|
||||
};
|
||||
|
||||
nativeBuildInputs = with pkgs; [
|
||||
rtl-sdr-librtlsdr
|
||||
SDL2
|
||||
SDL2_ttf
|
||||
SDL2_gfx
|
||||
gdal
|
||||
git
|
||||
];
|
||||
|
||||
buildInputs = [
|
||||
viz1090-mapdata
|
||||
];
|
||||
|
||||
buildPhase = ''
|
||||
echo "diff --git a/Makefile b/Makefile
|
||||
index 5e60779..d5b30ab 100644
|
||||
--- a/Makefile
|
||||
+++ b/Makefile
|
||||
@@ -3,7 +3,7 @@
|
||||
# sure that the variable PREFIX is defined, e.g. make PREFIX=/usr/local
|
||||
#
|
||||
|
||||
-CXXFLAGS=-O2 -std=c++11 -g
|
||||
+CXXFLAGS=-O2 -std=c++11 -g -I ${pkgs.SDL2.dev}/include/SDL2/
|
||||
LIBS= -lm -lSDL2 -lSDL2_ttf -lSDL2_gfx -g
|
||||
CXX=g++
|
||||
|
||||
diff --git a/Map.cpp b/Map.cpp
|
||||
index cd798ec..c5736bd 100644
|
||||
--- a/Map.cpp
|
||||
+++ b/Map.cpp
|
||||
@@ -189,7 +189,7 @@ std::vector<Line*> Map::getLines(float screen_lat_min, float screen_lat_max, flo
|
||||
Map::Map() {
|
||||
FILE *fileptr;
|
||||
|
||||
- if((fileptr = fopen(\"mapdata.bin\", \"rb\"))) {
|
||||
+ if((fileptr = fopen(\"${viz1090-mapdata}/mapdata.bin\", \"rb\"))) {
|
||||
|
||||
|
||||
fseek(fileptr, 0, SEEK_END);
|
||||
@@ -255,7 +255,7 @@ Map::Map() {
|
||||
//
|
||||
|
||||
|
||||
- if((fileptr = fopen(\"airportdata.bin\", \"rb\"))) {
|
||||
+ if((fileptr = fopen(\"${viz1090-mapdata}/airportdata.bin\", \"rb\"))) {
|
||||
fseek(fileptr, 0, SEEK_END);
|
||||
airportPoints_count = ftell(fileptr) / sizeof(float);
|
||||
rewind(fileptr);
|
||||
@@ -350,7 +350,7 @@ Map::Map() {
|
||||
|
||||
infile.close();
|
||||
|
||||
- infile.open(\"airportnames\");
|
||||
+ infile.open(\"${viz1090-mapdata}/airportnames\");
|
||||
|
||||
|
||||
while (std::getline(infile, line))
|
||||
|
||||
" | git apply -
|
||||
|
||||
cat Map.cpp | grep mapdata
|
||||
|
||||
make -j $NIX_BUILD_CORES
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
cp -v viz1090 $out/bin
|
||||
'';
|
||||
}
|
3
run.sh
Executable file
3
run.sh
Executable file
|
@ -0,0 +1,3 @@
|
|||
#!/bin/bash
|
||||
../dump1090/dump1090 --fix --aggressive --net --quiet &
|
||||
./viz1090 --fps --fullscreen --screensize 240 320 --lat 47.6 --lon -122.3
|
|
@ -1,2 +1,2 @@
|
|||
#!/bin/bash
|
||||
./viz1090 --screensize 640 360 --fullscreen --server adsb --lat 47.6 --lon -122.3
|
||||
./viz1090 --screensize 1920 1080 --fullscreen --server adsb --lat 47.6 --lon -122.3
|
||||
|
|
84
view1090.h
84
view1090.h
|
@ -1,84 +0,0 @@
|
|||
// view1090, a Mode S messages viewer for dump1090 devices.
|
||||
//
|
||||
// Copyright (C) 2013 by Malcolm Robb <Support@ATTAvionics.com>
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
#ifndef __VIEW1090_H
|
||||
#define __VIEW1090_H
|
||||
|
||||
// ============================= Include files ==========================
|
||||
|
||||
#include "dump1090.h"
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <pthread.h>
|
||||
#include <stdint.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <math.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/timeb.h>
|
||||
#include <signal.h>
|
||||
#include <fcntl.h>
|
||||
#include <ctype.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include "rtl-sdr.h"
|
||||
#include "anet.h"
|
||||
#else
|
||||
#include "winstubs.h" //Put everything Windows specific in here
|
||||
#endif
|
||||
|
||||
// ============================= #defines ===============================
|
||||
|
||||
#define VIEW1090_NET_OUTPUT_IP_ADDRESS "127.0.0.1"
|
||||
|
||||
#define NOTUSED(V) ((void) V)
|
||||
|
||||
// ======================== structure declarations ========================
|
||||
|
||||
// Program global state
|
||||
struct { // Internal state
|
||||
// Networking
|
||||
char net_input_beast_ipaddr[32]; // IPv4 address or network name of server/RPi
|
||||
} View1090;
|
||||
|
||||
// ======================== function declarations =========================
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __VIEW1090_H
|
22
viz1090.cpp
22
viz1090.cpp
|
@ -33,7 +33,6 @@
|
|||
#include "View.h"
|
||||
#include "Input.h"
|
||||
#include <cstring>
|
||||
|
||||
int go = 1;
|
||||
|
||||
|
||||
|
@ -69,18 +68,12 @@ void showHelp(void) {
|
|||
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int j;
|
||||
|
||||
AppData appData;
|
||||
View view(&appData);
|
||||
Input input(&appData,&view);
|
||||
|
||||
signal(SIGINT, SIG_DFL); // reset signal handler - bit extra safety
|
||||
|
||||
appData.initialize();
|
||||
|
||||
// Parse the command line options
|
||||
for (j = 1; j < argc; j++) {
|
||||
for (int j = 1; j < argc; j++) {
|
||||
int more = ((j + 1) < argc); // There are more arguments
|
||||
|
||||
if (!strcmp(argv[j],"--port") && more) {
|
||||
|
@ -116,19 +109,26 @@ int main(int argc, char **argv) {
|
|||
}
|
||||
}
|
||||
|
||||
int go;
|
||||
|
||||
appData.initialize();
|
||||
|
||||
view.SDL_init();
|
||||
view.font_init();
|
||||
|
||||
Input input(&appData,&view);
|
||||
|
||||
signal(SIGINT, SIG_DFL); // reset signal handler - bit extra safety
|
||||
|
||||
int go;
|
||||
|
||||
go = 1;
|
||||
|
||||
while (go == 1)
|
||||
{
|
||||
appData.connect();
|
||||
input.getInput();
|
||||
appData.update();
|
||||
view.draw();
|
||||
appData.connect();
|
||||
appData.update();
|
||||
}
|
||||
|
||||
appData.disconnect();
|
||||
|
|
Loading…
Reference in a new issue