draw aircraft

This commit is contained in:
2026-08-05 13:05:30 +02:00
parent 25824ac2f9
commit 704126fd3f
10 changed files with 66 additions and 7 deletions
+23 -2
View File
@@ -10,6 +10,8 @@
#include <cstdio>
#include <format>
#include <iostream>
#include "core/global.hpp"
#include "core/geo.hpp"
int main() {
if (hal::init() != 0) {
@@ -24,8 +26,6 @@ int main() {
const uint16_t middle_x = (screen_w / 2);
const uint16_t middle_y = (screen_h / 2);
float receiver_lat;
float receiver_lon;
{
nlohmann::json receiver =
net::http_get_json(std::format("{}/receiver.json", base_url));
@@ -72,6 +72,27 @@ int main() {
}
}
{ // draw planes
nlohmann::json aircraft = net::http_get_json(std::format("{}/aircraft.json", base_url));
if (aircraft!= nullptr) {
for(nlohmann::json &craft : aircraft["aircraft"]) {
try {
const auto [x_offset,y_offset] = get_offset_from_station(craft["lat"].get<double>(), craft["lon"].get<double>());
const uint16_t x_center = middle_x+((x_offset/1000)*pixels_per_km);
const uint16_t y_center = middle_y+((y_offset/1000)*pixels_per_km);
draw::pixel(x_center, y_center, {0xff,0x68,0x00});
draw::rhombus(x_center, y_center, 8/*TODO: remove magic*/,{0xff,0x68,0x00});
} catch(...) {
std::clog << YELLOW"[WARNING]" RESET " aircraft with no lat/lon data detected!\n";
}
}
} else {
// TODO draw vizual error
std::cerr << RED"[ERROR]" RESET " failed to get aircraft\n";
}
}
hal::end_frame();
}
}