format
This commit is contained in:
+2
-1
@@ -8,4 +8,5 @@ compile_commands.json
|
||||
.config.*
|
||||
include/
|
||||
!scripts/include/
|
||||
*.o
|
||||
*.o
|
||||
test
|
||||
+31
-21
@@ -17,7 +17,6 @@
|
||||
#include <iostream>
|
||||
#include <numbers>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
|
||||
#ifndef CONFIG_AUTOSCALE
|
||||
constexpr
|
||||
@@ -135,9 +134,9 @@ int main() {
|
||||
" aircraft with no ground speed or track data detected!\n";
|
||||
speed = 0;
|
||||
track = 0;
|
||||
#ifndef CONFIG_METRIC
|
||||
#ifndef CONFIG_METRIC
|
||||
speed_knot = 0;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
draw::color_t color = get_altitude_color(altitude);
|
||||
try {
|
||||
@@ -161,32 +160,39 @@ int main() {
|
||||
|
||||
// speed in pixels per hour
|
||||
const float speed_pph = speed * pixels_per_km;
|
||||
|
||||
|
||||
// track in radians
|
||||
const float track_rad =
|
||||
std::fmod((track - 90), 360.0f) *
|
||||
(static_cast<float>(std::numbers::pi) / 180.0f);
|
||||
#ifdef CONFIG_VECTOR_FOLLOW_TRACK_RATE
|
||||
{
|
||||
float track_rate_rads;
|
||||
try {
|
||||
track_rate_rads = craft["track_rate"].get<float>() * (static_cast<float>(std::numbers::pi) / 180.0f);
|
||||
} catch (...) {
|
||||
std::clog << YELLOW
|
||||
"[WARNING]" RESET
|
||||
" aircraft with no track_rate data detected!\n";
|
||||
{
|
||||
float track_rate_rads;
|
||||
try {
|
||||
track_rate_rads =
|
||||
craft["track_rate"].get<float>() *
|
||||
(static_cast<float>(std::numbers::pi) / 180.0f);
|
||||
} catch (...) {
|
||||
std::clog
|
||||
<< YELLOW "[WARNING]" RESET
|
||||
" aircraft with no track_rate data detected!\n";
|
||||
track_rate_rads = 0;
|
||||
}
|
||||
draw::arc(x_center, y_center,track_rad,speed_pph/3600,track_rate_rads,CONFIG_TIME_BASED_VECTOR_LENGHT*60,color);
|
||||
}
|
||||
draw::arc(x_center, y_center, track_rad, speed_pph / 3600,
|
||||
track_rate_rads, CONFIG_TIME_BASED_VECTOR_LENGHT * 60,
|
||||
color);
|
||||
}
|
||||
#else
|
||||
// lenght of Time-Based Vector
|
||||
const float vector_lenght =
|
||||
(speed_pph / 60) * CONFIG_TIME_BASED_VECTOR_LENGHT;
|
||||
draw::line(x_center, y_center,
|
||||
std::clamp(x_center + (vector_lenght * std::cos(track_rad)),0.0f, static_cast<float>(UINT16_MAX)),
|
||||
std::clamp(y_center + (vector_lenght * std::sin(track_rad)),0.0f,static_cast<float>(UINT16_MAX)), color);
|
||||
// lenght of Time-Based Vector
|
||||
const float vector_lenght =
|
||||
(speed_pph / 60) * CONFIG_TIME_BASED_VECTOR_LENGHT;
|
||||
draw::line(
|
||||
x_center, y_center,
|
||||
std::clamp(x_center + (vector_lenght * std::cos(track_rad)),
|
||||
0.0f, static_cast<float>(UINT16_MAX)),
|
||||
std::clamp(y_center + (vector_lenght * std::sin(track_rad)),
|
||||
0.0f, static_cast<float>(UINT16_MAX)),
|
||||
color);
|
||||
#endif
|
||||
draw::rhombus(x_center, y_center, 8 /*TODO: remove magic*/,
|
||||
color);
|
||||
@@ -214,7 +220,11 @@ int main() {
|
||||
x_center + 10 /*TODO: remove magic*/,
|
||||
y_center + FONT_HEIGHT + CONFIG_CHARACTER_SPACING,
|
||||
color);
|
||||
font::puts(std::to_string(altitude) + ALTITUDE_UNIT, x_center + 10 /*TODO: remove magic*/, y_center + (FONT_HEIGHT + CONFIG_CHARACTER_SPACING)*2,color);
|
||||
font::puts(std::to_string(altitude) + ALTITUDE_UNIT,
|
||||
x_center + 10 /*TODO: remove magic*/,
|
||||
y_center +
|
||||
(FONT_HEIGHT + CONFIG_CHARACTER_SPACING) * 2,
|
||||
color);
|
||||
}
|
||||
} catch (...) {
|
||||
std::clog << YELLOW "[WARNING]" RESET
|
||||
|
||||
Reference in New Issue
Block a user