Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add calibration offsets and radii as properties on BNO055 library #30

Open
wants to merge 6 commits into
base: master
from
Next

Add calibration offsets and radii as properties on BNO055 library

  • Loading branch information
katlings committed Feb 26, 2019
commit 768f33b07cd0f09ad9da7fc6e8b82d61fff91548
@@ -62,6 +62,11 @@
_MODE_REGISTER = const(0x3d)
_PAGE_REGISTER = const(0x07)
_CALIBRATION_REGISTER = const(0x35)
_OFFSET_ACCEL_REGISTER = const(0x55)
_OFFSET_MAGNET_REGISTER = const(0x5b)
_OFFSET_GYRO_REGISTER = const(0x61)
_RADIUS_ACCEL_REGISTER = const(0x67)
_RADIUS_MAGNET_REGISTER = const(0x69)
_TRIGGER_REGISTER = const(0x3f)
_POWER_REGISTER = const(0x3e)
_ID_REGISTER = const(0x00)
@@ -213,6 +218,52 @@ def calibrated(self):
sys, gyro, accel, mag = self.calibration_status
return sys == gyro == accel == mag == 0x03

_offsets_accelerometer = Struct(_OFFSET_ACCEL_REGISTER, '<hhh')
_offsets_magnetometer = Struct(_OFFSET_MAGNET_REGISTER, '<hhh')
_offsets_gyroscope = Struct(_OFFSET_GYRO_REGISTER, '<hhh')
_radius_accelerometer = Struct(_RADIUS_ACCEL_REGISTER, '<h')
_radius_magnetometer = Struct(_RADIUS_MAGNET_REGISTER, '<h')

@property
def offsets_accelerometer(self):
last_mode = self.mode
self.mode = CONFIG_MODE
vector = self._offsets_accelerometer
self.mode = last_mode
return vector

@property
def offsets_magnetometer(self):
last_mode = self.mode
self.mode = CONFIG_MODE
vector = self._offsets_magnetometer
self.mode = last_mode
return vector

@property
def offsets_gyroscope(self):
last_mode = self.mode
self.mode = CONFIG_MODE
vector = self._offsets_gyroscope
self.mode = last_mode
return vector

@property
def radius_accelerometer(self):
last_mode = self.mode
self.mode = CONFIG_MODE
vector = self._radius_accelerometer
self.mode = last_mode
return vector[0]

@property
def radius_magnetometer(self):
last_mode = self.mode
self.mode = CONFIG_MODE
vector = self._radius_magnetometer
self.mode = last_mode
return vector[0]

@mode.setter
def mode(self, new_mode):
self._write_register(_MODE_REGISTER, new_mode)
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.