diff --git a/firmware/application/ui_adsb_rx.cpp b/firmware/application/ui_adsb_rx.cpp index 508f2c55..fcb47ea0 100644 --- a/firmware/application/ui_adsb_rx.cpp +++ b/firmware/application/ui_adsb_rx.cpp @@ -161,6 +161,7 @@ ADSBRxDetailsView::ADSBRxDetailsView( geomap_view = nav.push( entry_copy.callsign, entry_copy.pos.altitude, + GeoPos::alt_unit::FEET, entry_copy.pos.latitude, entry_copy.pos.longitude, 0, diff --git a/firmware/application/ui_adsb_tx.cpp b/firmware/application/ui_adsb_tx.cpp index ada4d99c..94da2343 100644 --- a/firmware/application/ui_adsb_tx.cpp +++ b/firmware/application/ui_adsb_tx.cpp @@ -89,6 +89,7 @@ ADSBPositionView::ADSBPositionView( button_set_map.on_select = [this, &nav](Button&) { nav.push( geopos.altitude(), + GeoPos::alt_unit::FEET, geopos.lat(), geopos.lon(), [this](int32_t altitude, float lat, float lon) { diff --git a/firmware/application/ui_adsb_tx.hpp b/firmware/application/ui_adsb_tx.hpp index 927d543f..f68da241 100644 --- a/firmware/application/ui_adsb_tx.hpp +++ b/firmware/application/ui_adsb_tx.hpp @@ -55,7 +55,8 @@ public: private: GeoPos geopos { - { 0, 2 * 16 } + { 0, 2 * 16 }, + GeoPos::FEET }; Button button_set_map { diff --git a/firmware/application/ui_geomap.cpp b/firmware/application/ui_geomap.cpp index 27a1b106..724665a0 100644 --- a/firmware/application/ui_geomap.cpp +++ b/firmware/application/ui_geomap.cpp @@ -34,13 +34,16 @@ using namespace portapack; namespace ui { GeoPos::GeoPos( - const Point pos -) { + const Point pos, + const alt_unit altitude_unit +) : altitude_unit_(altitude_unit) { + set_parent_rect({pos, { 30 * 8, 3 * 16 }}); add_children({ &labels_position, &field_altitude, + &text_alt_unit, &field_lat_degrees, &field_lat_minutes, &field_lat_seconds, @@ -82,6 +85,8 @@ GeoPos::GeoPos( field_lon_degrees.on_change = changed_fn; field_lon_minutes.on_change = changed_fn; field_lon_seconds.on_change = changed_fn; + + text_alt_unit.set(altitude_unit_ ? "m" : "ft"); } void GeoPos::set_read_only(bool v) { @@ -283,12 +288,14 @@ GeoMapView::GeoMapView( NavigationView& nav, const std::string& tag, int32_t altitude, + GeoPos::alt_unit altitude_unit, float lat, float lon, float angle, const std::function on_close ) : nav_ (nav), altitude_ (altitude), + altitude_unit_ (altitude_unit), lat_ (lat), lon_ (lon), angle_ (angle), @@ -314,11 +321,13 @@ GeoMapView::GeoMapView( GeoMapView::GeoMapView( NavigationView& nav, int32_t altitude, + GeoPos::alt_unit altitude_unit, float lat, float lon, const std::function on_done ) : nav_ (nav), altitude_ (altitude), + altitude_unit_ (altitude_unit), lat_ (lat), lon_ (lon) { diff --git a/firmware/application/ui_geomap.hpp b/firmware/application/ui_geomap.hpp index df994006..45a9479b 100644 --- a/firmware/application/ui_geomap.hpp +++ b/firmware/application/ui_geomap.hpp @@ -39,9 +39,14 @@ enum GeoMapMode { class GeoPos : public View { public: + enum alt_unit { + FEET = 0, + METERS + }; + std::function on_change { }; - GeoPos(const Point pos); + GeoPos(const Point pos, const alt_unit altitude_unit); void focus() override; @@ -58,9 +63,10 @@ public: private: bool read_only { false }; bool report_change { true }; + alt_unit altitude_unit_ { }; Labels labels_position { - { { 1 * 8, 0 * 16 }, "Alt: feet", Color::light_grey() }, + { { 1 * 8, 0 * 16 }, "Alt:", Color::light_grey() }, { { 1 * 8, 1 * 16 }, "Lat: * ' \"", Color::light_grey() }, // No ° symbol in 8x16 font { { 1 * 8, 2 * 16 }, "Lon: * ' \"", Color::light_grey() }, }; @@ -72,6 +78,10 @@ private: 250, ' ' }; + Text text_alt_unit { + { 12 * 8, 0 * 16, 2 * 8, 16 }, + "" + }; NumberField field_lat_degrees { { 5 * 8, 1 * 16 }, 4, { -90, 90 }, 1, ' ' @@ -141,6 +151,7 @@ public: NavigationView& nav, const std::string& tag, int32_t altitude, + GeoPos::alt_unit altitude_unit, float lat, float lon, float angle, @@ -148,6 +159,7 @@ public: ); GeoMapView(NavigationView& nav, int32_t altitude, + GeoPos::alt_unit altitude_unit, float lat, float lon, const std::function on_done @@ -175,6 +187,7 @@ private: const Dim banner_height = 3 * 16; GeoMapMode mode_ { }; int32_t altitude_ { }; + GeoPos::alt_unit altitude_unit_ { }; float lat_ { }; float lon_ { }; float angle_ { }; @@ -183,7 +196,8 @@ private: bool map_opened { }; GeoPos geopos { - { 0, 0 } + { 0, 0 }, + altitude_unit_ }; GeoMap geomap { diff --git a/firmware/application/ui_sonde.cpp b/firmware/application/ui_sonde.cpp index b02b9fcc..3854373c 100644 --- a/firmware/application/ui_sonde.cpp +++ b/firmware/application/ui_sonde.cpp @@ -88,6 +88,7 @@ SondeView::SondeView(NavigationView& nav) { nav.push( "", altitude, + GeoPos::alt_unit::METERS, latitude, longitude, 0); @@ -113,7 +114,7 @@ void SondeView::on_packet(const sonde::Packet& packet) { text_signature.set(packet.signature()); text_serial.set(packet.serial_number()); - text_voltage.set(to_string_dec_uint(packet.battery_voltage()) + "mV"); + text_voltage.set(unit_auto_scale(packet.battery_voltage(), 2, 3) + "V"); altitude = packet.GPS_altitude(); latitude = packet.GPS_latitude(); diff --git a/firmware/application/ui_sonde.hpp b/firmware/application/ui_sonde.hpp index d2630c8f..f31ac823 100644 --- a/firmware/application/ui_sonde.hpp +++ b/firmware/application/ui_sonde.hpp @@ -97,7 +97,7 @@ private: }; Checkbox check_log { - { 22 * 8, 2 * 16 + 8 }, + { 22 * 8, 2 * 16 + 12 }, 3, "Log" }; @@ -116,7 +116,8 @@ private: }; GeoPos geopos { - { 0, 6 * 16 } + { 0, 6 * 16 }, + GeoPos::alt_unit::METERS }; Button button_see_map { diff --git a/firmware/portapack-h1-havoc.bin b/firmware/portapack-h1-havoc.bin index 77fb313a..7a04171e 100644 Binary files a/firmware/portapack-h1-havoc.bin and b/firmware/portapack-h1-havoc.bin differ