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