mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-12-23 22:39:22 -05:00
Added map view for ADSB RX
Geomap: added tag display (text) Geomap: fixed Y scroll value Fixed frequency display not updating after edit Updated binary
This commit is contained in:
parent
3aae333974
commit
fa519bba63
@ -22,7 +22,6 @@
|
||||
|
||||
#include "ui_adsb_rx.hpp"
|
||||
#include "ui_alphanum.hpp"
|
||||
#include "ui_geomap.hpp"
|
||||
|
||||
#include "rtc_time.hpp"
|
||||
#include "string_format.hpp"
|
||||
@ -123,6 +122,9 @@ void ADSBRxView::on_frame(const ADSBFrameMessage * message) {
|
||||
"." + to_string_dec_int((int)(entry.pos.longitude * 1000) % 100);
|
||||
|
||||
entry.set_info_string(str_info);
|
||||
|
||||
if (geomap_view)
|
||||
geomap_view->update_pos(entry.pos.latitude, entry.pos.longitude);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -139,7 +141,7 @@ void ADSBRxView::on_tick_second() {
|
||||
}
|
||||
}
|
||||
|
||||
ADSBRxView::ADSBRxView(NavigationView&) {
|
||||
ADSBRxView::ADSBRxView(NavigationView& nav) {
|
||||
baseband::run_image(portapack::spi_flash::image_tag_adsb_rx);
|
||||
|
||||
add_children({
|
||||
@ -147,17 +149,24 @@ ADSBRxView::ADSBRxView(NavigationView&) {
|
||||
&rssi,
|
||||
&field_lna,
|
||||
&field_vga,
|
||||
&text_debug_a,
|
||||
&text_debug_b,
|
||||
&text_debug_c,
|
||||
//&text_debug_a,
|
||||
//&text_debug_b,
|
||||
//&text_debug_c,
|
||||
&recent_entries_view
|
||||
});
|
||||
|
||||
recent_entries_view.set_parent_rect({ 0, 64, 240, 224 });
|
||||
recent_entries_view.on_select = [this](const AircraftRecentEntry& entry) {
|
||||
text_debug_a.set(entry.info_string);
|
||||
text_debug_b.set(to_string_hex_array(entry.frame_pos_even.get_raw_data(), 14));
|
||||
text_debug_c.set(to_string_hex_array(entry.frame_pos_odd.get_raw_data(), 14));
|
||||
recent_entries_view.on_select = [this, &nav](const AircraftRecentEntry& entry) {
|
||||
//text_debug_a.set(entry.info_string);
|
||||
//text_debug_b.set(to_string_hex_array(entry.frame_pos_even.get_raw_data(), 14));
|
||||
//text_debug_c.set(to_string_hex_array(entry.frame_pos_odd.get_raw_data(), 14));
|
||||
|
||||
geomap_view = nav.push<GeoMapView>(
|
||||
entry.callsign,
|
||||
entry.pos.altitude,
|
||||
entry.pos.latitude,
|
||||
entry.pos.longitude,
|
||||
0.0);
|
||||
};
|
||||
|
||||
signal_token_tick_second = rtc_time::signal_tick_second += [this]() {
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "ui.hpp"
|
||||
#include "file.hpp"
|
||||
#include "ui_receiver.hpp"
|
||||
#include "ui_geomap.hpp"
|
||||
#include "ui_font_fixed_8x16.hpp"
|
||||
#include "recent_entries.hpp"
|
||||
|
||||
@ -104,6 +105,11 @@ public:
|
||||
ADSBRxView(NavigationView&);
|
||||
~ADSBRxView();
|
||||
|
||||
ADSBRxView(const ADSBRxView&) = delete;
|
||||
ADSBRxView(ADSBRxView&&) = delete;
|
||||
ADSBRxView& operator=(const ADSBRxView&) = delete;
|
||||
ADSBRxView& operator=(ADSBRxView&&) = delete;
|
||||
|
||||
void focus() override;
|
||||
|
||||
std::string title() const override { return "ADS-B receive"; };
|
||||
@ -121,6 +127,7 @@ private:
|
||||
AircraftRecentEntries recent { };
|
||||
RecentEntriesView<RecentEntries<AircraftRecentEntry>> recent_entries_view { columns, recent };
|
||||
|
||||
GeoMapView* geomap_view { };
|
||||
SignalToken signal_token_tick_second { };
|
||||
|
||||
RSSI rssi {
|
||||
@ -139,7 +146,7 @@ private:
|
||||
{ { 0 * 8, 0 * 8 }, "LNA: VGA: RSSI:", Color::light_grey() }
|
||||
};
|
||||
|
||||
Text text_debug_a {
|
||||
/*Text text_debug_a {
|
||||
{ 0 * 8, 1 * 16, 30 * 8, 16 },
|
||||
"-"
|
||||
};
|
||||
@ -150,7 +157,7 @@ private:
|
||||
Text text_debug_c {
|
||||
{ 0 * 8, 3 * 16, 30 * 8, 16 },
|
||||
"-"
|
||||
};
|
||||
};*/
|
||||
|
||||
MessageHandlerRegistration message_handler_frame {
|
||||
Message::ID::ADSBFrame,
|
||||
|
@ -138,6 +138,7 @@ void GeoMap::paint(Painter& painter) {
|
||||
display.fill_rectangle({ r.center() - Point(1, 16), { 2, 32 } }, Color::red());
|
||||
} else {
|
||||
draw_bearing({ 120, 32 + 144 }, angle_, 16, Color::red());
|
||||
painter.draw_string({ 120 - ((int)tag_.length() * 8 / 2), 32 + 144 - 32 }, style(), tag_);
|
||||
}
|
||||
|
||||
/*if (has_focus() || highlighted())
|
||||
@ -152,7 +153,7 @@ void GeoMap::paint(Painter& painter) {
|
||||
}
|
||||
|
||||
bool GeoMap::on_touch(const TouchEvent event) {
|
||||
if (event.type == TouchEvent::Type::Start) {
|
||||
if ((event.type == TouchEvent::Type::Start) && (mode_ == PROMPT)) {
|
||||
set_highlighted(true);
|
||||
if (on_move) {
|
||||
Point p = event.point - screen_rect().center();
|
||||
@ -171,7 +172,7 @@ void GeoMap::move(const float lon, const float lat) {
|
||||
|
||||
// Map is in Equidistant "Plate Carrée" projection
|
||||
x_pos = map_center_x - (map_rect.width() / 2) + (lon_ / lon_ratio);
|
||||
y_pos = map_center_y - (map_rect.height() / 2) + (lat_ / lat_ratio);
|
||||
y_pos = map_center_y - (map_rect.height() / 2) + (lat_ / lat_ratio) + 16;
|
||||
|
||||
// Cap position
|
||||
if (x_pos > (map_width - map_rect.width()))
|
||||
@ -193,7 +194,7 @@ bool GeoMap::init() {
|
||||
map_center_y = map_height >> 1;
|
||||
|
||||
lon_ratio = 180.0 / map_center_x;
|
||||
lat_ratio = 90.0 / map_center_y;
|
||||
lat_ratio = -90.0 / map_center_y;
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -225,6 +226,13 @@ void GeoMapView::focus() {
|
||||
nav_.display_modal("No map", "No world_map.bin file in\n/ADSB/ directory", ABORT, nullptr);
|
||||
}
|
||||
|
||||
void GeoMapView::update_pos(float lat, float lon) {
|
||||
lat_ = lat;
|
||||
lon_ = lon;
|
||||
geomap.move(lon_, lat_);
|
||||
geomap.set_dirty();
|
||||
}
|
||||
|
||||
void GeoMapView::setup() {
|
||||
add_children({
|
||||
&geopos,
|
||||
@ -261,13 +269,12 @@ void GeoMapView::setup() {
|
||||
// Display mode
|
||||
GeoMapView::GeoMapView(
|
||||
NavigationView& nav,
|
||||
std::string* tag,
|
||||
const std::string& tag,
|
||||
int32_t altitude,
|
||||
float lat,
|
||||
float lon,
|
||||
float angle
|
||||
) : nav_ (nav),
|
||||
tag_ (tag),
|
||||
altitude_ (altitude),
|
||||
lat_ (lat),
|
||||
lon_ (lon),
|
||||
@ -281,6 +288,7 @@ GeoMapView::GeoMapView(
|
||||
setup();
|
||||
|
||||
geomap.set_mode(mode_);
|
||||
geomap.set_tag(tag);
|
||||
geomap.move(lon_, lat_);
|
||||
|
||||
geopos.set_read_only(true);
|
||||
|
@ -20,6 +20,9 @@
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GEOMAP_H__
|
||||
#define __GEOMAP_H__
|
||||
|
||||
#include "ui.hpp"
|
||||
#include "file.hpp"
|
||||
#include "ui_navigation.hpp"
|
||||
@ -104,6 +107,9 @@ public:
|
||||
bool init();
|
||||
void set_mode(GeoMapMode mode);
|
||||
void move(const float lon, const float lat);
|
||||
void set_tag(std::string new_tag) {
|
||||
tag_ = new_tag;
|
||||
}
|
||||
|
||||
private:
|
||||
void draw_bearing(const Point origin, const uint32_t angle, uint32_t size, const Color color);
|
||||
@ -118,11 +124,12 @@ private:
|
||||
float lat_ { };
|
||||
float lon_ { };
|
||||
float angle_ { };
|
||||
std::string tag_ { };
|
||||
};
|
||||
|
||||
class GeoMapView : public View {
|
||||
public:
|
||||
GeoMapView(NavigationView& nav, std::string* tag, int32_t altitude, float lat, float lon, float angle);
|
||||
GeoMapView(NavigationView& nav, const std::string& tag, int32_t altitude, float lat, float lon, float angle);
|
||||
GeoMapView(NavigationView& nav, int32_t altitude, float lat, float lon, const std::function<void(int32_t, float, float)> on_done);
|
||||
|
||||
GeoMapView(const GeoMapView&) = delete;
|
||||
@ -132,6 +139,8 @@ public:
|
||||
|
||||
void focus() override;
|
||||
|
||||
void update_pos(float lat, float lon);
|
||||
|
||||
std::string title() const override { return "Map view"; };
|
||||
|
||||
private:
|
||||
@ -143,7 +152,6 @@ private:
|
||||
|
||||
const Dim banner_height = 3 * 16;
|
||||
GeoMapMode mode_ { };
|
||||
std::string* tag_ { };
|
||||
int32_t altitude_ { };
|
||||
float lat_ { };
|
||||
float lon_ { };
|
||||
@ -166,3 +174,5 @@ private:
|
||||
};
|
||||
|
||||
} /* namespace ui */
|
||||
|
||||
#endif
|
||||
|
@ -162,9 +162,9 @@ POCSAGTXView::POCSAGTXView(
|
||||
};
|
||||
|
||||
tx_view.on_edit_frequency = [this, &nav]() {
|
||||
auto new_view = nav.push<FrequencyKeypadView>(receiver_model.tuning_frequency());
|
||||
auto new_view = nav.push<FrequencyKeypadView>(transmitter_model.tuning_frequency());
|
||||
new_view->on_changed = [this](rf::Frequency f) {
|
||||
receiver_model.set_tuning_frequency(f);
|
||||
transmitter_model.set_tuning_frequency(f);
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -72,7 +72,7 @@ void TransmitterView::paint(Painter& painter) {
|
||||
}
|
||||
|
||||
void TransmitterView::on_tuning_frequency_changed(rf::Frequency f) {
|
||||
receiver_model.set_tuning_frequency(f);
|
||||
transmitter_model.set_tuning_frequency(f);
|
||||
}
|
||||
|
||||
void TransmitterView::on_channel_bandwidth_changed(uint32_t channel_bandwidth) {
|
||||
@ -92,7 +92,7 @@ void TransmitterView::set_transmitting(const bool transmitting) {
|
||||
}
|
||||
|
||||
void TransmitterView::on_show() {
|
||||
//field_frequency.set_value(receiver_model.tuning_frequency());
|
||||
field_frequency.set_value(transmitter_model.tuning_frequency());
|
||||
}
|
||||
|
||||
void TransmitterView::focus() {
|
||||
@ -131,7 +131,7 @@ TransmitterView::TransmitterView(
|
||||
}
|
||||
}
|
||||
|
||||
field_frequency.set_value(receiver_model.tuning_frequency());
|
||||
//field_frequency.set_value(transmitter_model.tuning_frequency());
|
||||
field_frequency.set_step(frequency_step);
|
||||
field_frequency.on_change = [this](rf::Frequency f) {
|
||||
on_tuning_frequency_changed(f);
|
||||
@ -141,7 +141,7 @@ TransmitterView::TransmitterView(
|
||||
on_edit_frequency();
|
||||
};
|
||||
field_frequency.on_change = [this](rf::Frequency f) {
|
||||
receiver_model.set_tuning_frequency(f);
|
||||
transmitter_model.set_tuning_frequency(f);
|
||||
};
|
||||
|
||||
button_start.on_select = [this](Button&){
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user