def set_settings(self, data_rate=None, data_range=None): """Set accelerometer settings. Can be called with two or only one setting: .. code-block:: python mwclient.set_accelerometer_settings(data_rate=200.0, data_range=8.0) will give the same result as .. code-block:: python mwclient.set_accelerometer_settings(data_rate=200.0) mwclient.set_accelerometer_settings(data_range=8.0) albeit that the latter example makes two writes to the board. Call :meth:`~get_possible_settings` to see which values that can be set for this sensor. :param float data_rate: The frequency of accelerometer updates in Hz. :param float data_range: The measurement range in the unit ``g``. """ if data_rate is not None: self.current_odr = data_rate odr = self._get_odr(data_rate) if self._debug: log.debug("Setting Accelerometer ODR to {0}".format(odr)) libmetawear.mbl_mw_acc_set_odr(self.board, c_float(odr)) if data_range is not None: self.current_fsr = data_range fsr = self._get_fsr(data_range) if self._debug: log.debug("Setting Accelerometer FSR to {0}".format(fsr)) libmetawear.mbl_mw_acc_set_range(self.board, c_float(fsr)) if (data_rate is not None) or (data_range is not None): self.current_odr = data_rate self.current_fsr = data_range libmetawear.mbl_mw_acc_write_acceleration_config(self.board)
def set_settings(self, data_rate=None, data_range=None): """Set accelerometer settings. Can be called with two or only one setting: .. code-block:: python mwclient.set_accelerometer_settings(data_rate=200.0, data_range=8.0) will give the same result as .. code-block:: python mwclient.set_accelerometer_settings(data_rate=200.0) mwclient.set_accelerometer_settings(data_range=8.0) albeit that the latter example makes two writes to the board. Call :meth:`~get_possible_settings` to see which values that can be set for this sensor. :param float data_rate: The frequency of accelerometer updates in Hz. :param float data_range: The measurement range in the unit ``g``. """ if data_rate is not None: self.current_odr = data_rate odr = self._get_odr(data_rate) log.debug("Setting Accelerometer ODR to {0}".format(odr)) libmetawear.mbl_mw_acc_set_odr(self.board, c_float(odr)) if data_range is not None: self.current_fsr = data_range fsr = self._get_fsr(data_range) log.debug("Setting Accelerometer FSR to {0}".format(fsr)) libmetawear.mbl_mw_acc_set_range(self.board, c_float(fsr)) if (data_rate is not None) or (data_range is not None): self.current_odr = data_rate self.current_fsr = data_range libmetawear.mbl_mw_acc_write_acceleration_config(self.board)
def set_settings(self, acc_range=None, acc_rate=None, gyr_range=None, gyr_rate=None, mag_power_preset=None): """ Set accelerometer, gyroscope and magnetometer settings. Can be called with multiple or only one setting: .. code-block:: python mwclient.sensorfusion2.set_settings(acc_rate=200.0, acc_range=8.0) will give the same result as .. code-block:: python mwclient.sensorfusion.set_settings(acc_rate=200.0) mwclient.sensorfusion.set_settings(acc_range=8.0) albeit that the latter example makes two writes to the board. Power preset for magnetometer should be a string: .. code-block:: python mwclient.sensorfusion.set_settings(power_preset="LOW_POWER") Call :meth:`~get_possible_settings` to see which values that can be set for the sensors. :param float acc_rate: The frequency of accelerometer updates in Hz. :param float acc_range: The measurement range in the unit ``g``. :param float gyr_rate: The frequency of gyroscope updates in Hz. :param float gyr_range: The measurement range in the unit ``dps``, degrees per second. :param str power_preset: The power preset, influencing the data rate, accuracy and power consumption """ if acc_rate is not None: self.acc_current_odr = acc_rate acc_odr = self._get_odr(acc_rate, 'acc') if self._debug: log.debug("Setting Accelerometer ODR to {0}".format(acc_odr)) libmetawear.mbl_mw_acc_set_odr(self.board, c_float(acc_odr)) if acc_range is not None: self.acc_current_fsr = acc_range acc_fsr = self._get_fsr(acc_range, 'acc') if self._debug: log.debug("Setting Accelerometer FSR to {0}".format(acc_fsr)) libmetawear.mbl_mw_acc_set_range(self.board, c_float(acc_fsr)) if gyr_rate is not None: gyr_odr = self._get_odr(gyr_rate, 'gyr') if self._debug: log.debug("Setting Gyroscope ODR to {0}".format(gyr_odr)) libmetawear.mbl_mw_gyro_bmi160_set_odr(self.board, gyr_odr) if gyr_range is not None: gyr_fsr = self._get_fsr(gyr_range, 'gyr') if self._debug: log.debug("Setting Gyroscope FSR to {0}".format(gyr_fsr)) libmetawear.mbl_mw_gyro_bmi160_set_range(self.board, gyr_fsr) if (acc_rate is not None) or (acc_range is not None): self.acc_current_odr = acc_rate self.acc_current_fsr = acc_range libmetawear.mbl_mw_acc_write_acceleration_config(self.board) if (gyr_rate is not None) or (gyr_range is not None): libmetawear.mbl_mw_gyro_bmi160_write_config(self.board) if mag_power_preset is not None: pp = self._get_power_preset(mag_power_preset) if self._debug: log.debug( "Setting Magnetometer power preset to {0}".format(pp)) libmetawear.mbl_mw_mag_bmm150_set_preset(self.board, pp)