diff --git a/pwnagotchi/plugins/default/gps.py b/pwnagotchi/plugins/default/gps.py index d9c992bfd..1fb7030f5 100644 --- a/pwnagotchi/plugins/default/gps.py +++ b/pwnagotchi/plugins/default/gps.py @@ -57,7 +57,7 @@ def on_handshake(self, agent, filename, access_point, client_station): 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 @@ def on_ui_setup(self, ui): 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 @@ def on_ui_setup(self, ui): ), ) - def on_unload(self, ui): with ui._lock: ui.remove_element('latitude') @@ -141,5 +140,5 @@ def on_ui_update(self, ui): # 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 ") diff --git a/pwnagotchi/plugins/default/memtemp.py b/pwnagotchi/plugins/default/memtemp.py index f64e287dc..4f00cccb8 100644 --- a/pwnagotchi/plugins/default/memtemp.py +++ b/pwnagotchi/plugins/default/memtemp.py @@ -17,7 +17,7 @@ # - Added horizontal and vertical orientation # ############################################################### -from pwnagotchi.ui.components import LabeledValue +from pwnagotchi.ui.components import LabeledValue, Text from pwnagotchi.ui.view import BLACK import pwnagotchi.ui.fonts as fonts import pwnagotchi.plugins as plugins @@ -40,39 +40,118 @@ def mem_usage(self): def cpu_load(self): return int(pwnagotchi.cpu_load() * 100) + @staticmethod + def pad_text(width, data, symbol): + data = str(data) + symbol + return " " * (width - len(data)) + data + def on_ui_setup(self, ui): if ui.is_waveshare_v2(): - h_pos = (180, 80) - v_pos = (180, 61) + h_pos_line1 = (178, 84) + h_pos_line2 = (178, 94) + v_pos_line1 = (202, 74) # (127, 75) + v_pos_line2 = (202, 84) # (122, 84) + v_pos_line3 = (197, 94) # (127, 94) elif ui.is_waveshare_v1(): - h_pos = (170, 80) - v_pos = (170, 61) + h_pos_line1 = (170, 80) + h_pos_line2 = (170, 90) + v_pos_line1 = (170, 61) # (130, 70) + v_pos_line2 = (170, 71) # (125, 80) + v_pos_line3 = (165, 81) # (130, 90) elif ui.is_waveshare144lcd(): - h_pos = (53, 77) - v_pos = (78, 67) + h_pos_line1 = (53, 77) + h_pos_line2 = (53, 87) + v_pos_line1 = (78, 67) # (67, 73) + v_pos_line2 = (78, 77) # (62, 83) + v_pos_line3 = (73, 87) # (67, 93) elif ui.is_inky(): - h_pos = (140, 68) - v_pos = (165, 54) + h_pos_line1 = (140, 68) + h_pos_line2 = (140, 78) + v_pos_line1 = (165, 54) # (127, 60) + v_pos_line2 = (165, 64) # (122, 70) + v_pos_line3 = (160, 74) # (127, 80) elif ui.is_waveshare27inch(): - h_pos = (192, 138) - v_pos = (216, 122) + h_pos_line1 = (192, 138) + h_pos_line2 = (192, 148) + v_pos_line1 = (216, 122) # (6,120) + v_pos_line2 = (216, 132) # (1,135) + v_pos_line3 = (211, 142) # (6,150) else: - h_pos = (155, 76) - v_pos = (180, 61) + h_pos_line1 = (155, 76) + h_pos_line2 = (155, 86) + v_pos_line1 = (180, 61) # (127, 51) + v_pos_line2 = (180, 71) # (127, 56) + v_pos_line3 = (175, 81) # (102, 71) + + label_spacing = 0 if self.options['orientation'] == "vertical": - ui.add_element('memtemp', LabeledValue(color=BLACK, label='', value=' mem:-\n cpu:-\ntemp:-', - position=v_pos, - label_font=fonts.Small, text_font=fonts.Small)) + ui.add_element( + 'memtemp_line1', + LabeledValue( + color=BLACK, + label='mem:', + value='-', + position=v_pos_line1, + label_font=fonts.Small, + text_font=fonts.Small, + label_spacing=label_spacing, + ) + ) + ui.add_element( + 'memtemp_line2', + LabeledValue( + color=BLACK, + label='cpu:', + value='-', + position=v_pos_line2, + label_font=fonts.Small, + text_font=fonts.Small, + label_spacing=label_spacing, + ) + ) + ui.add_element( + 'memtemp_line3', + LabeledValue( + color=BLACK, + label='temp:', + value='-', + position=v_pos_line3, + label_font=fonts.Small, + text_font=fonts.Small, + label_spacing=label_spacing, + ) + ) else: # default to horizontal - ui.add_element('memtemp', LabeledValue(color=BLACK, label='', value='mem cpu temp\n - - -', - position=h_pos, - label_font=fonts.Small, text_font=fonts.Small)) + ui.add_element( + 'memtemp_line1', + Text( + color=BLACK, + value=' mem cpu temp', + position=h_pos_line1, + font=fonts.Small, + ) + ) + ui.add_element( + 'memtemp_line2', + Text( + color=BLACK, + value=' - - -', + position=h_pos_line2, + font=fonts.Small, + ) + ) def on_unload(self, ui): with ui._lock: - ui.remove_element('memtemp') + if self.options['orientation'] == "vertical": + ui.remove_element('memtemp_line1') + ui.remove_element('memtemp_line2') + ui.remove_element('memtemp_line3') + else: + ui.remove_element('memtemp_line1') + ui.remove_element('memtemp_line2') def on_ui_update(self, ui): if self.options['scale'] == "fahrenheit": @@ -87,9 +166,14 @@ def on_ui_update(self, ui): symbol = "c" if self.options['orientation'] == "vertical": - ui.set('memtemp', - " mem:%s%%\n cpu:%s%%\ntemp:%s%s" % (self.mem_usage(), self.cpu_load(), temp, symbol)) + ui.set('memtemp_line1', f"{self.mem_usage()}%") + ui.set('memtemp_line2', f"{self.cpu_load()}%") + ui.set('memtemp_line3', f"{temp}{symbol}") else: # default to horizontal - ui.set('memtemp', - " mem cpu temp\n %s%% %s%% %s%s" % (self.mem_usage(), self.cpu_load(), temp, symbol)) + ui.set( + 'memtemp_line2', + self.pad_text(4, self.mem_usage(), "%") + + self.pad_text(5, self.cpu_load(), "%") + + self.pad_text(5, temp, symbol) + )