From 22e8add4dd8a1577a23e3c2a89182eff0fbdc9e4 Mon Sep 17 00:00:00 2001 From: teixeluis Date: Thu, 24 Jun 2021 15:10:06 +0100 Subject: [PATCH] Fixed left padding of the decimal part of the numbers. --- firmware/application/apps/ui_adsb_rx.cpp | 8 ++++---- firmware/application/string_format.cpp | 2 +- firmware/common/adsb.cpp | 4 +++- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/firmware/application/apps/ui_adsb_rx.cpp b/firmware/application/apps/ui_adsb_rx.cpp index 88474923..25667fe6 100644 --- a/firmware/application/apps/ui_adsb_rx.cpp +++ b/firmware/application/apps/ui_adsb_rx.cpp @@ -250,10 +250,10 @@ void ADSBRxView::on_frame(const ADSBFrameMessage * message) { entry.set_info_string(str_info); logentry+=log_info + " "; + // we only want to update the details view if the frame + // we received has the same ICAO address, i.e. belongs to + // the same aircraft: if(send_updates && details_view->get_current_entry().ICAO_address == ICAO_address) { - // we only want to update the details view if the frame - // we received has the same ICAO address, i.e. belongs to - // the same aircraft: details_view->update(entry); } } @@ -263,8 +263,8 @@ void ADSBRxView::on_frame(const ADSBFrameMessage * message) { " Hdg:" + to_string_dec_uint(entry.velo.heading) + " Spd: "+ to_string_dec_int(entry.velo.speed); + // same here: if (send_updates && details_view->get_current_entry().ICAO_address == ICAO_address) { - // same here: details_view->update(entry); } } diff --git a/firmware/application/string_format.cpp b/firmware/application/string_format.cpp index c639923e..22b02d0b 100644 --- a/firmware/application/string_format.cpp +++ b/firmware/application/string_format.cpp @@ -124,7 +124,7 @@ std::string to_string_decimal(float decimal, int8_t precision) { fractional_part = -fractional_part; } - result = to_string_dec_int(integer_part) + "." + to_string_dec_uint(fractional_part, precision); + result = to_string_dec_int(integer_part) + "." + to_string_dec_uint(fractional_part, precision, '0'); return result; } diff --git a/firmware/common/adsb.cpp b/firmware/common/adsb.cpp index 3d0e43ef..d1d11707 100644 --- a/firmware/common/adsb.cpp +++ b/firmware/common/adsb.cpp @@ -160,7 +160,9 @@ int cpr_NL_approx(float lat) { int cpr_NL(float lat) { // TODO prove that the approximate function is good // enough for the precision we need. Uncomment if - // that is true: + // that is true. No performance penalty was noticed + // from testing, but if you find it might be an issue, + // switch to cpr_NL_approx() instead: //return cpr_NL_approx(lat);