Treehopper C# API
Mpu6050 Class Reference

InvenSense MPU6050 6-DoF IMU More...

Inheritance diagram for Mpu6050:
IAccelerometer IGyroscope IPollable IPollable Mpu9250

Classes

class  Mpu6050Registers
 

Public Types

enum  ExtSyncSets {
  Disabled = 0, TempOutL = 1, GyroXoutL = 2, GyroYoutL = 3,
  GyroZoutL = 4, AccelXoutL = 5, AccelYoutL = 6, AccelZoutL = 7
}
 
enum  GyroScales { Dps_250 = 0, Dps_500 = 1, Dps_1000 = 2, Dps_2000 = 3 }
 
enum  AccelScales { Fs_2g = 0, Fs_4g = 1, Fs_8g = 2, Fs_16g = 3 }
 
enum  ClockSels { InternalOscillator = 0, AutoSelect = 1, Reset = 7 }
 

Public Member Functions

 Mpu6050 (I2C i2c, bool addressPin=false, int ratekHz=400)
 Construct an MPU9150 9-Dof IMU More...
 
override async Task UpdateAsync ()
 Requests a reading from the sensor and updates its data properties with the gathered values. More...
 
virtual async Task Calibrate ()
 Calibrate IMU relative to gravity More...
 

Static Public Member Functions

static async Task< IList< Mpu6050 > > ProbeAsync (I2C i2c, bool includeMpu9250=false, int rate=100)
 Discover any MPU6050 IMUs (or optionally MPU9250s) attached to the specified bus. More...
 

Protected Attributes

Mpu6050Registers _registers
 

Properties

AccelScales AccelerometerScale [get, set]
 Gets or sets the accelerometer scale More...
 
GyroScales GyroscopeScale [get, set]
 Gets or sets the gyroscope scale More...
 
Vector3 Accelerometer [get]
 Gets the accelerometer data More...
 
Vector3 Gyroscope [get]
 Gets the gyroscope data More...
 
bool AutoUpdateWhenPropertyRead [get, set]
 Gets or sets whether reading from the sensor's properties should request updates from the sensor automatically (defaults to true). More...
 

Detailed Description

InvenSense MPU6050 6-DoF IMU

Member Enumeration Documentation

◆ ExtSyncSets

enum ExtSyncSets
strong
Enumerator
Disabled 
TempOutL 
GyroXoutL 
GyroYoutL 
GyroZoutL 
AccelXoutL 
AccelYoutL 
AccelZoutL 

◆ GyroScales

enum GyroScales
strong
Enumerator
Dps_250 
Dps_500 
Dps_1000 
Dps_2000 

◆ AccelScales

enum AccelScales
strong
Enumerator
Fs_2g 
Fs_4g 
Fs_8g 
Fs_16g 

◆ ClockSels

enum ClockSels
strong
Enumerator
InternalOscillator 
AutoSelect 
Reset 

Constructor & Destructor Documentation

◆ Mpu6050()

Mpu6050 ( I2C  i2c,
bool  addressPin = false,
int  ratekHz = 400 
)

Construct an MPU9150 9-Dof IMU

Parameters
i2cThe I2c module this module is connected to.
addressPinThe address of the module
ratekHzThe rate, in kHz, to use with this IC

Member Function Documentation

◆ ProbeAsync()

static async Task<IList<Mpu6050> > ProbeAsync ( I2C  i2c,
bool  includeMpu9250 = false,
int  rate = 100 
)
static

Discover any MPU6050 IMUs (or optionally MPU9250s) attached to the specified bus.

Parameters
i2cThe bus to probe.
includeMpu9250Whether to include MPU-9250 IMUs.
rateThe rate, in kHz, to use.
Returns
An awaitable task that completes with a list of of discovered sensors

◆ UpdateAsync()

override async Task UpdateAsync ( )

Requests a reading from the sensor and updates its data properties with the gathered values.

Returns
An awaitable Task

Note that when AutoUpdateWhenPropertyRead is true (which it is, by default), this method is implicitly called when any sensor data property is read from — there's no need to call this method unless you set AutoUpdateWhenPropertyRead to false.

Unless otherwise noted, this method updates all sensor data simultaneously, which can often lead to more efficient bus usage (as well as reducing USB chattiness).

Implements IPollable.

◆ Calibrate()

virtual async Task Calibrate ( )
virtual

Calibrate IMU relative to gravity

Returns

Member Data Documentation

◆ _registers

Mpu6050Registers _registers
protected

Property Documentation

◆ AccelerometerScale

AccelScales AccelerometerScale
getset

Gets or sets the accelerometer scale

◆ GyroscopeScale

GyroScales GyroscopeScale
getset

Gets or sets the gyroscope scale

◆ Accelerometer

Vector3 Accelerometer
get

Gets the accelerometer data

◆ Gyroscope

Vector3 Gyroscope
get

Gets the gyroscope data

◆ AutoUpdateWhenPropertyRead

bool AutoUpdateWhenPropertyRead
getsetinherited

Gets or sets whether reading from the sensor's properties should request updates from the sensor automatically (defaults to true).

By default, whenever you access one of the properties of this sensor, a new reading will be fetched. If this property is set to false, you must manually call the UpdateAsync() method to retrieve a new sensor reading.

This functionality enables more efficient sensor updates, since it allows you to intelligently control when data is gathered.


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