Skip to content

Commit

Permalink
bitcraze#286 Only try to read Loco Positioning memory when available …
Browse files Browse the repository at this point in the history
…(support for CF1)

Fixed similar problem for LED ring memory also
  • Loading branch information
krichardsson committed Feb 16, 2017
1 parent d753972 commit 83732e9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
13 changes: 3 additions & 10 deletions src/cfclient/ui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,13 +591,9 @@ def _connected(self):
except KeyError as e:
logger.warning(str(e))

mem = self.cf.mem.get_mems(MemoryElement.TYPE_DRIVER_LED)[0]
mem.write_data(self._led_write_done)

# self._led_write_test = 0

# mem.leds[self._led_write_test] = [10, 20, 30]
# mem.write_data(self._led_write_done)
mems = self.cf.mem.get_mems(MemoryElement.TYPE_DRIVER_LED)
if len(mems) > 0:
mems[0].write_data(self._led_write_done)

def _disconnected(self):
self.uiState = UIState.DISCONNECTED
Expand All @@ -609,9 +605,6 @@ def _connection_initiated(self):

def _led_write_done(self, mem, addr):
logger.info("LED write done callback")
# self._led_write_test += 1
# mem.leds[self._led_write_test] = [10, 20, 30]
# mem.write_data(self._led_write_done)

def _logging_error(self, log_conf, msg):
QMessageBox.about(self, "Log error", "Error when starting log config"
Expand Down
8 changes: 5 additions & 3 deletions src/cfclient/ui/tabs/LEDTab.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,11 @@ def _led_write_done(self, mem, addr):

def _connected(self, link_uri):
"""Callback when the Crazyflie has been connected"""
self._mem = self._helper.cf.mem.get_mems(
MemoryElement.TYPE_DRIVER_LED)[0]
logger.info(self._mem)
mems = self._helper.cf.mem.get_mems(MemoryElement.TYPE_DRIVER_LED)
if len(mems) > 0:
self._mem = mems[0]
logger.info(self._mem)

if self._mem:
for btn in self._btns:
btn.setEnabled(True)
Expand Down
5 changes: 3 additions & 2 deletions src/cfclient/ui/tabs/locopositioning_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,8 +505,9 @@ def _stop_polling_anchor_pos(self):
self._anchor_pos_timer.stop()

def _poll_anchor_positions(self):
mem = self._helper.cf.mem.get_mems(MemoryElement.TYPE_LOCO)[0]
mem.update(self._anchor_position_signal.emit)
mems = self._helper.cf.mem.get_mems(MemoryElement.TYPE_LOCO)
if len(mems) > 0:
mems[0].update(self._anchor_position_signal.emit)

def _anchor_positions_updated(self, mem):
"""Callback from the memory sub system when the anchor positions
Expand Down

0 comments on commit 83732e9

Please sign in to comment.