Skip to content

Commit

Permalink
Read and set radio address from config if possible
Browse files Browse the repository at this point in the history
If we have a stored link_uri in the user config we parse it and set the
address field in the main ui to this value. This can save time for
someone who has changed their address for their single Crazyflie that
they are working with.

Closes bitcraze#382
  • Loading branch information
jonasdn committed Mar 9, 2021
1 parent 49de1f9 commit fa572a1
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/cfclient/ui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ def __init__(self, *args):

self._connectivity_manager.connect_button_clicked.connect(self._connect)
self._connectivity_manager.scan_button_clicked.connect(self._scan)
self._set_address()

self._auto_reconnect_enabled = Config().get("auto_reconnect")
self.autoReconnectCheckBox.toggled.connect(
Expand Down Expand Up @@ -360,6 +361,17 @@ def __init__(self, *args):
self._theme_group.addAction(node)
self.menuThemes.addAction(node)

def _set_address(self):
address = 0xE7E7E7E7E7
try:
link_uri = Config().get("link_uri")
if len(link_uri) > 0:
address = int(link_uri.split('/')[-1], 16)
except Exception as err:
logger.warn('failed to parse address from config: %s' % str(err))
finally:
self.address.setValue(address)

def _theme_selected(self, *args):
""" Callback when a theme is selected. """
for checkbox in self._theme_checkboxes:
Expand Down

0 comments on commit fa572a1

Please sign in to comment.