HMC5883L Digital Compass Library

Fork of HMC5883L by Baser Kandehir

Files at this revision

API Documentation at this revision

Comitter:
chasefarmer2808
Date:
Fri Apr 14 23:34:27 2017 +0000
Parent:
2:bbc9ad18fd3e
Commit message:
compass working;

Changed in this revision

HMC5883L.cpp Show annotated file Show diff for this revision Revisions of this file
HMC5883L.h Show annotated file Show diff for this revision Revisions of this file
--- a/HMC5883L.cpp	Wed Aug 05 13:16:12 2015 +0000
+++ b/HMC5883L.cpp	Fri Apr 14 23:34:27 2017 +0000
@@ -31,10 +31,15 @@
 #include "HMC5883L.h"
 
 /* NUCLEO F411RE board */
-static I2C i2c(D14, D15);         // setup i2c (SDA,SCL)  
+//static I2C i2c(D14, D15);         // setup i2c (SDA,SCL)  
+//static I2C i2c (p28, p27);
 
 static float Gauss_LSB_XY = 1100.0F; // Varies with gain
 static float Gauss_LSB_Z =  980.0F;  // Varies with gain
+
+HMC5883L::HMC5883L(PinName sda, PinName scl) : i2c(sda, scl) {
+ 
+}
  
 void HMC5883L::setMagGain(MagGain gain)
 {
--- a/HMC5883L.h	Wed Aug 05 13:16:12 2015 +0000
+++ b/HMC5883L.h	Fri Apr 14 23:34:27 2017 +0000
@@ -28,7 +28,6 @@
 
 #include "mbed.h"
 #include "math.h"
-#include "ledControl.h"
 
 #define PI 3.14159265359 
 #define GAUSS_TO_MICROTESLA 100
@@ -65,9 +64,11 @@
 class HMC5883L
 {
     public:
+        HMC5883L(PinName sda, PinName scl);
         void init();
         double getHeading();
-        void readMagData(float* dest);  
+        void readMagData(float* dest); 
+        I2C i2c; 
     private:
         void setMagGain(MagGain gain);
         void writeByte(uint8_t address, uint8_t regAddress, uint8_t data);