How to use the cflib.crazyflie.mem.MemoryElement.TYPE_I2C function in cflib

To help you get started, we’ve selected a few cflib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bitcraze / crazyflie-clients-python / src / cfclient / ui / dialogs / cf2config.py View on Github external
def _write_data(self):
        self._write_data_btn.setEnabled(False)
        mem = self._cf.mem.get_mems(MemoryElement.TYPE_I2C)[0]
        mem.elements["pitch_trim"] = self._pitch_trim.value()
        mem.elements["roll_trim"] = self._roll_trim.value()
        mem.elements["radio_channel"] = self._radio_channel.value()
        mem.elements["radio_speed"] = self._radio_speed.currentIndex()
        if "radio_address" in mem.elements:
            mem.elements["radio_address"] = self._radio_address.value()
        mem.write_data(self._write_done)
github bitcraze / crazyflie-clients-python / src / cfclient / ui / main.py View on Github external
self.linkQualityBar.setValue(0)
            self.menuItemBootloader.setEnabled(True)
            self.logConfigAction.setEnabled(False)
            self.interfaceCombo.setEnabled(True)
        elif self.uiState == UIState.CONNECTED:
            s = "Connected on %s" % self._selected_interface
            self.setWindowTitle(s)
            self.menuItemConnect.setText("Disconnect")
            self.menuItemConnect.setEnabled(True)
            self.connectButton.setText("Disconnect")
            self.connectButton.setToolTip("Disconnect from the Crazyflie")
            self.scanButton.setEnabled(False)
            self.logConfigAction.setEnabled(True)
            # Find out if there's an I2C EEPROM, otherwise don't show the
            # dialog.
            if len(self.cf.mem.get_mems(MemoryElement.TYPE_I2C)) > 0:
                self._menu_cf2_config.setEnabled(True)
            self._menu_cf1_config.setEnabled(False)
        elif self.uiState == UIState.CONNECTING:
            s = "Connecting to {} ...".format(self._selected_interface)
            self.setWindowTitle(s)
            self.menuItemConnect.setText("Cancel")
            self.menuItemConnect.setEnabled(True)
            self.connectButton.setText("Cancel")
            self.connectButton.setToolTip("Cancel connecting to the Crazyflie")
            self.scanButton.setEnabled(False)
            self.address.setEnabled(False)
            self.menuItemBootloader.setEnabled(False)
            self.interfaceCombo.setEnabled(False)
        elif self.uiState == UIState.SCANNING:
            self.setWindowTitle("Scanning ...")
            self.connectButton.setText("Connect")
github bitcraze / crazyflie-clients-python / examples / write-eeprom.py View on Github external
def _connected(self, link_uri):
        """ This callback is called form the Crazyflie API when a Crazyflie
        has been connected and the TOCs have been downloaded."""
        print("Connected to %s" % link_uri)

        mems = self._cf.mem.get_mems(MemoryElement.TYPE_I2C)
        print("Found {} EEPOM(s)".format(len(mems)))
        if len(mems) > 0:
            print("Writing default configuration to"
                  " memory {}".format(mems[0].id))

            elems = mems[0].elements
            elems["version"] = 1
            elems["pitch_trim"] = 0.0
            elems["roll_trim"] = 0.0
            elems["radio_channel"] = 80
            elems["radio_speed"] = 0
            elems["radio_address"] = 0xE7E7E7E7E7

            mems[0].write_data(self._data_written)
github bitcraze / crazyflie-clients-python / examples / read-eeprom.py View on Github external
def _connected(self, link_uri):
        """ This callback is called form the Crazyflie API when a Crazyflie
        has been connected and the TOCs have been downloaded."""
        print("Connected to %s" % link_uri)

        mems = self._cf.mem.get_mems(MemoryElement.TYPE_I2C)
        print("Found {} EEPOM(s)".format(len(mems)))
        self._mems_to_update = len(mems)
        for m in mems:
            print("Updating id={}".format(m.id))
            m.update(self._data_updated)
github bitcraze / crazyflie-clients-python / src / cfclient / ui / main.py View on Github external
self.menuItemBootloader.setEnabled(True)
            self.logConfigAction.setEnabled(False)
            self.interfaceCombo.setEnabled(True)
        elif self.uiState == UIState.CONNECTED:
            s = "Connected on %s" % self._selected_interface
            self.setWindowTitle(s)
            self.menuItemConnect.setText("Disconnect")
            self.menuItemConnect.setEnabled(True)
            self.connectButton.setText("Disconnect")
            self.connectButton.setToolTip("Disconnect from"
                                          "the Crazyflie (Ctrl+I)")
            self.scanButton.setEnabled(False)
            self.logConfigAction.setEnabled(True)
            # Find out if there's an I2C EEPROM, otherwise don't show the
            # dialog.
            if len(self.cf.mem.get_mems(MemoryElement.TYPE_I2C)) > 0:
                self._menu_cf2_config.setEnabled(True)
            self._menu_cf1_config.setEnabled(False)
        elif self.uiState == UIState.CONNECTING:
            s = "Connecting to {} ...".format(self._selected_interface)
            self.setWindowTitle(s)
            self.menuItemConnect.setText("Cancel")
            self.menuItemConnect.setEnabled(True)
            self.connectButton.setText("Cancel")
            self.connectButton.setToolTip(
                "Cancel connecting to the Crazyflie")
            self.scanButton.setEnabled(False)
            self.address.setEnabled(False)
            self.menuItemBootloader.setEnabled(False)
            self.interfaceCombo.setEnabled(False)
        elif self.uiState == UIState.SCANNING:
            self.setWindowTitle("Scanning ...")
github bitcraze / crazyflie-clients-python / src / cfclient / ui / dialogs / cf2config.py View on Github external
def _write_done(self, mem, addr):
        self._cf.mem.get_mems(
            MemoryElement.TYPE_I2C)[0].update(self._data_updated)