add led matrix draw logic
This commit is contained in:
+12
-17
@@ -1,3 +1,5 @@
|
||||
#include "TrackedAircraft.h"
|
||||
#include "LEDMatrix.cpp"
|
||||
#include "Network.cpp"
|
||||
#include "SBS1Decoder.cpp"
|
||||
#include <arpa/inet.h>
|
||||
@@ -21,21 +23,15 @@ class FlightWall {
|
||||
private:
|
||||
FlightWallOpts opts_;
|
||||
|
||||
// hex ident, all other info
|
||||
std::unordered_map<std::string, TrackedAircraft> tracked;
|
||||
double min_distance = INT_MAX;
|
||||
std::string min_aircraft_icao;
|
||||
TrackedAircraft min_distance_aircraft;
|
||||
|
||||
static constexpr double EARTH_RADIUS_M = 6371000.0;
|
||||
static constexpr double DEG_TO_RAD = M_PI / 180.0;
|
||||
|
||||
struct TrackedAircraft {
|
||||
std::optional<std::string> callsign; // Field 10
|
||||
std::optional<int> altitude; // Field 11 (ft)
|
||||
std::optional<double> ground_speed; // Field 12 (knots)
|
||||
std::optional<double> track; // Field 13 (degrees)
|
||||
std::optional<double> latitude; // Field 14
|
||||
std::optional<double> longitude; // Field 15
|
||||
std::optional<int> vertical_rate; // Field 16 (ft/min)
|
||||
std::optional<bool> emergency; // Field 19
|
||||
std::time_t last_seen;
|
||||
};
|
||||
|
||||
static double get_distance(double lat1, double lon1, double lat2,
|
||||
double lon2) {
|
||||
double lat1Rad = lat1 * DEG_TO_RAD;
|
||||
@@ -50,7 +46,9 @@ private:
|
||||
}
|
||||
|
||||
public:
|
||||
FlightWall(FlightWallOpts opts) : opts_(opts) {}
|
||||
FlightWall(FlightWallOpts opts) : opts_(opts) {
|
||||
LEDMatrix m(&min_distance_aircraft);
|
||||
}
|
||||
|
||||
int start() {
|
||||
Network n(opts_.server_ip, opts_.port);
|
||||
@@ -58,10 +56,6 @@ public:
|
||||
char buffer[1024];
|
||||
std::string line;
|
||||
|
||||
// hex ident, all other info
|
||||
std::unordered_map<std::string, TrackedAircraft> tracked;
|
||||
double min_distance = INT_MAX;
|
||||
std::string min_aircraft_icao;
|
||||
|
||||
while (true) {
|
||||
ssize_t bytes_rec = recv(n.get_sock(), buffer, sizeof(buffer) - 1, 0);
|
||||
@@ -148,6 +142,7 @@ public:
|
||||
if (parsed_dist < min_distance) {
|
||||
min_distance = parsed_dist;
|
||||
min_aircraft_icao = parsed->hex_ident;
|
||||
min_distance_aircraft = tracked.find(parsed->hex_ident)->second;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user