Zumo32U4 library
Classes | Public Member Functions | Public Attributes | List of all members
Zumo32U4IMU Class Reference

Interfaces with the inertial sensors on the Zumo 32U4. More...

#include <Zumo32U4IMU.h>

Classes

struct  vector
 Represents a 3-dimensional vector with x, y, and z components. More...
 

Public Member Functions

uint8_t getLastError ()
 Returns 0 if the last I2C communication with the IMU was successful, or a non-zero status code if there was an error. More...
 
bool init ()
 Initializes the inertial sensors and detects their type. More...
 
Zumo32U4IMUType getType ()
 Returns the type of the inertial sensors on the Zumo 32U4. More...
 
void enableDefault ()
 Enables all of the inertial sensors with a default configuration. More...
 
void configureForTurnSensing ()
 Configures the sensors with settings optimized for turn sensing. More...
 
void configureForBalancing ()
 Configures the sensors with settings optimized for balancing. More...
 
void configureForFaceUphill ()
 Configures the sensors with settings optimized for the FaceUphill example program. More...
 
void writeReg (uint8_t addr, uint8_t reg, uint8_t value)
 Writes an 8-bit sensor register. More...
 
uint8_t readReg (uint8_t addr, uint8_t reg)
 Reads an 8-bit sensor register. More...
 
void readAcc ()
 Takes a reading from the accelerometer and makes the measurements available in a. More...
 
void readGyro ()
 Takes a reading from the gyro and makes the measurements available in g. More...
 
void readMag ()
 Takes a reading from the magnetometer and makes the measurements available in m. More...
 
void read ()
 Takes a reading from all three sensors (accelerometer, gyro, and magnetometer) and makes their measurements available in the respective vectors. More...
 
bool accDataReady ()
 Indicates whether the accelerometer has new measurement data ready. More...
 
bool gyroDataReady ()
 Indicates whether the gyro has new measurement data ready. More...
 
bool magDataReady ()
 Indicates whether the magnetometer has new measurement data ready. More...
 

Public Attributes

vector< int16_t > a = {0, 0, 0}
 Raw accelerometer readings. More...
 
vector< int16_t > g = {0, 0, 0}
 Raw gyro readings. More...
 
vector< int16_t > m = {0, 0, 0}
 Raw magnetometer readings. More...
 

Detailed Description

Interfaces with the inertial sensors on the Zumo 32U4.

This class allows you to configure and get readings from the I2C sensors that make up the Zumo 32U4's inertial measurement unit (IMU): gyro, accelerometer, and magnetometer.

You must call Wire.start() before using any of this library's functions that access the sensors.

Definition at line 75 of file Zumo32U4IMU.h.

Member Function Documentation

◆ accDataReady()

bool Zumo32U4IMU::accDataReady ( )

Indicates whether the accelerometer has new measurement data ready.

Returns
True if there is new accelerometer data available; false otherwise.

Definition at line 307 of file Zumo32U4IMU.cpp.

◆ configureForBalancing()

void Zumo32U4IMU::configureForBalancing ( )

Configures the sensors with settings optimized for balancing.

Definition at line 125 of file Zumo32U4IMU.cpp.

◆ configureForFaceUphill()

void Zumo32U4IMU::configureForFaceUphill ( )

Configures the sensors with settings optimized for the FaceUphill example program.

Definition at line 197 of file Zumo32U4IMU.cpp.

◆ configureForTurnSensing()

void Zumo32U4IMU::configureForTurnSensing ( )

Configures the sensors with settings optimized for turn sensing.

Definition at line 168 of file Zumo32U4IMU.cpp.

◆ enableDefault()

void Zumo32U4IMU::enableDefault ( )

Enables all of the inertial sensors with a default configuration.

Definition at line 31 of file Zumo32U4IMU.cpp.

◆ getLastError()

uint8_t Zumo32U4IMU::getLastError ( )
inline

Returns 0 if the last I2C communication with the IMU was successful, or a non-zero status code if there was an error.

Definition at line 97 of file Zumo32U4IMU.h.

◆ getType()

Zumo32U4IMUType Zumo32U4IMU::getType ( )
inline

Returns the type of the inertial sensors on the Zumo 32U4.

Returns
The sensor type as a member of the Zumo32U4IMUType enum. If the type is not known (e.g. if init() has not been called yet), this will be Zumo32U4IMUType::Unknown.

Definition at line 110 of file Zumo32U4IMU.h.

◆ gyroDataReady()

bool Zumo32U4IMU::gyroDataReady ( )

Indicates whether the gyro has new measurement data ready.

Returns
True if there is new gyro data available; false otherwise.

Definition at line 320 of file Zumo32U4IMU.cpp.

◆ init()

bool Zumo32U4IMU::init ( )

Initializes the inertial sensors and detects their type.

Returns
True if the sensor type was detected succesfully; false otherwise.

Definition at line 11 of file Zumo32U4IMU.cpp.

◆ magDataReady()

bool Zumo32U4IMU::magDataReady ( )

Indicates whether the magnetometer has new measurement data ready.

Returns
True if there is new magnetometer data available; false otherwise.

Definition at line 333 of file Zumo32U4IMU.cpp.

◆ read()

void Zumo32U4IMU::read ( )

Takes a reading from all three sensors (accelerometer, gyro, and magnetometer) and makes their measurements available in the respective vectors.

Definition at line 298 of file Zumo32U4IMU.cpp.

◆ readAcc()

void Zumo32U4IMU::readAcc ( void  )

Takes a reading from the accelerometer and makes the measurements available in a.

Definition at line 246 of file Zumo32U4IMU.cpp.

◆ readGyro()

void Zumo32U4IMU::readGyro ( )

Takes a reading from the gyro and makes the measurements available in g.

Definition at line 263 of file Zumo32U4IMU.cpp.

◆ readMag()

void Zumo32U4IMU::readMag ( )

Takes a reading from the magnetometer and makes the measurements available in m.

Definition at line 280 of file Zumo32U4IMU.cpp.

◆ readReg()

uint8_t Zumo32U4IMU::readReg ( uint8_t  addr,
uint8_t  reg 
)

Reads an 8-bit sensor register.

Parameters
addrDevice address.
regRegister address.
Returns
8-bit register value read from the device.

Definition at line 229 of file Zumo32U4IMU.cpp.

◆ writeReg()

void Zumo32U4IMU::writeReg ( uint8_t  addr,
uint8_t  reg,
uint8_t  value 
)

Writes an 8-bit sensor register.

Parameters
addrDevice address.
regRegister address.
value8-bit register value to be written.

Definition at line 221 of file Zumo32U4IMU.cpp.

Member Data Documentation

◆ a

vector<int16_t> Zumo32U4IMU::a = {0, 0, 0}

Raw accelerometer readings.

Definition at line 87 of file Zumo32U4IMU.h.

◆ g

vector<int16_t> Zumo32U4IMU::g = {0, 0, 0}

Raw gyro readings.

Definition at line 90 of file Zumo32U4IMU.h.

◆ m

vector<int16_t> Zumo32U4IMU::m = {0, 0, 0}

Raw magnetometer readings.

Definition at line 93 of file Zumo32U4IMU.h.


The documentation for this class was generated from the following files: