add receaver lat/lon

This commit is contained in:
2026-08-04 18:02:10 +02:00
parent 50e42ad0c2
commit 8e627364cb
51 changed files with 25437 additions and 14 deletions
+30 -9
View File
@@ -1,9 +1,15 @@
#include "../res/station.h"
#include "core/color.h"
#include "core/config.hpp"
#include "core/const.hpp"
#include "hal/draw.hpp"
#include "hal/hal.hpp"
#include "hal/net.hpp"
#include "nlohmann/json_fwd.hpp"
#include <cstdint>
#include <cstdio>
#include <format>
#include <iostream>
int main() {
if (hal::init() != 0) {
@@ -11,11 +17,27 @@ int main() {
}
const auto [screen_w, screen_h] = hal::get_screen_size();
const float pixels_per_km = static_cast<float>(screen_h > screen_w ? screen_w : screen_h) / (max_range*2);
const float pixels_per_km =
static_cast<float>(screen_h > screen_w ? screen_w : screen_h) /
(max_range * 2);
bool odd_even = true;
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));
try {
receiver_lat = receiver["lat"].get<float>();
receiver_lon = receiver["lon"].get<float>();
} catch (...) {
receiver_lat = FALLBACK_LAT;
receiver_lon = FALLBACK_LON;
std::cerr << BLUE "[INFO]" RESET " using fallback lat/lon\n";
}
}
while (true) {
hal::start_frame();
@@ -28,15 +50,15 @@ int main() {
}
{ // draw station
uint16_t y = middle_y - STATION_HEIGHT / 2;
for (uint8_t i = 0; i < STATION_HEIGHT; i++) {
uint16_t x = middle_x - STATION_WIDTH / 2;
for (uint8_t j = 0; j < STATION_WIDTH; j++) {
uint8_t byte = station[i * STATION_BYTES_PER_ROW + j / 8];
if((byte >> (7 - (j % 8))) & 1) {
draw::pixel(x, y, {0xff,0xff,0xff});
if ((byte >> (7 - (j % 8))) & 1) {
draw::pixel(x, y, {0xff, 0xff, 0xff});
}
x++;
}
@@ -44,13 +66,12 @@ int main() {
}
}
{ // draw rings
for(uint16_t r = first_ring_distance; r <= max_range; r *=2) {
draw::circle(middle_x, middle_y, r*pixels_per_km, {0xff,0xff,0xff});
}
{ // draw rings
for (uint16_t r = first_ring_distance; r <= max_range; r *= 2) {
draw::circle(middle_x, middle_y, r * pixels_per_km, {0xff, 0xff, 0xff});
}
}
hal::end_frame();
}
}