From 0f8643258e2926874e5f26392fe720af489f62e1 Mon Sep 17 00:00:00 2001 From: Thomas Bouve Date: Sun, 20 Sep 2020 11:14:00 +0200 Subject: [PATCH 1/5] gps config updates --- pwnagotchi/plugins/default/gps.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/pwnagotchi/plugins/default/gps.py b/pwnagotchi/plugins/default/gps.py index d9c992b..7b6b8f6 100644 --- a/pwnagotchi/plugins/default/gps.py +++ b/pwnagotchi/plugins/default/gps.py @@ -10,7 +10,7 @@ from pwnagotchi.ui.view import BLACK class GPS(plugins.Plugin): __author__ = "evilsocket@gmail.com" - __version__ = "1.0.0" + __version__ = "1.0.1" __license__ = "GPL3" __description__ = "Save GPS coordinates whenever an handshake is captured." @@ -57,7 +57,7 @@ class GPS(plugins.Plugin): def on_ui_setup(self, ui): # add coordinates for other displays if ui.is_waveshare_v2(): - lat_pos = (127, 75) + lat_pos = (127, 74) lon_pos = (122, 84) alt_pos = (127, 94) elif ui.is_waveshare_v1(): @@ -66,21 +66,21 @@ class GPS(plugins.Plugin): alt_pos = (130, 90) elif ui.is_inky(): lat_pos = (127, 60) - lon_pos = (127, 70) + lon_pos = (122, 70) alt_pos = (127, 80) elif ui.is_waveshare144lcd(): # guessed values, add tested ones if you can lat_pos = (67, 73) lon_pos = (62, 83) alt_pos = (67, 93) - elif ui.is_dfrobot_v2: - lat_pos = (127, 75) + elif ui.is_dfrobot_v2(): + lat_pos = (127, 74) lon_pos = (122, 84) alt_pos = (127, 94) elif ui.is_waveshare27inch(): - lat_pos = (6,120) - lon_pos = (1,135) - alt_pos = (6,150) + lat_pos = (6, 120) + lon_pos = (1, 135) + alt_pos = (6, 150) else: # guessed values, add tested ones if you can lat_pos = (127, 51) @@ -126,7 +126,6 @@ class GPS(plugins.Plugin): ), ) - def on_unload(self, ui): with ui._lock: ui.remove_element('latitude') @@ -141,5 +140,5 @@ class GPS(plugins.Plugin): # last char is sometimes not completely drawn ¯\_(ツ)_/¯ # using an ending-whitespace as workaround on each line ui.set("latitude", f"{self.coordinates['Latitude']:.4f} ") - ui.set("longitude", f" {self.coordinates['Longitude']:.4f} ") - ui.set("altitude", f" {self.coordinates['Altitude']:.1f}m ") + ui.set("longitude", f"{self.coordinates['Longitude']:.4f} ") + ui.set("altitude", f"{self.coordinates['Altitude']:.1f}m ") From e72e2292a897b7eb26f9a77dee4d8d58e60b8ac4 Mon Sep 17 00:00:00 2001 From: Thomas Bouve Date: Sun, 20 Sep 2020 20:22:39 +0200 Subject: [PATCH 2/5] Update guessed coordinates based on other values. --- pwnagotchi/plugins/default/gps.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pwnagotchi/plugins/default/gps.py b/pwnagotchi/plugins/default/gps.py index 7b6b8f6..644fb75 100644 --- a/pwnagotchi/plugins/default/gps.py +++ b/pwnagotchi/plugins/default/gps.py @@ -84,8 +84,8 @@ class GPS(plugins.Plugin): else: # guessed values, add tested ones if you can lat_pos = (127, 51) - lon_pos = (127, 56) - alt_pos = (102, 71) + lon_pos = (122, 61) + alt_pos = (127, 71) label_spacing = 0 From fb7217b0fa28f5bb4fa9a6e52abe869032547ac5 Mon Sep 17 00:00:00 2001 From: Thomas Bouve Date: Sun, 20 Sep 2020 21:10:10 +0200 Subject: [PATCH 3/5] Add configuration options and cleanup - added support for configuring the plugin position and vertical line spacing - fix default values for some displays which appeared to be incorrect - change `ui.is_dfrobot_v2` to a function (to match other display entries) - version bump to 1.0.2 --- pwnagotchi/plugins/default/gps.py | 88 ++++++++++++++++++------------- 1 file changed, 52 insertions(+), 36 deletions(-) diff --git a/pwnagotchi/plugins/default/gps.py b/pwnagotchi/plugins/default/gps.py index 644fb75..b99a557 100644 --- a/pwnagotchi/plugins/default/gps.py +++ b/pwnagotchi/plugins/default/gps.py @@ -10,10 +10,13 @@ from pwnagotchi.ui.view import BLACK class GPS(plugins.Plugin): __author__ = "evilsocket@gmail.com" - __version__ = "1.0.1" + __version__ = "1.0.2" __license__ = "GPL3" __description__ = "Save GPS coordinates whenever an handshake is captured." + LINE_SPACING = 10 + LABEL_SPACING = 0 + def __init__(self): self.running = False self.coordinates = None @@ -55,39 +58,52 @@ class GPS(plugins.Plugin): logging.info("not saving GPS. Couldn't find location.") def on_ui_setup(self, ui): - # add coordinates for other displays - if ui.is_waveshare_v2(): - lat_pos = (127, 74) - lon_pos = (122, 84) - alt_pos = (127, 94) - elif ui.is_waveshare_v1(): - lat_pos = (130, 70) - lon_pos = (125, 80) - alt_pos = (130, 90) - elif ui.is_inky(): - lat_pos = (127, 60) - lon_pos = (122, 70) - alt_pos = (127, 80) - elif ui.is_waveshare144lcd(): - # guessed values, add tested ones if you can - lat_pos = (67, 73) - lon_pos = (62, 83) - alt_pos = (67, 93) - elif ui.is_dfrobot_v2(): - lat_pos = (127, 74) - lon_pos = (122, 84) - alt_pos = (127, 94) - elif ui.is_waveshare27inch(): - lat_pos = (6, 120) - lon_pos = (1, 135) - alt_pos = (6, 150) - else: - # guessed values, add tested ones if you can - lat_pos = (127, 51) - lon_pos = (122, 61) - alt_pos = (127, 71) + try: + # Configure line_spacing + line_spacing = int(self.options['linespacing']) + except Exception: + # Set default value + line_spacing = self.LINE_SPACING - label_spacing = 0 + try: + # Configure position + pos = self.options['position'].split(',') + pos = [int(x.strip()) for x in pos] + lat_pos = (pos[0], pos[1]) + lon_pos = (pos[0], pos[1] + line_spacing) + alt_pos = (pos[0], pos[1] + (2 * line_spacing)) + except Exception: + # Set default value based on display type + if ui.is_waveshare_v2(): + lat_pos = (127, 74) + lon_pos = (122, 84) + alt_pos = (127, 94) + elif ui.is_waveshare_v1(): + lat_pos = (130, 70) + lon_pos = (125, 80) + alt_pos = (130, 90) + elif ui.is_inky(): + lat_pos = (127, 60) + lon_pos = (122, 70) + alt_pos = (127, 80) + elif ui.is_waveshare144lcd(): + # guessed values, add tested ones if you can + lat_pos = (67, 73) + lon_pos = (62, 83) + alt_pos = (67, 93) + elif ui.is_dfrobot_v2(): + lat_pos = (127, 74) + lon_pos = (122, 84) + alt_pos = (127, 94) + elif ui.is_waveshare27inch(): + lat_pos = (6, 120) + lon_pos = (1, 135) + alt_pos = (6, 150) + else: + # guessed values, add tested ones if you can + lat_pos = (127, 51) + lon_pos = (122, 61) + alt_pos = (127, 71) ui.add_element( "latitude", @@ -98,7 +114,7 @@ class GPS(plugins.Plugin): position=lat_pos, label_font=fonts.Small, text_font=fonts.Small, - label_spacing=label_spacing, + label_spacing=self.LABEL_SPACING, ), ) ui.add_element( @@ -110,7 +126,7 @@ class GPS(plugins.Plugin): position=lon_pos, label_font=fonts.Small, text_font=fonts.Small, - label_spacing=label_spacing, + label_spacing=self.LABEL_SPACING, ), ) ui.add_element( @@ -122,7 +138,7 @@ class GPS(plugins.Plugin): position=alt_pos, label_font=fonts.Small, text_font=fonts.Small, - label_spacing=label_spacing, + label_spacing=self.LABEL_SPACING, ), ) From c535ffd40ec30eb38c096eff5b25049d444f4fdd Mon Sep 17 00:00:00 2001 From: Thomas Bouve Date: Sun, 20 Sep 2020 21:24:33 +0200 Subject: [PATCH 4/5] Fix version bump. --- pwnagotchi/plugins/default/gps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pwnagotchi/plugins/default/gps.py b/pwnagotchi/plugins/default/gps.py index b99a557..667a266 100644 --- a/pwnagotchi/plugins/default/gps.py +++ b/pwnagotchi/plugins/default/gps.py @@ -10,7 +10,7 @@ from pwnagotchi.ui.view import BLACK class GPS(plugins.Plugin): __author__ = "evilsocket@gmail.com" - __version__ = "1.0.2" + __version__ = "1.0.1" __license__ = "GPL3" __description__ = "Save GPS coordinates whenever an handshake is captured." From 5c6d8dc807e64a099f3234dad067a2d9b6d43716 Mon Sep 17 00:00:00 2001 From: Thomas Bouve Date: Sun, 20 Sep 2020 22:12:54 +0200 Subject: [PATCH 5/5] Adjust x coordinate for longer long field. --- pwnagotchi/plugins/default/gps.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pwnagotchi/plugins/default/gps.py b/pwnagotchi/plugins/default/gps.py index 667a266..d068792 100644 --- a/pwnagotchi/plugins/default/gps.py +++ b/pwnagotchi/plugins/default/gps.py @@ -69,9 +69,9 @@ class GPS(plugins.Plugin): # Configure position pos = self.options['position'].split(',') pos = [int(x.strip()) for x in pos] - lat_pos = (pos[0], pos[1]) + lat_pos = (pos[0] + 5, pos[1]) lon_pos = (pos[0], pos[1] + line_spacing) - alt_pos = (pos[0], pos[1] + (2 * line_spacing)) + alt_pos = (pos[0] + 5, pos[1] + (2 * line_spacing)) except Exception: # Set default value based on display type if ui.is_waveshare_v2():