pub struct Bno055<I> {
pub mode: BNO055OperationMode,
/* private fields */
}
Fields§
§mode: BNO055OperationMode
Implementations§
source§impl<I, E> Bno055<I>where
I: I2c<SevenBitAddress, Error = E>,
impl<I, E> Bno055<I>where
I: I2c<SevenBitAddress, Error = E>,
sourcepub fn new(i2c: I) -> Self
pub fn new(i2c: I) -> Self
Side-effect-free constructor.
Nothing will be read or written before init()
call.
sourcepub fn with_alternative_address(self) -> Self
pub fn with_alternative_address(self) -> Self
Enables use of alternative I2C address regs::BNO055_ALTERNATE_ADDR
.
sourcepub fn init(&mut self, delay: &mut dyn DelayNs) -> Result<(), Error<E>>
pub fn init(&mut self, delay: &mut dyn DelayNs) -> Result<(), Error<E>>
Initializes the BNO055 device.
Side-effects:
- Software reset of BNO055
- Sets BNO055 to
CONFIG
mode - Sets BNO055’s power mode to
NORMAL
- Clears
SYS_TRIGGER
register
§Usage Example
// use your_chip_hal::{I2c, Delay}; // <- import your chip's I2c and Delay
use bno055::Bno055;
let mut delay = Delay::new(/* ... */);
let mut i2c = I2c::new(/* ... */);
let mut bno055 = Bno055::new(i2c);
bno055.init(&mut delay)?;
sourcepub fn soft_reset(&mut self, delay: &mut dyn DelayNs) -> Result<(), Error<E>>
pub fn soft_reset(&mut self, delay: &mut dyn DelayNs) -> Result<(), Error<E>>
Resets the BNO055, initializing the register map to default values. More in section 3.2.
sourcepub fn set_mode(
&mut self,
mode: BNO055OperationMode,
delay: &mut dyn DelayNs
) -> Result<(), Error<E>>
pub fn set_mode( &mut self, mode: BNO055OperationMode, delay: &mut dyn DelayNs ) -> Result<(), Error<E>>
Sets the operating mode, see BNO055OperationMode. See section 3.3.
sourcepub fn set_power_mode(&mut self, mode: BNO055PowerMode) -> Result<(), Error<E>>
pub fn set_power_mode(&mut self, mode: BNO055PowerMode) -> Result<(), Error<E>>
Sets the power mode, see BNO055PowerMode See section 3.2
sourcepub fn power_mode(&mut self) -> Result<BNO055PowerMode, Error<E>>
pub fn power_mode(&mut self) -> Result<BNO055PowerMode, Error<E>>
Returns BNO055’s power mode.
sourcepub fn set_external_crystal(
&mut self,
ext: bool,
delay: &mut dyn DelayNs
) -> Result<(), Error<E>>
pub fn set_external_crystal( &mut self, ext: bool, delay: &mut dyn DelayNs ) -> Result<(), Error<E>>
Enables/Disables usage of external 32k crystal.
sourcepub fn set_axis_remap(&mut self, remap: AxisRemap) -> Result<(), Error<E>>
pub fn set_axis_remap(&mut self, remap: AxisRemap) -> Result<(), Error<E>>
Configures axis remap of the device.
sourcepub fn axis_remap(&mut self) -> Result<AxisRemap, Error<E>>
pub fn axis_remap(&mut self) -> Result<AxisRemap, Error<E>>
Returns axis remap of the device.
sourcepub fn set_axis_sign(&mut self, sign: BNO055AxisSign) -> Result<(), Error<E>>
pub fn set_axis_sign(&mut self, sign: BNO055AxisSign) -> Result<(), Error<E>>
Configures device’s axes sign: positive or negative.
sourcepub fn axis_sign(&mut self) -> Result<BNO055AxisSign, Error<E>>
pub fn axis_sign(&mut self) -> Result<BNO055AxisSign, Error<E>>
Return device’s axes sign.
sourcepub fn get_revision(&mut self) -> Result<BNO055Revision, Error<E>>
pub fn get_revision(&mut self) -> Result<BNO055Revision, Error<E>>
Gets the revision of software, bootloader, accelerometer, magnetometer, and gyroscope of the BNO055 device.
sourcepub fn get_system_status(
&mut self,
do_selftest: bool,
delay: &mut dyn DelayNs
) -> Result<BNO055SystemStatus, Error<E>>
pub fn get_system_status( &mut self, do_selftest: bool, delay: &mut dyn DelayNs ) -> Result<BNO055SystemStatus, Error<E>>
Returns device’s system status.
sourcepub fn quaternion(&mut self) -> Result<Quaternion<f32>, Error<E>>
pub fn quaternion(&mut self) -> Result<Quaternion<f32>, Error<E>>
Gets a quaternion (mint::Quaternion<f32>
) reading from the BNO055.
Available only in sensor fusion modes.
sourcepub fn euler_angles(&mut self) -> Result<EulerAngles<f32, ()>, Error<E>>
pub fn euler_angles(&mut self) -> Result<EulerAngles<f32, ()>, Error<E>>
Get Euler angles representation of heading in degrees.
Euler angles is represented as (roll
, pitch
, yaw/heading
).
Available only in sensor fusion modes.
sourcepub fn get_calibration_status(
&mut self
) -> Result<BNO055CalibrationStatus, Error<E>>
pub fn get_calibration_status( &mut self ) -> Result<BNO055CalibrationStatus, Error<E>>
Get calibration status
sourcepub fn is_fully_calibrated(&mut self) -> Result<bool, Error<E>>
pub fn is_fully_calibrated(&mut self) -> Result<bool, Error<E>>
Checks whether device is fully calibrated or not.
sourcepub fn calibration_profile(
&mut self,
delay: &mut dyn DelayNs
) -> Result<BNO055Calibration, Error<E>>
pub fn calibration_profile( &mut self, delay: &mut dyn DelayNs ) -> Result<BNO055Calibration, Error<E>>
Reads current calibration profile of the device.
sourcepub fn set_calibration_profile(
&mut self,
calib: BNO055Calibration,
delay: &mut dyn DelayNs
) -> Result<(), Error<E>>
pub fn set_calibration_profile( &mut self, calib: BNO055Calibration, delay: &mut dyn DelayNs ) -> Result<(), Error<E>>
Sets current calibration profile.
sourcepub fn id(&mut self) -> Result<u8, Error<E>>
pub fn id(&mut self) -> Result<u8, Error<E>>
Returns device’s factory-programmed and constant chip ID. This ID is device model ID and not a BNO055’s unique ID, whic is stored in different register.
sourcepub fn get_mode(&mut self) -> Result<BNO055OperationMode, Error<E>>
pub fn get_mode(&mut self) -> Result<BNO055OperationMode, Error<E>>
Returns device’s operation mode.
sourcepub fn is_in_fusion_mode(&mut self) -> Result<bool, Error<E>>
pub fn is_in_fusion_mode(&mut self) -> Result<bool, Error<E>>
Checks whether the device is in Sensor Fusion mode or not.
pub fn get_acc_config(&mut self) -> Result<AccConfig, Error<E>>
pub fn set_acc_config(&mut self, acc_config: &AccConfig) -> Result<(), Error<E>>
sourcepub fn linear_acceleration_fixed(&mut self) -> Result<Vector3<i16>, Error<E>>
pub fn linear_acceleration_fixed(&mut self) -> Result<Vector3<i16>, Error<E>>
Returns linear acceleration vector in cm/s^2 units. Available only in sensor fusion modes.
sourcepub fn linear_acceleration(&mut self) -> Result<Vector3<f32>, Error<E>>
pub fn linear_acceleration(&mut self) -> Result<Vector3<f32>, Error<E>>
Returns linear acceleration vector in m/s^2 units. Available only in sensor fusion modes.
sourcepub fn gravity_fixed(&mut self) -> Result<Vector3<i16>, Error<E>>
pub fn gravity_fixed(&mut self) -> Result<Vector3<i16>, Error<E>>
Returns gravity vector in cm/s^2 units. Available only in sensor fusion modes.
sourcepub fn gravity(&mut self) -> Result<Vector3<f32>, Error<E>>
pub fn gravity(&mut self) -> Result<Vector3<f32>, Error<E>>
Returns gravity vector in m/s^2 units. Available only in sensor fusion modes.
sourcepub fn accel_data_fixed(&mut self) -> Result<Vector3<i16>, Error<E>>
pub fn accel_data_fixed(&mut self) -> Result<Vector3<i16>, Error<E>>
Returns current accelerometer data in cm/s^2 units. Available only in modes in which accelerometer is enabled.
sourcepub fn accel_data(&mut self) -> Result<Vector3<f32>, Error<E>>
pub fn accel_data(&mut self) -> Result<Vector3<f32>, Error<E>>
Returns current accelerometer data in m/s^2 units. Available only in modes in which accelerometer is enabled.
sourcepub fn gyro_data_fixed(&mut self) -> Result<Vector3<i16>, Error<E>>
pub fn gyro_data_fixed(&mut self) -> Result<Vector3<i16>, Error<E>>
Returns current gyroscope data in 1/16th deg/s units. Available only in modes in which gyroscope is enabled.
sourcepub fn gyro_data(&mut self) -> Result<Vector3<f32>, Error<E>>
pub fn gyro_data(&mut self) -> Result<Vector3<f32>, Error<E>>
Returns current gyroscope data in deg/s units. Available only in modes in which gyroscope is enabled.
sourcepub fn mag_data_fixed(&mut self) -> Result<Vector3<i16>, Error<E>>
pub fn mag_data_fixed(&mut self) -> Result<Vector3<i16>, Error<E>>
Returns current magnetometer data in 1/16th uT units. Available only in modes in which magnetometer is enabled.
sourcepub fn mag_data(&mut self) -> Result<Vector3<f32>, Error<E>>
pub fn mag_data(&mut self) -> Result<Vector3<f32>, Error<E>>
Returns current magnetometer data in uT units. Available only in modes in which magnetometer is enabled.
sourcepub fn temperature(&mut self) -> Result<i8, Error<E>>
pub fn temperature(&mut self) -> Result<i8, Error<E>>
Returns current temperature of the chip (in degrees Celsius).