diff --git a/CMakeLists.txt b/CMakeLists.txt index 5f0ba81..4b7e528 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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). diff --git a/Makefile b/Makefile index 2e26b2d..56064fc 100644 --- a/Makefile +++ b/Makefile @@ -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 # --------------------------------------------------------------------------- diff --git a/cmake/platform_Linux.cmake b/cmake/platform_Linux.cmake index 2ada38c..7ff2dda 100644 --- a/cmake/platform_Linux.cmake +++ b/cmake/platform_Linux.cmake @@ -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) diff --git a/cmake/platform_Pico.cmake b/cmake/platform_Pico.cmake index 956c572..0a72110 100644 --- a/cmake/platform_Pico.cmake +++ b/cmake/platform_Pico.cmake @@ -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() diff --git a/src/core/gfx.cpp b/src/core/gfx.cpp index 96ef7ca..057954a 100644 --- a/src/core/gfx.cpp +++ b/src/core/gfx.cpp @@ -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( + static_cast>( character_bit_offset + j), - static_cast(i), - static_cast( + static_cast>(i), + static_cast>( _5X7_DOTMATRIX_CHARSET_WIDTH))) { draw::pixel(x, y, color); } diff --git a/src/hal/hal_linux.cpp b/src/hal/hal_linux.cpp index 56759a3..ebc66e3 100644 --- a/src/hal/hal_linux.cpp +++ b/src/hal/hal_linux.cpp @@ -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) { diff --git a/src/main.cpp b/src/main.cpp index 46875b9..f343902 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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(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);