add draw to matrix
This commit is contained in:
+9
-9
@@ -1,7 +1,7 @@
|
||||
#include "TrackedAircraft.h"
|
||||
#include "LEDMatrix.cpp"
|
||||
#include "Network.cpp"
|
||||
#include "SBS1Decoder.cpp"
|
||||
#include "TrackedAircraft.h"
|
||||
#include <arpa/inet.h>
|
||||
#include <climits>
|
||||
#include <cmath>
|
||||
@@ -21,8 +21,6 @@ struct FlightWallOpts {
|
||||
|
||||
class FlightWall {
|
||||
private:
|
||||
FlightWallOpts opts_;
|
||||
|
||||
// hex ident, all other info
|
||||
std::unordered_map<std::string, TrackedAircraft> tracked;
|
||||
double min_distance = INT_MAX;
|
||||
@@ -45,10 +43,11 @@ private:
|
||||
return EARTH_RADIUS_M * std::hypot(x, y);
|
||||
}
|
||||
|
||||
FlightWallOpts opts_;
|
||||
LEDMatrix m{&min_distance_aircraft};
|
||||
|
||||
public:
|
||||
FlightWall(FlightWallOpts opts) : opts_(opts) {
|
||||
LEDMatrix m(&min_distance_aircraft);
|
||||
}
|
||||
FlightWall(FlightWallOpts opts) : opts_(opts) {}
|
||||
|
||||
int start() {
|
||||
Network n(opts_.server_ip, opts_.port);
|
||||
@@ -56,7 +55,6 @@ public:
|
||||
char buffer[1024];
|
||||
std::string line;
|
||||
|
||||
|
||||
while (true) {
|
||||
ssize_t bytes_rec = recv(n.get_sock(), buffer, sizeof(buffer) - 1, 0);
|
||||
if (bytes_rec < 0) {
|
||||
@@ -137,8 +135,8 @@ public:
|
||||
|
||||
// update min distance and aircraft if changed
|
||||
if (parsed->latitude && parsed->longitude) {
|
||||
double parsed_dist =
|
||||
get_distance(opts_.lat, opts_.lon, *parsed->latitude, *parsed->longitude);
|
||||
double parsed_dist = get_distance(
|
||||
opts_.lat, opts_.lon, *parsed->latitude, *parsed->longitude);
|
||||
if (parsed_dist < min_distance) {
|
||||
min_distance = parsed_dist;
|
||||
min_aircraft_icao = parsed->hex_ident;
|
||||
@@ -150,6 +148,8 @@ public:
|
||||
std::cout << "Closest aircraft: " << min_aircraft_icao
|
||||
<< ", distance: " << min_distance << "m\n";
|
||||
|
||||
m.draw();
|
||||
|
||||
line.erase(0, pos + 1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user