mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-10-01 01:26:06 -04:00
Map view in AIS (#213)
* Added GeoMapView to AISRecentEntryDetailView * Added autoupdate in AIS map
This commit is contained in:
parent
920b98f7c9
commit
262c030224
@ -52,6 +52,11 @@ static std::string latlon(const Latitude latitude, const Longitude longitude) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static float latlon_float(const int32_t normalized) {
|
||||||
|
const uint32_t normalized_abs = std::abs(normalized);
|
||||||
|
return ((((float) normalized_abs) * 5) / 3) / (100 * 10000);
|
||||||
|
}
|
||||||
|
|
||||||
static std::string mmsi(
|
static std::string mmsi(
|
||||||
const ais::MMSI& mmsi
|
const ais::MMSI& mmsi
|
||||||
) {
|
) {
|
||||||
@ -203,9 +208,10 @@ void RecentEntriesTable<AISRecentEntries>::draw(
|
|||||||
painter.draw_string(target_rect.location(), style, line);
|
painter.draw_string(target_rect.location(), style, line);
|
||||||
}
|
}
|
||||||
|
|
||||||
AISRecentEntryDetailView::AISRecentEntryDetailView() {
|
AISRecentEntryDetailView::AISRecentEntryDetailView(NavigationView& nav) {
|
||||||
add_children({
|
add_children({
|
||||||
&button_done,
|
&button_done,
|
||||||
|
&button_see_map,
|
||||||
});
|
});
|
||||||
|
|
||||||
button_done.on_select = [this](const ui::Button&) {
|
button_done.on_select = [this](const ui::Button&) {
|
||||||
@ -213,6 +219,29 @@ AISRecentEntryDetailView::AISRecentEntryDetailView() {
|
|||||||
this->on_close();
|
this->on_close();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
button_see_map.on_select = [this, &nav](Button&) {
|
||||||
|
geomap_view = nav.push<GeoMapView>(
|
||||||
|
entry_.name,
|
||||||
|
0,
|
||||||
|
GeoPos::alt_unit::METERS,
|
||||||
|
ais::format::latlon_float(entry_.last_position.latitude.normalized()),
|
||||||
|
ais::format::latlon_float(entry_.last_position.longitude.normalized()),
|
||||||
|
entry_.last_position.true_heading,
|
||||||
|
[this]() {
|
||||||
|
send_updates = false;
|
||||||
|
});
|
||||||
|
send_updates = true;
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void AISRecentEntryDetailView::update_position() {
|
||||||
|
if (send_updates)
|
||||||
|
geomap_view->update_position(ais::format::latlon_float(entry_.last_position.latitude.normalized()), ais::format::latlon_float(entry_.last_position.longitude.normalized()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void AISRecentEntryDetailView::focus() {
|
void AISRecentEntryDetailView::focus() {
|
||||||
@ -261,7 +290,7 @@ void AISRecentEntryDetailView::set_entry(const AISRecentEntry& entry) {
|
|||||||
set_dirty();
|
set_dirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
AISAppView::AISAppView(NavigationView&) {
|
AISAppView::AISAppView(NavigationView& nav) : nav_ { nav } {
|
||||||
baseband::run_image(portapack::spi_flash::image_tag_ais);
|
baseband::run_image(portapack::spi_flash::image_tag_ais);
|
||||||
|
|
||||||
add_children({
|
add_children({
|
||||||
@ -337,6 +366,7 @@ void AISAppView::on_packet(const ais::Packet& packet) {
|
|||||||
// TODO: Crude hack, should be a more formal listener arrangement...
|
// TODO: Crude hack, should be a more formal listener arrangement...
|
||||||
if( entry.key() == recent_entry_detail_view.entry().key() ) {
|
if( entry.key() == recent_entry_detail_view.entry().key() ) {
|
||||||
recent_entry_detail_view.set_entry(entry);
|
recent_entry_detail_view.set_entry(entry);
|
||||||
|
recent_entry_detail_view.update_position();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
#include "ui_rssi.hpp"
|
#include "ui_rssi.hpp"
|
||||||
#include "ui_channel.hpp"
|
#include "ui_channel.hpp"
|
||||||
|
|
||||||
|
#include "ui_geomap.hpp"
|
||||||
|
|
||||||
#include "event_m0.hpp"
|
#include "event_m0.hpp"
|
||||||
|
|
||||||
#include "log_file.hpp"
|
#include "log_file.hpp"
|
||||||
@ -116,11 +118,12 @@ class AISRecentEntryDetailView : public View {
|
|||||||
public:
|
public:
|
||||||
std::function<void(void)> on_close { };
|
std::function<void(void)> on_close { };
|
||||||
|
|
||||||
AISRecentEntryDetailView();
|
AISRecentEntryDetailView(NavigationView& nav);
|
||||||
|
|
||||||
void set_entry(const AISRecentEntry& new_entry);
|
void set_entry(const AISRecentEntry& new_entry);
|
||||||
const AISRecentEntry& entry() const { return entry_; };
|
const AISRecentEntry& entry() const { return entry_; };
|
||||||
|
|
||||||
|
void update_position();
|
||||||
void focus() override;
|
void focus() override;
|
||||||
void paint(Painter&) override;
|
void paint(Painter&) override;
|
||||||
|
|
||||||
@ -128,9 +131,15 @@ private:
|
|||||||
AISRecentEntry entry_ { };
|
AISRecentEntry entry_ { };
|
||||||
|
|
||||||
Button button_done {
|
Button button_done {
|
||||||
{ 72, 216, 96, 24 },
|
{ 125, 216, 96, 24 },
|
||||||
"Done"
|
"Done"
|
||||||
};
|
};
|
||||||
|
Button button_see_map {
|
||||||
|
{ 19, 216, 96, 24 },
|
||||||
|
"See on map"
|
||||||
|
};
|
||||||
|
GeoMapView* geomap_view { nullptr };
|
||||||
|
bool send_updates { false };
|
||||||
|
|
||||||
Rect draw_field(
|
Rect draw_field(
|
||||||
Painter& painter,
|
Painter& painter,
|
||||||
@ -160,6 +169,7 @@ private:
|
|||||||
static constexpr uint32_t initial_target_frequency = 162025000;
|
static constexpr uint32_t initial_target_frequency = 162025000;
|
||||||
static constexpr uint32_t sampling_rate = 2457600;
|
static constexpr uint32_t sampling_rate = 2457600;
|
||||||
static constexpr uint32_t baseband_bandwidth = 1750000;
|
static constexpr uint32_t baseband_bandwidth = 1750000;
|
||||||
|
NavigationView& nav_;
|
||||||
|
|
||||||
AISRecentEntries recent { };
|
AISRecentEntries recent { };
|
||||||
std::unique_ptr<AISLogger> logger { };
|
std::unique_ptr<AISLogger> logger { };
|
||||||
@ -169,7 +179,7 @@ private:
|
|||||||
{ "Name/Call", 20 },
|
{ "Name/Call", 20 },
|
||||||
} };
|
} };
|
||||||
AISRecentEntriesView recent_entries_view { columns, recent };
|
AISRecentEntriesView recent_entries_view { columns, recent };
|
||||||
AISRecentEntryDetailView recent_entry_detail_view { };
|
AISRecentEntryDetailView recent_entry_detail_view { nav_ };
|
||||||
|
|
||||||
static constexpr auto header_height = 1 * 16;
|
static constexpr auto header_height = 1 * 16;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user