Implemented first Hangar-Service

Dependencies:   CalibrateMagneto QuaternionMath

Fork of SML2 by TobyRich GmbH

Revision:
11:d21275e60ebb
Parent:
4:e759b8c756da
Child:
12:1632d7391453
--- a/Magnetometer.h	Tue Feb 24 10:10:14 2015 +0000
+++ b/Magnetometer.h	Thu Mar 12 10:16:01 2015 +0000
@@ -2,10 +2,39 @@
 #define _H_MAGNETOMETER_H
 
 #include "I2CPeripheral.h"
+#include "Sensor.h"
 
-class Magnetometer : public I2CPeripheral {
+class Magnetometer : public I2CPeripheral, public Sensor {
 public:
     Magnetometer(I2C &i2c);
+    
+    virtual bool powerOn();
+    virtual void powerOff();
+    virtual void start();
+    virtual void stop();
+
+    virtual Vector3 read();
+    
+private:
+    // Calibration data
+    int8_t   dig_x1;
+    int8_t   dig_y1;
+    int8_t   dig_x2;
+    int8_t   dig_y2;
+    uint16_t dig_z1;
+    int16_t  dig_z2;
+    int16_t  dig_z3;
+    int16_t  dig_z4;
+    uint8_t  dig_xy1;
+    int8_t   dig_xy2;
+    uint16_t dig_xyz1;
+    
+    // Hard iron cancellation data
+    Vector3 sum;
+    Vector3 hardIron;
+    size_t numSamples;
+    
+    void readCalibrationData();
 };
 
 #endif//_H_MAGNETOMETER_H
\ No newline at end of file