Compare commits

..
2 Commits
Author SHA1 Message Date
dylan d550e78d96 add draw to matrix 2026-11-15 20:49:47 +00:00
dylan 6f43e21ef9 update readme 2026-11-15 20:49:39 +00:00
3 changed files with 29 additions and 28 deletions
+9 -9
View File
@@ -1,7 +1,7 @@
#include "TrackedAircraft.h"
#include "LEDMatrix.cpp" #include "LEDMatrix.cpp"
#include "Network.cpp" #include "Network.cpp"
#include "SBS1Decoder.cpp" #include "SBS1Decoder.cpp"
#include "TrackedAircraft.h"
#include <arpa/inet.h> #include <arpa/inet.h>
#include <climits> #include <climits>
#include <cmath> #include <cmath>
@@ -21,8 +21,6 @@ struct FlightWallOpts {
class FlightWall { class FlightWall {
private: private:
FlightWallOpts opts_;
// hex ident, all other info // hex ident, all other info
std::unordered_map<std::string, TrackedAircraft> tracked; std::unordered_map<std::string, TrackedAircraft> tracked;
double min_distance = INT_MAX; double min_distance = INT_MAX;
@@ -45,10 +43,11 @@ private:
return EARTH_RADIUS_M * std::hypot(x, y); return EARTH_RADIUS_M * std::hypot(x, y);
} }
FlightWallOpts opts_;
LEDMatrix m{&min_distance_aircraft};
public: public:
FlightWall(FlightWallOpts opts) : opts_(opts) { FlightWall(FlightWallOpts opts) : opts_(opts) {}
LEDMatrix m(&min_distance_aircraft);
}
int start() { int start() {
Network n(opts_.server_ip, opts_.port); Network n(opts_.server_ip, opts_.port);
@@ -56,7 +55,6 @@ public:
char buffer[1024]; char buffer[1024];
std::string line; std::string line;
while (true) { while (true) {
ssize_t bytes_rec = recv(n.get_sock(), buffer, sizeof(buffer) - 1, 0); ssize_t bytes_rec = recv(n.get_sock(), buffer, sizeof(buffer) - 1, 0);
if (bytes_rec < 0) { if (bytes_rec < 0) {
@@ -137,8 +135,8 @@ public:
// update min distance and aircraft if changed // update min distance and aircraft if changed
if (parsed->latitude && parsed->longitude) { if (parsed->latitude && parsed->longitude) {
double parsed_dist = double parsed_dist = get_distance(
get_distance(opts_.lat, opts_.lon, *parsed->latitude, *parsed->longitude); opts_.lat, opts_.lon, *parsed->latitude, *parsed->longitude);
if (parsed_dist < min_distance) { if (parsed_dist < min_distance) {
min_distance = parsed_dist; min_distance = parsed_dist;
min_aircraft_icao = parsed->hex_ident; min_aircraft_icao = parsed->hex_ident;
@@ -150,6 +148,8 @@ public:
std::cout << "Closest aircraft: " << min_aircraft_icao std::cout << "Closest aircraft: " << min_aircraft_icao
<< ", distance: " << min_distance << "m\n"; << ", distance: " << min_distance << "m\n";
m.draw();
line.erase(0, pos + 1); line.erase(0, pos + 1);
} }
} }
+19 -19
View File
@@ -70,6 +70,25 @@ private:
return {operator_or_reg, flight_number}; return {operator_or_reg, flight_number};
} }
void draw_display_text() {
for (Text t : display_text) {
rgb_matrix::DrawText(canvas, font, t.x, t.y + font.baseline(), t.color,
NULL, t.text.c_str(), t.spacing);
}
rgb_matrix::DrawText(canvas, font, flight_number.x, flight_number.y + font.baseline(), flight_number.color,
NULL, flight_number.text.c_str(), flight_number.spacing);
rgb_matrix::DrawText(canvas, font, flight_operator.x, flight_operator.y + font.baseline(), flight_operator.color,
NULL, flight_operator.text.c_str(), flight_operator.spacing);
rgb_matrix::DrawText(canvas, font, altitude.x, altitude.y + font.baseline(), altitude.color,
NULL, altitude.text.c_str(), altitude.spacing);
rgb_matrix::DrawText(canvas, font, speed.x, speed.y + font.baseline(), speed.color,
NULL, speed.text.c_str(), speed.spacing);
rgb_matrix::DrawText(canvas, font, track.x, track.y + font.baseline(), track.color,
NULL, track.text.c_str(), track.spacing);
rgb_matrix::DrawText(canvas, font, vertical_speed.x, vertical_speed.y + font.baseline(), vertical_speed.color,
NULL, vertical_speed.text.c_str(), vertical_speed.spacing);
}
public: public:
LEDMatrix() {}; LEDMatrix() {};
@@ -100,25 +119,6 @@ public:
~LEDMatrix() { delete canvas; } ~LEDMatrix() { delete canvas; }
void draw_display_text() {
for (Text t : display_text) {
rgb_matrix::DrawText(canvas, font, t.x, t.y + font.baseline(), t.color,
NULL, t.text.c_str(), t.spacing);
}
rgb_matrix::DrawText(canvas, font, flight_number.x, flight_number.y + font.baseline(), flight_number.color,
NULL, flight_number.text.c_str(), flight_number.spacing);
rgb_matrix::DrawText(canvas, font, flight_operator.x, flight_operator.y + font.baseline(), flight_operator.color,
NULL, flight_operator.text.c_str(), flight_operator.spacing);
rgb_matrix::DrawText(canvas, font, altitude.x, altitude.y + font.baseline(), altitude.color,
NULL, altitude.text.c_str(), altitude.spacing);
rgb_matrix::DrawText(canvas, font, speed.x, speed.y + font.baseline(), speed.color,
NULL, speed.text.c_str(), speed.spacing);
rgb_matrix::DrawText(canvas, font, track.x, track.y + font.baseline(), track.color,
NULL, track.text.c_str(), track.spacing);
rgb_matrix::DrawText(canvas, font, vertical_speed.x, vertical_speed.y + font.baseline(), vertical_speed.color,
NULL, vertical_speed.text.c_str(), vertical_speed.spacing);
}
void draw() { void draw() {
if (!current_aircraft->callsign->empty()) { if (!current_aircraft->callsign->empty()) {
std::string current_callsign = *current_aircraft->callsign; std::string current_callsign = *current_aircraft->callsign;
+1
View File
@@ -1,3 +1,4 @@
### To clone ### To clone
`git clone --recurse-submodules `https://gitea.dylanbenzi.com/dylan/flightwall` `git clone --recurse-submodules `https://gitea.dylanbenzi.com/dylan/flightwall`
`git submodule update --init --recursive`