From f93c338adfb6b279c156adbe26d1a64f929682e8 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Fri, 20 Oct 2023 13:00:54 +0200 Subject: [PATCH] Updated telemetry config and controls --- sbapp/sideband/core.py | 19 ++++++++++++--- sbapp/ui/layouts.py | 52 ++++++++++++++++++++++++++++++++++-------- 2 files changed, 59 insertions(+), 12 deletions(-) diff --git a/sbapp/sideband/core.py b/sbapp/sideband/core.py index 2fa913b..4091e6b 100644 --- a/sbapp/sideband/core.py +++ b/sbapp/sideband/core.py @@ -1378,6 +1378,22 @@ class SidebandCore(): else: self.setstate("wants.announce", True) + def update_telemetry(self): + if self.config["telemetry_enabled"] == True: + if self.telemeter == None: + self.telemeter = Telemeter() + + sensors = ["location", "orientation", "battery", "barometer", "temperature", "humidity", "compass", "light", "gravity", "gyroscope", "accelerometer", "proximity"] + for sensor in sensors: + if self.config["telemetry_s_"+sensor]: + self.telemeter.enable(sensor) + else: + self.telemeter.disable(sensor) + + def get_telemetry(self): + self.update_telemetry() + return self.telemeter.read_all() + def is_known(self, dest_hash): try: source_identity = RNS.Identity.recall(dest_hash) @@ -1412,9 +1428,6 @@ class SidebandCore(): # TODO: The "start_announce" config entry should be # renamed to "auto_announce", which is its current # meaning. - if self.config["telemetry_enabled"] == True: - pass - if self.config["start_announce"] == True: needs_if_change_announce = False diff --git a/sbapp/ui/layouts.py b/sbapp/ui/layouts.py index 3f6014c..6c1a531 100644 --- a/sbapp/ui/layouts.py +++ b/sbapp/ui/layouts.py @@ -868,12 +868,48 @@ MDNavigationLayout: text_size: self.width, None height: self.texture_size[1] + MDLabel: + markup: True + text: "\\n\\n" + size_hint_y: None + text_size: self.width, None + height: self.texture_size[1] + + MDBoxLayout: + orientation: "vertical" + spacing: dp(24) + size_hint_y: None + padding: [dp(0),dp(24),dp(0),dp(0)] + height: dp(74) + + MDRectangleFlatIconButton: + id: telemetry_icons_button + icon: "update" + text: "Send Telemetry Update Now" + padding: [dp(0), dp(14), dp(0), dp(14)] + icon_size: dp(24) + font_size: dp(16) + size_hint: [1.0, None] + on_release: root.ids.screen_manager.app.telemetry_update(self) + disabled: False + + MDRectangleFlatIconButton: + id: telemetry_icons_button + icon: "content-copy" + text: "Copy Telemetry Data To Clipboard" + padding: [dp(0), dp(14), dp(0), dp(14)] + icon_size: dp(24) + font_size: dp(16) + size_hint: [1.0, None] + on_release: root.ids.screen_manager.app.telemetry_copy(self) + disabled: False + MDBoxLayout: id: telemetry_enabled_fields orientation: "vertical" size_hint_y: None height: self.minimum_height - padding: [0, 0, 0, dp(0)] + padding: [0, dp(16), 0, dp(0)] MDTextField: id: telemetry_collector @@ -942,7 +978,7 @@ MDNavigationLayout: MDLabel: id: telemetry_info4 markup: True - text: "\\nYou can customise the display style of your telemetry data when viewed by others, by setting an icon and color options. This is usually used by clients to display your telemetry entry on a map or in lists and overviews. If left unset, the receiver will decide how to display the data.\\n\\n" + text: "\\nYou can customise the display style of your telemetry data when viewed by others, by setting an icon and color options. This is usually used by clients to display your telemetry entry on a map or in lists and overviews. If left unset, the receiver will decide how to display the data.\\n" size_hint_y: None text_size: self.width, None height: self.texture_size[1] @@ -950,15 +986,12 @@ MDNavigationLayout: MDBoxLayout: orientation: "vertical" size_hint_y: None - size_hint_x: None - # height: dp(96) - # width: dp(64) - spacing: dp(0) + height: dp(112) padding: [dp(0), dp(24), dp(0), dp(24)] pos_hint: {"center_x": .5} MDIconButton: - pos_hint: {"center_x": .5, "center_y": .5} + pos_hint: {"center_x": .5} id: telemetry_icon_preview icon: "alpha-p-circle-outline" type: "large" @@ -966,8 +999,9 @@ MDNavigationLayout: icon_color: [0, 0, 0, 1] md_bg_color: [1, 1, 1, 1] icon_size: dp(64) + size_hint_y: None # width: dp(64) - # height: dp(64) + height: dp(80) MDRectangleFlatIconButton: @@ -2386,7 +2420,7 @@ MDNavigationLayout: on_release: root.ids.screen_manager.app.telemetry_action(self) IconLeftWidget: - icon: "axis-arrow-lock" + icon: "map-marker-path" on_release: root.ids.screen_manager.app.telemetry_action(self)