MAG3110 Virgo robot adaptation

Fork of MAG3110 by JP PANG

Revision:
6:b2bb387caf3f
Parent:
5:9644c7d596a1
Child:
7:14570d7e3335
--- a/MAG3110.h	Thu Oct 10 02:22:13 2013 +0000
+++ b/MAG3110.h	Mon Aug 01 02:50:19 2016 +0000
@@ -7,10 +7,9 @@
 #define MAG3110_H
 
 #include "mbed.h"
+#include "generalFunctions.h"
 
-#define PI 3.14159265359
-
-//#define MAG_ADDR 0x0E
+#define MAG_ADDR (0x0E << 1)
 
 // define registers
 #define MAG_DR_STATUS 0x00
@@ -84,17 +83,8 @@
      * Main constructor
      * @param sda SDA pin
      * @param sdl SCL pin
-     * @param addr addr of the I2C peripheral
      */
-    MAG3110(PinName sda, PinName scl, int addr);
-    /**
-     * Debug version of constructor
-     * @param sda SDA pin
-     * @param sdl SCL pin
-     * @param addr Address of the I2C peripheral
-     * @param pc Serial object to output debug messages
-     */
-    MAG3110(PinName sda, PinName scl, int addr, Serial *pc); //pass serial for debug
+    MAG3110(PinName sda, PinName scl);
     /**
      * Setup the Magnetometer
      *
@@ -113,11 +103,6 @@
      */
     int readVal(char regAddr);
     /**
-     * Calculate the heading
-     * @return heading in degrees
-     */
-    float getHeading();
-    /**
      * Perform a read on the X, Y and Z values.
      * @param xVal Pointer to X value
      * @param yVal Pointer to Y value
@@ -130,15 +115,19 @@
      * @param maxX Maximum value for X range
      * @param minY Minimum value for Y range
      * @param maxY maximum value for Y range
+     * @param minZ Minimum value for Z range
+     * @param maxZ maximum value for Z range
      */
-    void setCalibration(int minX, int maxX, int minY, int maxY);
+    void setCalibration(float minX, float maxX, float minY, float maxY, float minZ, float maxZ);
+    /**
+     * Acquire data from all axes in floating and return in uT, floating point format.
+     * @param uT Pointer to 1x3 floating point array to store micro tesla values from X,Y,Z axes
+     */
+    void get_uT(float *uT);
 
 private:
     I2C _i2c;
-    int _i2c_address;
-    Serial *_pc;
-    bool _debug;
-    int _avgX, _avgY;
+    float _avgX, _avgY, _avgZ;
 
 };
 #endif