BMA180 library with multiple configurable ranges. Based on the Sensor_test by Bo Carøe.

Dependents:   Sensor_test_2_0 KalmanFilter

Fork of BMA180 by Bo Carøe

BMA180.h

Committer:
cdonate
Date:
2012-08-15
Revision:
2:c7eb9f15e026
Parent:
1:cd2316c8a187

File content as of revision 2:c7eb9f15e026:

#pragma once

//I2C address, either 0x40 or 0x41, depending on pin VDDIO
#define BMA180_ADRESS 0x40

//Convert acceleration to meters per second squared
//This value depends on the Range you are using, i.e. +-1g, +-3g, etc.
//fConvMPSS= (acc of gravitation) / Sensitivity

const float fConvMPSS= 1.7919037e-3;

class BMA180
{
private:
    I2C & I2CBus;
    Timer & GlobalTime;
    
    //Offset
    float Offset[3];
    
public:
    //Acceleration on all three axes
    short RawAcc[3];        //Raw Data
    float Acc[3];           //Calibrated raw data in m/s^2
    
    
    //Initialization
    BMA180(I2C & I2CBus_, Timer & GlobalTime_);
    void Init();

public:    
    //Read raw Data
    void ReadRawData();
    
public:
    //Update Method
    //Get current information from the sensor
    //Calculate the offset
    //Converts other units
    void Update();
    
    //Calibration
    //pRaw1g: short array [3] provides the best raw data for approximately 1g = {0, 0, -2870}
    void Calibrate(int ms, const short * pRaw1g);
    
    void userCalibration(short * Raw1g);
};