bug fixes
This commit is contained in:
@@ -26,6 +26,8 @@ project(p-rad ${PROJECT_LANGUAGES})
|
|||||||
set(CMAKE_CXX_STANDARD 23)
|
set(CMAKE_CXX_STANDARD 23)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
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
|
# 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
|
# 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).
|
# garbage-collected. Scope them to the p-rad target instead (see platform files).
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ pico: $(AUTOHEADER)
|
|||||||
mkdir -p build-pico
|
mkdir -p build-pico
|
||||||
(cd build-pico && cmake .. -DBUILD_PLATFORM=Pico && make -j$(nproc))
|
(cd build-pico && cmake .. -DBUILD_PLATFORM=Pico && make -j$(nproc))
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -fr build*
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# kconfig targets
|
# kconfig targets
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ add_executable(p-rad
|
|||||||
target_compile_options(p-rad PRIVATE -ffunction-sections -fdata-sections)
|
target_compile_options(p-rad PRIVATE -ffunction-sections -fdata-sections)
|
||||||
target_link_options(p-rad PRIVATE -Wl,--gc-sections)
|
target_link_options(p-rad PRIVATE -Wl,--gc-sections)
|
||||||
if(CMAKE_BUILD_TYPE EQUAL Release)
|
if(CMAKE_BUILD_TYPE EQUAL Release)
|
||||||
add_compile_options(-O3)
|
add_compile_options(-O3 -s)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_include_directories(p-rad PRIVATE src)
|
target_include_directories(p-rad PRIVATE src)
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ target_compile_options(p-rad PRIVATE -ffunction-sections -fdata-sections)
|
|||||||
target_link_options(p-rad PRIVATE -Wl,--gc-sections)
|
target_link_options(p-rad PRIVATE -Wl,--gc-sections)
|
||||||
|
|
||||||
if(CMAKE_BUILD_TYPE EQUAL Release)
|
if(CMAKE_BUILD_TYPE EQUAL Release)
|
||||||
add_compile_options(-Os)
|
add_compile_options(-Os -s)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -157,10 +157,10 @@ void putchar(const char c, uint16_t x, uint16_t y, const draw::color_t color) {
|
|||||||
x = x_orig;
|
x = x_orig;
|
||||||
for (uint8_t j = 0; j < FONT_WIDTH; j++) {
|
for (uint8_t j = 0; j < FONT_WIDTH; j++) {
|
||||||
if (get_Nth_bit_in_grid(_5x7_dotmatrix_charset,
|
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),
|
character_bit_offset + j),
|
||||||
static_cast<typeof(character_bit_offset)>(i),
|
static_cast<std::remove_const_t<decltype(character_bit_offset)>>(i),
|
||||||
static_cast<typeof(character_bit_offset)>(
|
static_cast<std::remove_const_t<decltype(character_bit_offset)>>(
|
||||||
_5X7_DOTMATRIX_CHARSET_WIDTH))) {
|
_5X7_DOTMATRIX_CHARSET_WIDTH))) {
|
||||||
draw::pixel(x, y, color);
|
draw::pixel(x, y, color);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ void start_frame() {
|
|||||||
SDL_RenderClear(main_sdl_session.renderer);
|
SDL_RenderClear(main_sdl_session.renderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
const Uint64 frame_delay_ns = 1000000000ULL / 1;
|
constexpr Uint64 frame_delay_ns = 1000000000ULL / 1;
|
||||||
void end_frame() {
|
void end_frame() {
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
while (SDL_PollEvent(&event)) {
|
while (SDL_PollEvent(&event)) {
|
||||||
@@ -109,7 +109,7 @@ void end_frame() {
|
|||||||
if (event.key.key != SDLK_Q) {
|
if (event.key.key != SDLK_Q) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
[[fallthrough]];
|
||||||
case SDL_EVENT_QUIT:
|
case SDL_EVENT_QUIT:
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
std::exit(0);
|
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, 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);
|
||||||
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
|
// 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) {
|
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,
|
SDL_SetRenderDrawColor(main_sdl_session.renderer, color.r, color.g, color.b,
|
||||||
0xff);
|
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
|
// Handle straight line case
|
||||||
if (std::fabs(angular_speed_rads) < 1e-6f) {
|
if (std::fabs(angular_speed_rads) < 1e-6f) {
|
||||||
|
|||||||
+9
-4
@@ -133,6 +133,10 @@ int main() {
|
|||||||
"[WARNING]" RESET
|
"[WARNING]" RESET
|
||||||
" 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;
|
||||||
|
#ifndef CONFIG_METRIC
|
||||||
|
speed_knot = 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
draw::color_t color = get_altitude_color(altitude);
|
draw::color_t color = get_altitude_color(altitude);
|
||||||
try {
|
try {
|
||||||
@@ -156,13 +160,11 @@ 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;
|
||||||
// lenght of Time-Based Vector
|
|
||||||
const float vector_lenght =
|
|
||||||
(speed_pph / 60) * CONFIG_TIME_BASED_VECTOR_LENGHT;
|
|
||||||
|
|
||||||
// track in radians
|
// track in radians
|
||||||
const float track_rad =
|
const float track_rad =
|
||||||
std::fmod((track - 90), 365.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
|
||||||
{
|
{
|
||||||
@@ -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);
|
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
|
||||||
|
const float vector_lenght =
|
||||||
|
(speed_pph / 60) * CONFIG_TIME_BASED_VECTOR_LENGHT;
|
||||||
draw::line(x_center, y_center,
|
draw::line(x_center, y_center,
|
||||||
x_center + (vector_lenght * std::cos(track_rad)),
|
x_center + (vector_lenght * std::cos(track_rad)),
|
||||||
y_center + (vector_lenght * std::sin(track_rad)), color);
|
y_center + (vector_lenght * std::sin(track_rad)), color);
|
||||||
|
|||||||
Reference in New Issue
Block a user