mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2026-09-10 16:49:36 +00:00
Made a GeoPos widget for lon/lat/alt entry and display (APRS...)
Cleaned up the GeoMap view, can be used as input
This commit is contained in:
@@ -29,14 +29,70 @@
|
||||
|
||||
namespace ui {
|
||||
|
||||
class GeoMapView : public View {
|
||||
class GeoPos : public View {
|
||||
public:
|
||||
enum Mode {
|
||||
SHOW,
|
||||
SET
|
||||
std::function<void(void)> on_change { };
|
||||
|
||||
GeoPos(const Point pos);
|
||||
|
||||
void focus() override;
|
||||
|
||||
void set_read_only(bool v);
|
||||
void set_altitude(int32_t altitude);
|
||||
void set_lat(float lat);
|
||||
void set_lon(float lon);
|
||||
float lat();
|
||||
float lon();
|
||||
int32_t altitude();
|
||||
|
||||
private:
|
||||
bool read_only { false };
|
||||
|
||||
Labels labels_position {
|
||||
{ { 2 * 8, 0 * 16 }, "Alt: feet", Color::light_grey() },
|
||||
{ { 2 * 8, 1 * 16 }, "Lat: * ' \"", Color::light_grey() }, // No ° symbol in 8x16 font
|
||||
{ { 2 * 8, 2 * 16 }, "Lon: * ' \"", Color::light_grey() },
|
||||
};
|
||||
|
||||
GeoMapView(NavigationView& nav, Mode mode);
|
||||
NumberField field_altitude {
|
||||
{ 7 * 8, 0 * 16 },
|
||||
5,
|
||||
{ -1000, 50000 },
|
||||
250,
|
||||
' '
|
||||
};
|
||||
|
||||
NumberField field_lat_degrees {
|
||||
{ 7 * 8, 1 * 16 }, 4, { -90, 90 }, 1, ' '
|
||||
};
|
||||
NumberField field_lat_minutes {
|
||||
{ 12 * 8, 1 * 16 }, 2, { 0, 59 }, 1, ' '
|
||||
};
|
||||
NumberField field_lat_seconds {
|
||||
{ 15 * 8, 1 * 16 }, 2, { 0, 59 }, 1, ' '
|
||||
};
|
||||
|
||||
NumberField field_lon_degrees {
|
||||
{ 7 * 8, 2 * 16 }, 4, { -180, 180 }, 1, ' '
|
||||
};
|
||||
NumberField field_lon_minutes {
|
||||
{ 12 * 8, 2 * 16 }, 2, { 0, 59 }, 1, ' '
|
||||
};
|
||||
NumberField field_lon_seconds {
|
||||
{ 15 * 8, 2 * 16 }, 2, { 0, 59 }, 1, ' '
|
||||
};
|
||||
};
|
||||
|
||||
class GeoMapView : public View {
|
||||
public:
|
||||
GeoMapView(NavigationView& nav, 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;
|
||||
GeoMapView(GeoMapView&&) = delete;
|
||||
GeoMapView& operator=(const GeoMapView&) = delete;
|
||||
GeoMapView& operator=(GeoMapView&&) = delete;
|
||||
|
||||
~GeoMapView();
|
||||
|
||||
void focus() override;
|
||||
@@ -44,42 +100,37 @@ public:
|
||||
std::string title() const override { return "Map view"; };
|
||||
|
||||
private:
|
||||
enum Mode {
|
||||
DISPLAY,
|
||||
PROMPT
|
||||
};
|
||||
|
||||
const Dim banner_height = 3 * 16;
|
||||
NavigationView& nav_;
|
||||
const std::function<void(int32_t, float, float)> on_done { };
|
||||
Mode mode_ { };
|
||||
std::string* tag_ { };
|
||||
int32_t altitude_ { };
|
||||
float lat_ { };
|
||||
float lon_ { };
|
||||
float angle_ { };
|
||||
|
||||
File map_file { };
|
||||
bool file_error { false };
|
||||
uint16_t map_width { }, map_height { };
|
||||
int32_t map_center_x { }, map_center_y { };
|
||||
|
||||
void setup();
|
||||
void move_map();
|
||||
Point polar_to_point(const uint8_t angle, const uint32_t size);
|
||||
void draw_bearing(const Point origin, const uint8_t angle, uint32_t size, const Color color);
|
||||
void draw_bearing(const Point origin, const uint32_t angle, uint32_t size, const Color color);
|
||||
|
||||
Labels labels {
|
||||
{ { 0 * 8, 0 * 8 }, "Test", Color::light_grey() }
|
||||
GeoPos geopos {
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
NumberField field_xpos {
|
||||
{ 0, 0 },
|
||||
4,
|
||||
{ -180, 180 },
|
||||
1,
|
||||
'0'
|
||||
};
|
||||
NumberField field_ypos {
|
||||
{ 6 * 8, 0 },
|
||||
4,
|
||||
{ -90, 90 },
|
||||
1,
|
||||
'0'
|
||||
};
|
||||
NumberField field_angle {
|
||||
{ 12 * 8, 0 },
|
||||
3,
|
||||
{ 0, 255 },
|
||||
1,
|
||||
'0'
|
||||
Button button_ok {
|
||||
{ 20 * 8, 8, 8 * 8, 2 * 16 },
|
||||
"OK"
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user