Library for the HMC5883L with 5 pins

Dependents:   projet_st_connect

Fork of QMC5883L by z jx

Revision:
5:d046009bc7c3
Parent:
4:2620ae5391a6
--- a/QMC5883L.h	Thu Oct 11 17:46:43 2018 +0000
+++ b/QMC5883L.h	Tue Nov 13 14:37:19 2018 +0000
@@ -29,6 +29,7 @@
 #include "mbed.h"
 #include "math.h"
 
+// #define DEBUG 1
 #define PI 3.14159265359 
 #define GAUSS_TO_MICROTESLA 100
 #define QMC5883L_ADDRESS 0x1A//0x18//
@@ -51,8 +52,27 @@
 /* Magnetometer Gain Settings */
 enum MagScale
 {
-    MagScale_2G =  0x00,      // +/- 2 Ga
-    MagScale_8G  = 0x10,     // +/- 8 Ga
+    MagScale_2G =  0x0,      // +/- 2 Ga
+    MagScale_8G  = 0x1,     // +/- 8 Ga
+};
+
+enum OSR{
+    osr512 = 0x0,
+    osr256 = 0x1,
+    osr128 = 0x2,
+    osr64 = 0x3
+};
+
+enum Mode{
+    mode_standby = 0x0,
+    mode_continuous = 0x1
+};
+
+enum ODR{
+    odr_1Ohz = 0x0,
+    odr_50hz = 0x1,
+    odr_100hz = 0x2,
+    odr_200hz = 0x3
 };
 
 class QMC5883L
@@ -60,6 +80,9 @@
     public:
         QMC5883L(PinName sda, PinName scl);
         void    init();
+        void changeState(OSR osr, MagScale rng, ODR odr, Mode mode);
+        void standby();
+        void reset();
         double  getHeading();
         void    readMagData(float* dest);  
         int16_t getMagXvalue();