mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-10-01 01:26:06 -04:00
GPS + orientation for Sonde (#1757)
* RadioSonde has gpsdata * Orientation update in Sonde
This commit is contained in:
parent
831dbeaab5
commit
3943848add
@ -90,7 +90,7 @@ SondeView::SondeView(NavigationView& nav)
|
|||||||
};
|
};
|
||||||
|
|
||||||
button_see_map.on_select = [this, &nav](Button&) {
|
button_see_map.on_select = [this, &nav](Button&) {
|
||||||
nav.push<GeoMapView>(
|
geomap_view_ = nav.push<GeoMapView>(
|
||||||
sonde_id,
|
sonde_id,
|
||||||
gps_info.alt,
|
gps_info.alt,
|
||||||
GeoPos::alt_unit::METERS,
|
GeoPos::alt_unit::METERS,
|
||||||
@ -98,6 +98,9 @@ SondeView::SondeView(NavigationView& nav)
|
|||||||
gps_info.lat,
|
gps_info.lat,
|
||||||
gps_info.lon,
|
gps_info.lon,
|
||||||
999); // set a dummy heading out of range to draw a cross...probably not ideal?
|
999); // set a dummy heading out of range to draw a cross...probably not ideal?
|
||||||
|
nav.set_on_pop([this]() {
|
||||||
|
geomap_view_ = nullptr;
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
logger = std::make_unique<SondeLogger>();
|
logger = std::make_unique<SondeLogger>();
|
||||||
@ -124,6 +127,17 @@ SondeView::~SondeView() {
|
|||||||
audio::output::stop();
|
audio::output::stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SondeView::on_gps(const GPSPosDataMessage* msg) {
|
||||||
|
if (!geomap_view_)
|
||||||
|
return;
|
||||||
|
geomap_view_->update_my_position(msg->lat, msg->lon, msg->altitude);
|
||||||
|
}
|
||||||
|
void SondeView::on_orientation(const OrientationDataMessage* msg) {
|
||||||
|
if (!geomap_view_)
|
||||||
|
return;
|
||||||
|
geomap_view_->update_my_orientation(msg->angle, true);
|
||||||
|
}
|
||||||
|
|
||||||
void SondeView::focus() {
|
void SondeView::focus() {
|
||||||
field_frequency.focus();
|
field_frequency.focus();
|
||||||
}
|
}
|
||||||
|
@ -60,6 +60,8 @@ class SondeView : public View {
|
|||||||
|
|
||||||
SondeView(NavigationView& nav);
|
SondeView(NavigationView& nav);
|
||||||
~SondeView();
|
~SondeView();
|
||||||
|
SondeView(const SondeView& other) = delete;
|
||||||
|
SondeView& operator=(const SondeView& other) = delete;
|
||||||
|
|
||||||
void focus() override;
|
void focus() override;
|
||||||
|
|
||||||
@ -173,6 +175,8 @@ class SondeView : public View {
|
|||||||
{16 * 8, 15 * 16, 12 * 8, 3 * 16},
|
{16 * 8, 15 * 16, 12 * 8, 3 * 16},
|
||||||
"See on map"};
|
"See on map"};
|
||||||
|
|
||||||
|
GeoMapView* geomap_view_{nullptr};
|
||||||
|
|
||||||
MessageHandlerRegistration message_handler_packet{
|
MessageHandlerRegistration message_handler_packet{
|
||||||
Message::ID::SondePacket,
|
Message::ID::SondePacket,
|
||||||
[this](Message* const p) {
|
[this](Message* const p) {
|
||||||
@ -181,6 +185,21 @@ class SondeView : public View {
|
|||||||
this->on_packet(packet);
|
this->on_packet(packet);
|
||||||
}};
|
}};
|
||||||
|
|
||||||
|
MessageHandlerRegistration message_handler_gps{
|
||||||
|
Message::ID::GPSPosData,
|
||||||
|
[this](Message* const p) {
|
||||||
|
const auto message = static_cast<const GPSPosDataMessage*>(p);
|
||||||
|
this->on_gps(message);
|
||||||
|
}};
|
||||||
|
MessageHandlerRegistration message_handler_orientation{
|
||||||
|
Message::ID::OrientationData,
|
||||||
|
[this](Message* const p) {
|
||||||
|
const auto message = static_cast<const OrientationDataMessage*>(p);
|
||||||
|
this->on_orientation(message);
|
||||||
|
}};
|
||||||
|
|
||||||
|
void on_gps(const GPSPosDataMessage* msg);
|
||||||
|
void on_orientation(const OrientationDataMessage* msg);
|
||||||
void on_packet(const sonde::Packet& packet);
|
void on_packet(const sonde::Packet& packet);
|
||||||
char* float_to_char(float x, char* p);
|
char* float_to_char(float x, char* p);
|
||||||
};
|
};
|
||||||
|
@ -516,8 +516,12 @@ void GeoMap::update_my_position(float lat, float lon, int32_t altitude) {
|
|||||||
markerListUpdated = true;
|
markerListUpdated = true;
|
||||||
set_dirty();
|
set_dirty();
|
||||||
}
|
}
|
||||||
void GeoMap::update_my_orientation(uint16_t angle) {
|
void GeoMap::update_my_orientation(uint16_t angle, bool refresh) {
|
||||||
my_angle = angle;
|
my_angle = angle;
|
||||||
|
if (refresh) {
|
||||||
|
markerListUpdated = true;
|
||||||
|
set_dirty();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GeoMapView::focus() {
|
void GeoMapView::focus() {
|
||||||
@ -530,8 +534,8 @@ void GeoMapView::focus() {
|
|||||||
void GeoMapView::update_my_position(float lat, float lon, int32_t altitude) {
|
void GeoMapView::update_my_position(float lat, float lon, int32_t altitude) {
|
||||||
geomap.update_my_position(lat, lon, altitude);
|
geomap.update_my_position(lat, lon, altitude);
|
||||||
}
|
}
|
||||||
void GeoMapView::update_my_orientation(uint16_t angle) {
|
void GeoMapView::update_my_orientation(uint16_t angle, bool refresh) {
|
||||||
geomap.update_my_orientation(angle);
|
geomap.update_my_orientation(angle, refresh);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GeoMapView::update_position(float lat, float lon, uint16_t angle, int32_t altitude, int32_t speed) {
|
void GeoMapView::update_position(float lat, float lon, uint16_t angle, int32_t altitude, int32_t speed) {
|
||||||
|
@ -186,7 +186,7 @@ class GeoMap : public Widget {
|
|||||||
bool on_keyboard(const KeyboardEvent event) override;
|
bool on_keyboard(const KeyboardEvent event) override;
|
||||||
|
|
||||||
void update_my_position(float lat, float lon, int32_t altitude);
|
void update_my_position(float lat, float lon, int32_t altitude);
|
||||||
void update_my_orientation(uint16_t angle);
|
void update_my_orientation(uint16_t angle, bool refresh = false);
|
||||||
|
|
||||||
bool init();
|
bool init();
|
||||||
void set_mode(GeoMapMode mode);
|
void set_mode(GeoMapMode mode);
|
||||||
@ -278,7 +278,7 @@ class GeoMapView : public View {
|
|||||||
|
|
||||||
void update_position(float lat, float lon, uint16_t angle, int32_t altitude, int32_t speed = 0);
|
void update_position(float lat, float lon, uint16_t angle, int32_t altitude, int32_t speed = 0);
|
||||||
void update_my_position(float lat, float lon, int32_t altitude);
|
void update_my_position(float lat, float lon, int32_t altitude);
|
||||||
void update_my_orientation(uint16_t angle);
|
void update_my_orientation(uint16_t angle, bool refresh = false);
|
||||||
|
|
||||||
std::string title() const override { return "Map view"; };
|
std::string title() const override { return "Map view"; };
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user