From abb4385859162b8eef03072023fa548b01ab83dc Mon Sep 17 00:00:00 2001 From: Joel Wetzell Date: Wed, 1 Jul 2020 13:16:48 -0500 Subject: [PATCH 1/2] Adjust polar to point and bearing drawing --- firmware/application/ui/ui_geomap.cpp | 5 +++-- firmware/common/ui.cpp | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/firmware/application/ui/ui_geomap.cpp b/firmware/application/ui/ui_geomap.cpp index d7a07b36..868d16a0 100644 --- a/firmware/application/ui/ui_geomap.cpp +++ b/firmware/application/ui/ui_geomap.cpp @@ -169,8 +169,9 @@ void GeoMap::paint(Painter& painter) { display.fill_rectangle({ r.center() - Point(16, 1), { 32, 2 } }, Color::red()); display.fill_rectangle({ r.center() - Point(1, 16), { 2, 32 } }, Color::red()); } else { - draw_bearing({ 120, 32 + 144 }, angle_, 10, Color::red()); - painter.draw_string({ 120 - ((int)tag_.length() * 8 / 2), 32 + 144 - 32 }, style(), tag_); + //coordinates could probably be calculted off screen_rect()? + draw_bearing({ 120, 16 + 48 + 128 }, angle_, 10, Color::red()); + painter.draw_string({ 120 - ((int)tag_.length() * 8 / 2), 16 + 48 + 128 - 32 }, style(), tag_); } } diff --git a/firmware/common/ui.cpp b/firmware/common/ui.cpp index c257d1fa..406f5e49 100644 --- a/firmware/common/ui.cpp +++ b/firmware/common/ui.cpp @@ -91,7 +91,9 @@ Rect& Rect::operator-=(const Point& p) { } Point polar_to_point(float angle, uint32_t distance) { - return Point(sin_f32(DEG_TO_RAD(angle) + (pi / 2)) * distance, -sin_f32(DEG_TO_RAD(angle)) * distance); + //polar to compass with y negated for screen drawing + return Point(sin_f32(DEG_TO_RAD(-angle) + pi) * distance, + sin_f32(DEG_TO_RAD(-angle) - (pi / 2)) * distance); } } /* namespace ui */ From 2969a0fec9047030d2a6d456786b9c013bee7ff6 Mon Sep 17 00:00:00 2001 From: Joel Wetzell Date: Wed, 1 Jul 2020 15:39:35 -0500 Subject: [PATCH 2/2] use screen_rect for center coordinate --- firmware/application/ui/ui_geomap.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/firmware/application/ui/ui_geomap.cpp b/firmware/application/ui/ui_geomap.cpp index 868d16a0..f907825a 100644 --- a/firmware/application/ui/ui_geomap.cpp +++ b/firmware/application/ui/ui_geomap.cpp @@ -169,9 +169,9 @@ void GeoMap::paint(Painter& painter) { display.fill_rectangle({ r.center() - Point(16, 1), { 32, 2 } }, Color::red()); display.fill_rectangle({ r.center() - Point(1, 16), { 2, 32 } }, Color::red()); } else { - //coordinates could probably be calculted off screen_rect()? - draw_bearing({ 120, 16 + 48 + 128 }, angle_, 10, Color::red()); - painter.draw_string({ 120 - ((int)tag_.length() * 8 / 2), 16 + 48 + 128 - 32 }, style(), tag_); + draw_bearing(r.center(), angle_, 10, Color::red()); + //center tag above bearing + painter.draw_string(r.center() - Point(((int)tag_.length() * 8 / 2), 2 * 16), style(), tag_); } }