From 2e7c5348136d580338816209a41f5483f3513bab Mon Sep 17 00:00:00 2001 From: Kristoffer Richardsson Date: Wed, 20 Feb 2019 13:59:40 +0100 Subject: [PATCH] Added deck information to the about box. --- src/cfclient/ui/dialogs/about.py | 48 +++++++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 4 deletions(-) diff --git a/src/cfclient/ui/dialogs/about.py b/src/cfclient/ui/dialogs/about.py index 4b5d4536cc..59b79dc816 100644 --- a/src/cfclient/ui/dialogs/about.py +++ b/src/cfclient/ui/dialogs/about.py @@ -36,6 +36,7 @@ from PyQt5 import QtWidgets from PyQt5 import uic from PyQt5.QtCore import pyqtSignal +from cflib.crazyflie.mem import MemoryElement __author__ = 'Bitcraze AB' __all__ = ['AboutDialog'] @@ -64,8 +65,13 @@ Crazyflie
Connected: {uri}
Firmware: {firmware}
+
+Decks found
+{decks} +
Sensors found
{imu_sensors} +
Sensors tests
{imu_sensor_tests} """ @@ -76,6 +82,7 @@ IMU_SENSORS_FORMAT = "{}: {}
" SENSOR_TESTS_FORMAT = "{}: {}
" FIRMWARE_FORMAT = "{:x}{:x} ({})" +DECK_FORMAT = "{}: rev={}, adr={}
" CREDITS_FORMAT = """ Contributions
@@ -94,6 +101,7 @@ class AboutDialog(QtWidgets.QWidget, about_widget_class): _disconnected_signal = pyqtSignal(str) + _cb_deck_data_updated_signal = pyqtSignal(object) """Crazyflie client About box for debugging and information""" @@ -107,10 +115,13 @@ def __init__(self, helper, *args): self._interface_text = "" self._imu_sensors_text = "" self._imu_sensor_test_text = "" + self._decks_text = "" self._uri = None self._fw_rev0 = None self._fw_rev1 = None self._fw_modified = None + self._firmware = None + self._helper = helper helper.cf.param.add_update_callback( @@ -124,6 +135,8 @@ def __init__(self, helper, *args): self._disconnected_signal.connect(self._disconnected) helper.cf.disconnected.add_callback(self._disconnected_signal.emit) + self._cb_deck_data_updated_signal.connect(self._deck_data_updated) + # Open the Credits file and show it in the UI credits = "" try: @@ -144,7 +157,6 @@ def showEvent(self, event): for key in list(interface_status.keys()): self._interface_text += INTERFACE_FORMAT.format( key, interface_status[key]) - firmware = None self._device_text = "" devs = self._helper.inputDeviceReader.available_devices() @@ -163,10 +175,16 @@ def showEvent(self, event): self._input_readers_text = "None
" if self._uri: - firmware = FIRMWARE_FORMAT.format( + self._firmware = FIRMWARE_FORMAT.format( self._fw_rev0, self._fw_rev1, "MODIFIED" if self._fw_modified else "CLEAN") + + self._request_deck_data_update() + + self._update_debug_info_view() + + def _update_debug_info_view(self): self._debug_out.setHtml( DEBUG_INFO_FORMAT.format( version=cfclient.VERSION, @@ -180,9 +198,10 @@ def showEvent(self, event): input_devices=self._device_text, input_readers=self._input_readers_text, uri=self._uri, - firmware=firmware, + firmware=self._firmware, imu_sensors=self._imu_sensors_text, - imu_sensor_tests=self._imu_sensor_test_text)) + imu_sensor_tests=self._imu_sensor_test_text, + decks=self._decks_text)) def _connected(self, uri): """Callback when Crazyflie is connected""" @@ -216,7 +235,28 @@ def _disconnected(self, uri): self._interface_text = "" self._imu_sensors_text = "" self._imu_sensor_test_text = "" + self._decks_text = "" self._uri = None self._fw_rev1 = None self._fw_rev0 = None self._fw_modified = None + self._firmware = None + + def _request_deck_data_update(self): + self._decks_text = "" + mems = self._helper.cf.mem.get_mems(MemoryElement.TYPE_1W) + for mem in mems: + mem.update(self._cb_deck_data_updated_signal.emit) + + def _deck_data_updated(self, deck_data): + name = 'N/A' + if "Board name" in deck_data.elements: + name = deck_data.elements["Board name"] + + rev = 'N/A' + if "Board revision" in deck_data.elements: + rev = deck_data.elements["Board revision"] + + self._decks_text += DECK_FORMAT.format(name, rev, deck_data.addr) + + self._update_debug_info_view()