Library for the HMC5883L with 5 pins

Dependents:   projet_st_connect

Fork of QMC5883L by z jx

Revision:
6:37d4c4e18227
Parent:
4:2620ae5391a6
Child:
7:4136b94b5cb9
--- a/QMC5883L.h	Thu Oct 11 17:46:43 2018 +0000
+++ b/QMC5883L.h	Tue Nov 06 16:40:11 2018 +0000
@@ -49,10 +49,24 @@
 #define CHIP_ID      0x0D
 
 /* Magnetometer Gain Settings */
-enum MagScale
+enum TypeMagScale
+{
+    MagScale_2G =  0,      // +/- 2 Ga
+    MagScale_8G  = 1,     // +/- 8 Ga
+};
+
+enum TypeState
 {
-    MagScale_2G =  0x00,      // +/- 2 Ga
-    MagScale_8G  = 0x10,     // +/- 8 Ga
+    Standby_MODE = 0,
+    Continuous_MODE = 1
+};
+
+enum TypeODR
+{
+    F10 = 0,
+    F50 = 1,
+    F100 = 2,
+    F200 = 3
 };
 
 class QMC5883L
@@ -67,8 +81,14 @@
         int16_t getMagZvalue();
         int16_t getMagTemp();
         void    ChipID();
+        void standby();
+        void soft_reset();
     private:
-        float setMagRange(MagScale Mscale);
+        TypeState state;
+        TypeODR odr;
+        TypeMagScale mag_scale;
+        float setMagRange(TypeMagScale Mscale);
+        void change_odr_state(TypeMagScale mmag_scale, TypeODR modr, TypeState mstate);
         uint8_t QMC5883L_ReadByte(uint8_t QMC5883L_reg);
         void QMC5883L_WriteByte(uint8_t QMC5883L_reg, uint8_t QMC5883L_data);
         I2C QMC5883L_i2c;