Skip to content

Commit

Permalink
Added deck information to the about box.
Browse files Browse the repository at this point in the history
  • Loading branch information
krichardsson committed Feb 20, 2019
1 parent deb2d4b commit 2e7c534
Showing 1 changed file with 44 additions and 4 deletions.
48 changes: 44 additions & 4 deletions src/cfclient/ui/dialogs/about.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down Expand Up @@ -64,8 +65,13 @@
<b>Crazyflie</b><br>
Connected: {uri}<br>
Firmware: {firmware}<br>
<br>
<b>Decks found</b><br>
{decks}
<br>
<b>Sensors found</b><br>
{imu_sensors}
<br>
<b>Sensors tests</b><br>
{imu_sensor_tests}
"""
Expand All @@ -76,6 +82,7 @@
IMU_SENSORS_FORMAT = "{}: {}<br>"
SENSOR_TESTS_FORMAT = "{}: {}<br>"
FIRMWARE_FORMAT = "{:x}{:x} ({})"
DECK_FORMAT = "{}: rev={}, adr={}<br>"

CREDITS_FORMAT = """
<b>Contributions</b><br>
Expand All @@ -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"""

Expand All @@ -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(
Expand All @@ -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:
Expand All @@ -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()
Expand All @@ -163,10 +175,16 @@ def showEvent(self, event):
self._input_readers_text = "None<br>"

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,
Expand All @@ -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"""
Expand Down Expand Up @@ -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()

0 comments on commit 2e7c534

Please sign in to comment.