diff --git a/adafruit_bno055.py b/adafruit_bno055.py index 97af7a8..a4e64de 100644 --- a/adafruit_bno055.py +++ b/adafruit_bno055.py @@ -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) @@ -85,6 +90,23 @@ class _ReadOnlyUnaryStruct(UnaryStruct): # pylint: disable=too-few-public-method def __set__(self, obj, value): raise NotImplementedError() +class _ModeStruct(Struct): # pylint: disable=too-few-public-methods + def __init__(self, register_address, struct_format, mode): + super().__init__(register_address, struct_format) + self.mode = mode + + def __get__(self, obj, objtype=None): + last_mode = obj.mode + obj.mode = self.mode + result = super().__get__(obj, objtype) + obj.mode = last_mode + return result + + def __set__(self, obj, value): + last_mode = obj.mode + obj.mode = self.mode + super().__set__(obj, value) + obj.mode = last_mode class BNO055: """ @@ -118,6 +140,18 @@ class BNO055: gravity = _ScaledReadOnlyStruct(0x2e, '