upm  0.4.1
Sensor/Actuator repository for libmraa (v0.8.0)
Public Member Functions | List of all members

API for MPU9150 chip (Accelerometer, Gyro and Magnometer Sensor) More...

Detailed Description

This module defines the MPU9150 interface for libmpu9150

mpu9150.jpg
sensor.init();
while (true) {
sensor.update();
float[] accel = sensor.getAccelerometer();
System.out.println("Accelerometer: " + "AX: " + accel[0] + " AY: " + accel[1] + " AZ: "
+ accel[2]);
float[] gyro = sensor.getGyroscope();
System.out.println("Gryoscope: " + "GX: " + gyro[0] + " GY: " + gyro[1] + " GZ: "
+ gyro[2]);
float[] magn = sensor.getMagnetometer();
System.out.println("Magnetometer: " + "MX: " + magn[0] + " MY: " + magn[1] + " MZ: "
+ magn[2]);
Thread.sleep(1000);
}

Public Member Functions

synchronized void delete ()
 
 MPU9150 (int bus, int address, int magAddress, boolean enableAk8975)
 
 MPU9150 (int bus, int address, int magAddress)
 
 MPU9150 (int bus, int address)
 
 MPU9150 (int bus)
 
boolean init ()
 
void update ()
 
float[] getMagnetometer ()
 
- Public Member Functions inherited from MPU60X0
synchronized void delete ()
 
 MPU60X0 (int bus, short address)
 
 MPU60X0 (int bus)
 
boolean init ()
 
void update ()
 
short readReg (short reg)
 
void readRegs (short reg, byte[] buffer)
 
boolean writeReg (short reg, short val)
 
boolean setSleep (boolean enable)
 
boolean setClockSource (MPU60X0.CLKSEL_T clk)
 
boolean setGyroscopeScale (MPU60X0.FS_SEL_T scale)
 
boolean setAccelerometerScale (MPU60X0.AFS_SEL_T scale)
 
boolean setDigitalLowPassFilter (MPU60X0.DLPF_CFG_T dlp)
 
boolean setSampleRateDivider (short div)
 
short getSampleRateDivider ()
 
float[] getAccelerometer ()
 
float[] getGyroscope ()
 
float getTemperature ()
 
boolean enableTemperatureSensor (boolean enable)
 
boolean setExternalSync (MPU60X0.EXT_SYNC_SET_T val)
 
boolean enableI2CBypass (boolean enable)
 
boolean setMotionDetectionThreshold (short thr)
 
short getInterruptStatus ()
 
boolean setInterruptEnables (short enables)
 
short getInterruptEnables ()
 
boolean setInterruptPinConfig (short cfg)
 
short getInterruptPinConfig ()
 
void installISR (int gpio, int level, IsrCallback cb)
 
void uninstallISR ()
 

Constructor & Destructor Documentation

MPU9150 ( int  bus,
int  address,
int  magAddress,
boolean  enableAk8975 
)

MPU9150 constructor

Parameters
busI2C bus to use
addressThe address for this device
magAddressThe address of the connected magnetometer
enableAk8975Enables i2c bypass mode for magnetometer, default is true

Member Function Documentation

float [] getMagnetometer ( )

Return the compensated values for the x, y, and z axes. The unit of measurement is in micro-teslas (uT).

Returns
Array containing X, Y, Z magnetometer values
boolean init ( )

Set up initial values and start operation

Returns
true if successful
void update ( )

Take a measurement and store the current sensor values internally. Note, these user facing registers are only updated from the internal device sensor values when the i2c serial traffic is 'idle'. So, if you are reading the values too fast, the bus may never be idle, and you will just end up reading the same values over and over.

Unfortunately, it is is not clear how long 'idle' actually means, so if you see this behavior, reduce the rate at which you are calling update().

Inheritance diagram for MPU9150:
Inheritance graph
[legend]
Collaboration diagram for MPU9150:
Collaboration graph
[legend]

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