MPL sensor

Fork of MPL3115A2 by clemente di caprio

Files at this revision

API Documentation at this revision

Comitter:
clemente
Date:
Sun Sep 22 07:04:14 2013 +0000
Parent:
7:59e9ba115d0a
Child:
9:75a5960adf5c
Commit message:
Added functions to set offset for temperature, altitude and pressure, as De Cremer Tim suggest.

Changed in this revision

MPL3115A2.cpp Show annotated file Show diff for this revision Revisions of this file
MPL3115A2.h Show annotated file Show diff for this revision Revisions of this file
--- a/MPL3115A2.cpp	Sun Aug 25 21:48:05 2013 +0000
+++ b/MPL3115A2.cpp	Sun Sep 22 07:04:14 2013 +0000
@@ -47,6 +47,8 @@
     MPL3115A2_usr2_fptr = NULL;
     MPL3115A2_Int1.fall( NULL);
     MPL3115A2_Int2.fall( NULL);
+    
+    Reset();
 }
 
 void MPL3115A2::Reset( void)
@@ -452,6 +454,36 @@
         return 0;        
 }
 
+void MPL3115A2::SetPressureOffset( char offset)
+{
+    unsigned char data [2] = {0x2b, offset};
+
+    Standby();
+    writeRegs(data,2);
+
+    Active(); 
+}
+
+void MPL3115A2::SetTemperatureOffset( char offset)
+{
+    unsigned char data [2] = {0x2c, offset};
+
+    Standby();
+    writeRegs(data,2);
+
+    Active(); 
+}
+
+void MPL3115A2::SetAltitudeOffset( char offset)
+{
+    unsigned char data [2] = {0x2d, offset};
+
+    Standby();
+    writeRegs(data,2);
+
+    Active(); 
+}
+
 void MPL3115A2::readRegs(int addr, uint8_t * data, int len) {
     char t[1] = {addr};
     m_i2c.write(m_addr, t, 1, true);
--- a/MPL3115A2.h	Sun Aug 25 21:48:05 2013 +0000
+++ b/MPL3115A2.h	Sun Sep 22 07:04:14 2013 +0000
@@ -193,6 +193,42 @@
     */    
     void Reset( void);
 
+    /**
+    * Configure the Pressure offset.
+    * Pressure user accessible offset trim value expressed as an 8-bit 2's complement number. 
+    * The user offset registers may be adjusted to enhance accuracy and optimize the system performance. 
+    * Range is from -512 to +508 Pa, 4 Pa per LSB.
+    * In RAW output mode no scaling or offsets will be applied in the digital domain
+    *
+    * @param    offset
+    * @return   none
+    */    
+    void SetPressureOffset( char offset);
+    
+    /**
+    * Configure the Temperature offset.
+    * Temperature user accessible offset trim value expressed as an 8-bit 2's complement number. 
+    * The user offset registers may be adjusted to enhance accuracy and optimize the system performance. 
+    * Range is from -8 to +7.9375°C 0.0625°C per LSB.
+    * In RAW output mode no scaling or offsets will be applied in the digital domain
+    *
+    * @param    offset
+    * @return   none
+    */    
+    void SetTemperatureOffset( char offset);
+    
+    /**
+    * Configure the Altitude offset.
+    * Altitude Data User Offset Register (OFF_H) is expressed as a 2’s complement number in meters. 
+    * The user offset register provides user adjustment to the vertical height of the Altitude output. 
+    * The range of values are from -128 to +127 meters.
+    * In RAW output mode no scaling or offsets will be applied in the digital domain
+    *
+    * @param    offset
+    * @return   none
+    */    
+    void SetAltitudeOffset( char offset);        
+
 private:
     I2C m_i2c;
     int m_addr;