From 93aea5984767754309c9b7cc255211bb4df8b13a Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Fri, 15 Jan 2016 18:15:34 -0800 Subject: [PATCH] Add AIS last position timestamp to details view. --- firmware/application/ais_app.cpp | 1 + firmware/application/string_format.cpp | 9 +++++++++ firmware/application/string_format.hpp | 1 + 3 files changed, 11 insertions(+) diff --git a/firmware/application/ais_app.cpp b/firmware/application/ais_app.cpp index ae20f25a..a4a1fb7e 100644 --- a/firmware/application/ais_app.cpp +++ b/firmware/application/ais_app.cpp @@ -410,6 +410,7 @@ void AISRecentEntryDetailView::paint(Painter& painter) { field_rect = draw_field(painter, field_rect, s, "Name", entry_.name); field_rect = draw_field(painter, field_rect, s, "Call", entry_.call_sign); field_rect = draw_field(painter, field_rect, s, "Dest", entry_.destination); + field_rect = draw_field(painter, field_rect, s, "Last", to_string_datetime(entry_.last_position.timestamp)); field_rect = draw_field(painter, field_rect, s, "Pos ", ais::format::latlon(entry_.last_position.latitude, entry_.last_position.longitude)); field_rect = draw_field(painter, field_rect, s, "Stat", ais::format::navigational_status(entry_.navigational_status)); field_rect = draw_field(painter, field_rect, s, "Rx #", to_string_dec_uint(entry_.received_count)); diff --git a/firmware/application/string_format.cpp b/firmware/application/string_format.cpp index 596cc47c..5e151297 100644 --- a/firmware/application/string_format.cpp +++ b/firmware/application/string_format.cpp @@ -112,6 +112,15 @@ std::string to_string_hex(const uint32_t n, const int32_t l) { return p; } +std::string to_string_datetime(const rtc::RTC& value) { + return to_string_dec_uint(value.year(), 4, '0') + "/" + + to_string_dec_uint(value.month(), 2, '0') + "/" + + to_string_dec_uint(value.day(), 2, '0') + " " + + to_string_dec_uint(value.hour(), 2, '0') + ":" + + to_string_dec_uint(value.minute(), 2, '0') + ":" + + to_string_dec_uint(value.second(), 2, '0'); +} + std::string to_string_timestamp(const rtc::RTC& value) { return to_string_dec_uint(value.year(), 4, '0') + to_string_dec_uint(value.month(), 2, '0') + diff --git a/firmware/application/string_format.hpp b/firmware/application/string_format.hpp index 6f758478..b90030e2 100644 --- a/firmware/application/string_format.hpp +++ b/firmware/application/string_format.hpp @@ -35,6 +35,7 @@ std::string to_string_dec_uint(const uint32_t n, const int32_t l = 0, const char std::string to_string_dec_int(const int32_t n, const int32_t l = 0, const char fill = 0); std::string to_string_hex(const uint32_t n, const int32_t l = 0); +std::string to_string_datetime(const rtc::RTC& value); std::string to_string_timestamp(const rtc::RTC& value); #endif/*__STRING_FORMAT_H__*/