Added unit parameter for geopos widget, updated binary

This commit is contained in:
furrtek 2017-10-28 20:22:55 +02:00
parent d4207cde7b
commit d5aec94eed
8 changed files with 37 additions and 9 deletions

View File

@ -161,6 +161,7 @@ ADSBRxDetailsView::ADSBRxDetailsView(
geomap_view = nav.push<GeoMapView>( geomap_view = nav.push<GeoMapView>(
entry_copy.callsign, entry_copy.callsign,
entry_copy.pos.altitude, entry_copy.pos.altitude,
GeoPos::alt_unit::FEET,
entry_copy.pos.latitude, entry_copy.pos.latitude,
entry_copy.pos.longitude, entry_copy.pos.longitude,
0, 0,

View File

@ -89,6 +89,7 @@ ADSBPositionView::ADSBPositionView(
button_set_map.on_select = [this, &nav](Button&) { button_set_map.on_select = [this, &nav](Button&) {
nav.push<GeoMapView>( nav.push<GeoMapView>(
geopos.altitude(), geopos.altitude(),
GeoPos::alt_unit::FEET,
geopos.lat(), geopos.lat(),
geopos.lon(), geopos.lon(),
[this](int32_t altitude, float lat, float lon) { [this](int32_t altitude, float lat, float lon) {

View File

@ -55,7 +55,8 @@ public:
private: private:
GeoPos geopos { GeoPos geopos {
{ 0, 2 * 16 } { 0, 2 * 16 },
GeoPos::FEET
}; };
Button button_set_map { Button button_set_map {

View File

@ -34,13 +34,16 @@ using namespace portapack;
namespace ui { namespace ui {
GeoPos::GeoPos( 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 }}); set_parent_rect({pos, { 30 * 8, 3 * 16 }});
add_children({ add_children({
&labels_position, &labels_position,
&field_altitude, &field_altitude,
&text_alt_unit,
&field_lat_degrees, &field_lat_degrees,
&field_lat_minutes, &field_lat_minutes,
&field_lat_seconds, &field_lat_seconds,
@ -82,6 +85,8 @@ GeoPos::GeoPos(
field_lon_degrees.on_change = changed_fn; field_lon_degrees.on_change = changed_fn;
field_lon_minutes.on_change = changed_fn; field_lon_minutes.on_change = changed_fn;
field_lon_seconds.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) { void GeoPos::set_read_only(bool v) {
@ -283,12 +288,14 @@ GeoMapView::GeoMapView(
NavigationView& nav, NavigationView& nav,
const std::string& tag, const std::string& tag,
int32_t altitude, int32_t altitude,
GeoPos::alt_unit altitude_unit,
float lat, float lat,
float lon, float lon,
float angle, float angle,
const std::function<void(void)> on_close const std::function<void(void)> on_close
) : nav_ (nav), ) : nav_ (nav),
altitude_ (altitude), altitude_ (altitude),
altitude_unit_ (altitude_unit),
lat_ (lat), lat_ (lat),
lon_ (lon), lon_ (lon),
angle_ (angle), angle_ (angle),
@ -314,11 +321,13 @@ GeoMapView::GeoMapView(
GeoMapView::GeoMapView( GeoMapView::GeoMapView(
NavigationView& nav, NavigationView& nav,
int32_t altitude, int32_t altitude,
GeoPos::alt_unit altitude_unit,
float lat, float lat,
float lon, float lon,
const std::function<void(int32_t, float, float)> on_done const std::function<void(int32_t, float, float)> on_done
) : nav_ (nav), ) : nav_ (nav),
altitude_ (altitude), altitude_ (altitude),
altitude_unit_ (altitude_unit),
lat_ (lat), lat_ (lat),
lon_ (lon) lon_ (lon)
{ {

View File

@ -39,9 +39,14 @@ enum GeoMapMode {
class GeoPos : public View { class GeoPos : public View {
public: public:
enum alt_unit {
FEET = 0,
METERS
};
std::function<void(int32_t, float, float)> on_change { }; std::function<void(int32_t, float, float)> on_change { };
GeoPos(const Point pos); GeoPos(const Point pos, const alt_unit altitude_unit);
void focus() override; void focus() override;
@ -58,9 +63,10 @@ public:
private: private:
bool read_only { false }; bool read_only { false };
bool report_change { true }; bool report_change { true };
alt_unit altitude_unit_ { };
Labels labels_position { 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, 1 * 16 }, "Lat: * ' \"", Color::light_grey() }, // No ° symbol in 8x16 font
{ { 1 * 8, 2 * 16 }, "Lon: * ' \"", Color::light_grey() }, { { 1 * 8, 2 * 16 }, "Lon: * ' \"", Color::light_grey() },
}; };
@ -72,6 +78,10 @@ private:
250, 250,
' ' ' '
}; };
Text text_alt_unit {
{ 12 * 8, 0 * 16, 2 * 8, 16 },
""
};
NumberField field_lat_degrees { NumberField field_lat_degrees {
{ 5 * 8, 1 * 16 }, 4, { -90, 90 }, 1, ' ' { 5 * 8, 1 * 16 }, 4, { -90, 90 }, 1, ' '
@ -141,6 +151,7 @@ public:
NavigationView& nav, NavigationView& nav,
const std::string& tag, const std::string& tag,
int32_t altitude, int32_t altitude,
GeoPos::alt_unit altitude_unit,
float lat, float lat,
float lon, float lon,
float angle, float angle,
@ -148,6 +159,7 @@ public:
); );
GeoMapView(NavigationView& nav, GeoMapView(NavigationView& nav,
int32_t altitude, int32_t altitude,
GeoPos::alt_unit altitude_unit,
float lat, float lat,
float lon, float lon,
const std::function<void(int32_t, float, float)> on_done const std::function<void(int32_t, float, float)> on_done
@ -175,6 +187,7 @@ private:
const Dim banner_height = 3 * 16; const Dim banner_height = 3 * 16;
GeoMapMode mode_ { }; GeoMapMode mode_ { };
int32_t altitude_ { }; int32_t altitude_ { };
GeoPos::alt_unit altitude_unit_ { };
float lat_ { }; float lat_ { };
float lon_ { }; float lon_ { };
float angle_ { }; float angle_ { };
@ -183,7 +196,8 @@ private:
bool map_opened { }; bool map_opened { };
GeoPos geopos { GeoPos geopos {
{ 0, 0 } { 0, 0 },
altitude_unit_
}; };
GeoMap geomap { GeoMap geomap {

View File

@ -88,6 +88,7 @@ SondeView::SondeView(NavigationView& nav) {
nav.push<GeoMapView>( nav.push<GeoMapView>(
"", "",
altitude, altitude,
GeoPos::alt_unit::METERS,
latitude, latitude,
longitude, longitude,
0); 0);
@ -113,7 +114,7 @@ void SondeView::on_packet(const sonde::Packet& packet) {
text_signature.set(packet.signature()); text_signature.set(packet.signature());
text_serial.set(packet.serial_number()); 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(); altitude = packet.GPS_altitude();
latitude = packet.GPS_latitude(); latitude = packet.GPS_latitude();

View File

@ -97,7 +97,7 @@ private:
}; };
Checkbox check_log { Checkbox check_log {
{ 22 * 8, 2 * 16 + 8 }, { 22 * 8, 2 * 16 + 12 },
3, 3,
"Log" "Log"
}; };
@ -116,7 +116,8 @@ private:
}; };
GeoPos geopos { GeoPos geopos {
{ 0, 6 * 16 } { 0, 6 * 16 },
GeoPos::alt_unit::METERS
}; };
Button button_see_map { Button button_see_map {

Binary file not shown.