Quick test of the Wi-Go Magnetometer

Dependencies:   TSI mbed MAG3110

Revision:
4:e7831feff821
Parent:
3:945e32be0448
Child:
6:dafb20e438bf
--- a/main.cpp	Sun May 19 20:35:55 2013 +0000
+++ b/main.cpp	Fri May 24 20:05:54 2013 +0000
@@ -29,7 +29,7 @@
 #include "MAG3110.h"
 
 
-#define PI 3.14159265359
+//#define PI 3.14159265359
 #define ON  0
 #define OFF 1
 
@@ -41,20 +41,9 @@
 // Slide sensor acts as a button
 TSISensor tsi;
 
-// I2C used to communicate with sensor
-I2C i2c(PTE0, PTE1);
-
 //MAG3100 mag(&i2c, &pc); //DEBUG verion
-MAG3110 mag(&i2c);
+MAG3110 mag(PTE0, PTE1);
 
-//int newX, tempXmin, tempXmax, newY, tempYmin, tempYmax;
-// Ideally these would be saved in eeprom/flash
-/*
-struct settings_t {
-    long maxX, minX, maxY, minY;
-}
-settings;
-*/
 
 
 void calXY() //magnetometer calibration: finding max and min of X, Y axis
@@ -113,8 +102,6 @@
     }
     greenLed = OFF;
     wait(1.0);
-
-
 }
 
 int main()
@@ -125,9 +112,6 @@
     greenLed = OFF;
     blueLed = OFF;
 
-    mag.begin();
-    
-
     // Get some values
     printf("DR_STATUS %X\n", mag.readReg( MAG_DR_STATUS ));
     printf("WHO_AM_I %X\n", mag.readReg( MAG_WHO_AM_I ));
@@ -153,7 +137,7 @@
         wait(0.5);
         int xVal = mag.readVal(MAG_OUT_X_MSB);
         int yVal = mag.readVal(MAG_OUT_Y_MSB);
-        float heading = mag.getHeading();       //(atan2((double)(yVal-avgY),(double)(xVal-avgX)))*180/PI;
+        float heading = mag.getHeading();
 
         // Do something with heading - display direction and turn on blue LED if heading approx north
         if (abs(heading) <= 22.5) {