mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-03-01 10:47:20 +00:00
Pull AIS record types out of AISView.
This commit is contained in:
parent
4b2157a938
commit
a29b76ac38
@ -144,7 +144,7 @@ void AISView::truncate_entries() {
|
|||||||
void AISView::on_packet(const ais::Packet& packet) {
|
void AISView::on_packet(const ais::Packet& packet) {
|
||||||
const auto source_id = packet.source_id();
|
const auto source_id = packet.source_id();
|
||||||
auto matching_recent = std::find_if(recent.begin(), recent.end(),
|
auto matching_recent = std::find_if(recent.begin(), recent.end(),
|
||||||
[source_id](const AISView::RecentEntry& entry) { return entry.mmsi == source_id; }
|
[source_id](const AISRecentEntry& entry) { return entry.mmsi == source_id; }
|
||||||
);
|
);
|
||||||
if( matching_recent != recent.end() ) {
|
if( matching_recent != recent.end() ) {
|
||||||
// Found within. Move to front of list, increment counter.
|
// Found within. Move to front of list, increment counter.
|
||||||
@ -211,7 +211,7 @@ bool AISView::on_encoder(const EncoderEvent event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AISView::draw_entry(
|
void AISView::draw_entry(
|
||||||
const RecentEntry& entry,
|
const AISRecentEntry& entry,
|
||||||
const Rect& target_rect,
|
const Rect& target_rect,
|
||||||
Painter& painter,
|
Painter& painter,
|
||||||
const Style& style,
|
const Style& style,
|
||||||
@ -268,7 +268,7 @@ void AISView::paint(Painter& painter) {
|
|||||||
|
|
||||||
AISView::RecentEntries::iterator AISView::selected_entry() {
|
AISView::RecentEntries::iterator AISView::selected_entry() {
|
||||||
const auto key = selected_key;
|
const auto key = selected_key;
|
||||||
return std::find_if(std::begin(recent), std::end(recent), [key](const RecentEntry& e) { return e.mmsi == key; });
|
return std::find_if(std::begin(recent), std::end(recent), [key](const AISRecentEntry& e) { return e.mmsi == key; });
|
||||||
}
|
}
|
||||||
|
|
||||||
void AISView::advance(const int32_t amount) {
|
void AISView::advance(const int32_t amount) {
|
||||||
|
@ -38,6 +38,31 @@ using namespace lpc43xx;
|
|||||||
|
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
|
||||||
|
struct AISPosition {
|
||||||
|
rtc::RTC timestamp { };
|
||||||
|
ais::Latitude latitude { 0 };
|
||||||
|
ais::Longitude longitude { 0 };
|
||||||
|
};
|
||||||
|
|
||||||
|
struct AISRecentEntry {
|
||||||
|
ais::MMSI mmsi;
|
||||||
|
std::string name;
|
||||||
|
std::string call_sign;
|
||||||
|
std::string destination;
|
||||||
|
AISPosition last_position;
|
||||||
|
size_t received_count;
|
||||||
|
int8_t navigational_status;
|
||||||
|
|
||||||
|
AISRecentEntry(
|
||||||
|
const ais::MMSI& mmsi
|
||||||
|
) : mmsi { mmsi },
|
||||||
|
last_position { },
|
||||||
|
received_count { 0 },
|
||||||
|
navigational_status { -1 }
|
||||||
|
{
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class AISModel {
|
class AISModel {
|
||||||
public:
|
public:
|
||||||
AISModel();
|
AISModel();
|
||||||
@ -75,38 +100,13 @@ private:
|
|||||||
|
|
||||||
bool has_focus = false;
|
bool has_focus = false;
|
||||||
|
|
||||||
struct Position {
|
using RecentEntries = std::list<AISRecentEntry>;
|
||||||
rtc::RTC timestamp { };
|
|
||||||
ais::Latitude latitude { 0 };
|
|
||||||
ais::Longitude longitude { 0 };
|
|
||||||
};
|
|
||||||
|
|
||||||
struct RecentEntry {
|
|
||||||
ais::MMSI mmsi;
|
|
||||||
std::string name;
|
|
||||||
std::string call_sign;
|
|
||||||
std::string destination;
|
|
||||||
Position last_position;
|
|
||||||
size_t received_count;
|
|
||||||
int8_t navigational_status;
|
|
||||||
|
|
||||||
RecentEntry(
|
|
||||||
const ais::MMSI& mmsi
|
|
||||||
) : mmsi { mmsi },
|
|
||||||
last_position { },
|
|
||||||
received_count { 0 },
|
|
||||||
navigational_status { -1 }
|
|
||||||
{
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
using RecentEntries = std::list<RecentEntry>;
|
|
||||||
RecentEntries recent;
|
RecentEntries recent;
|
||||||
|
|
||||||
void on_packet(const ais::Packet& packet);
|
void on_packet(const ais::Packet& packet);
|
||||||
|
|
||||||
void draw_entry(
|
void draw_entry(
|
||||||
const RecentEntry& entry,
|
const AISRecentEntry& entry,
|
||||||
const Rect& target_rect,
|
const Rect& target_rect,
|
||||||
Painter& painter,
|
Painter& painter,
|
||||||
const Style& style,
|
const Style& style,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user