bug fixes

This commit is contained in:
2026-08-08 11:24:27 +02:00
parent 6ac93f0a5b
commit abf1226b47
7 changed files with 24 additions and 13 deletions
+2
View File
@@ -26,6 +26,8 @@ project(p-rad ${PROJECT_LANGUAGES})
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_compile_options(-Wall -Wextra -Wpedantic -Wno-write-strings)
# NOTE: don't use add_link_options/add_compile_options here - they apply to
# every target including pico-sdk's bs2_default, whose binary gets fully
# garbage-collected. Scope them to the p-rad target instead (see platform files).
+2
View File
@@ -18,6 +18,8 @@ pico: $(AUTOHEADER)
mkdir -p build-pico
(cd build-pico && cmake .. -DBUILD_PLATFORM=Pico && make -j$(nproc))
clean:
rm -fr build*
# ---------------------------------------------------------------------------
# kconfig targets
# ---------------------------------------------------------------------------
+1 -1
View File
@@ -6,7 +6,7 @@ add_executable(p-rad
target_compile_options(p-rad PRIVATE -ffunction-sections -fdata-sections)
target_link_options(p-rad PRIVATE -Wl,--gc-sections)
if(CMAKE_BUILD_TYPE EQUAL Release)
add_compile_options(-O3)
add_compile_options(-O3 -s)
endif()
target_include_directories(p-rad PRIVATE src)
+1 -1
View File
@@ -12,7 +12,7 @@ target_compile_options(p-rad PRIVATE -ffunction-sections -fdata-sections)
target_link_options(p-rad PRIVATE -Wl,--gc-sections)
if(CMAKE_BUILD_TYPE EQUAL Release)
add_compile_options(-Os)
add_compile_options(-Os -s)
endif()
+3 -3
View File
@@ -157,10 +157,10 @@ void putchar(const char c, uint16_t x, uint16_t y, const draw::color_t color) {
x = x_orig;
for (uint8_t j = 0; j < FONT_WIDTH; j++) {
if (get_Nth_bit_in_grid(_5x7_dotmatrix_charset,
static_cast<typeof(character_bit_offset)>(
static_cast<std::remove_const_t<decltype(character_bit_offset)>>(
character_bit_offset + j),
static_cast<typeof(character_bit_offset)>(i),
static_cast<typeof(character_bit_offset)>(
static_cast<std::remove_const_t<decltype(character_bit_offset)>>(i),
static_cast<std::remove_const_t<decltype(character_bit_offset)>>(
_5X7_DOTMATRIX_CHARSET_WIDTH))) {
draw::pixel(x, y, color);
}
+6 -4
View File
@@ -96,7 +96,7 @@ void start_frame() {
SDL_RenderClear(main_sdl_session.renderer);
}
const Uint64 frame_delay_ns = 1000000000ULL / 1;
constexpr Uint64 frame_delay_ns = 1000000000ULL / 1;
void end_frame() {
SDL_Event event;
while (SDL_PollEvent(&event)) {
@@ -109,7 +109,7 @@ void end_frame() {
if (event.key.key != SDLK_Q) {
break;
}
[[fallthrough]];
case SDL_EVENT_QUIT:
SDL_Quit();
std::exit(0);
@@ -164,7 +164,6 @@ void circle(const uint16_t x_center, const uint16_t y_center,
SDL_RenderPoint(main_sdl_session.renderer, x + x_center, -y + y_center);
SDL_RenderPoint(main_sdl_session.renderer, y + x_center, x + y_center);
SDL_RenderPoint(main_sdl_session.renderer, -y + x_center, x + y_center);
std::cout << "\n";
}
// Initialising the value of P
@@ -227,8 +226,11 @@ void line(const uint16_t x1, const uint16_t y1, const uint16_t x2,
void arc(uint16_t start_x, uint16_t start_y, float start_angle_rad, float speed /*in pps*/,float angular_speed_rads, uint16_t duration, color_t color) {
SDL_SetRenderDrawColor(main_sdl_session.renderer, color.r, color.g, color.b,
0xff);
constexpr float DEG2RAD = std::numbers::pi / 180.0f;
if (speed == 0) {
SDL_RenderPoint(main_sdl_session.renderer, start_x, start_y);
return;
}
// Handle straight line case
if (std::fabs(angular_speed_rads) < 1e-6f) {
+9 -4
View File
@@ -133,6 +133,10 @@ int main() {
"[WARNING]" RESET
" aircraft with no ground speed or track data detected!\n";
speed = 0;
track = 0;
#ifndef CONFIG_METRIC
speed_knot = 0;
#endif
}
draw::color_t color = get_altitude_color(altitude);
try {
@@ -156,13 +160,11 @@ int main() {
// speed in pixels per hour
const float speed_pph = speed * pixels_per_km;
// lenght of Time-Based Vector
const float vector_lenght =
(speed_pph / 60) * CONFIG_TIME_BASED_VECTOR_LENGHT;
// track in radians
const float track_rad =
std::fmod((track - 90), 365.0f) *
std::fmod((track - 90), 360.0f) *
(static_cast<float>(std::numbers::pi) / 180.0f);
#ifdef CONFIG_VECTOR_FOLLOW_TRACK_RATE
{
@@ -178,6 +180,9 @@ int main() {
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,
x_center + (vector_lenght * std::cos(track_rad)),
y_center + (vector_lenght * std::sin(track_rad)), color);