summaryrefslogtreecommitdiff
path: root/Venus_Skeleton/libs/HMC5883L/HMC5883L.h
diff options
context:
space:
mode:
Diffstat (limited to 'Venus_Skeleton/libs/HMC5883L/HMC5883L.h')
-rw-r--r--Venus_Skeleton/libs/HMC5883L/HMC5883L.h75
1 files changed, 75 insertions, 0 deletions
diff --git a/Venus_Skeleton/libs/HMC5883L/HMC5883L.h b/Venus_Skeleton/libs/HMC5883L/HMC5883L.h
new file mode 100644
index 0000000..64ac68c
--- /dev/null
+++ b/Venus_Skeleton/libs/HMC5883L/HMC5883L.h
@@ -0,0 +1,75 @@
+/*
+HMC5883L.h - Header file for the HMC5883L Triple Axis Magnetometer Arduino Library.
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the version 3 GNU General Public License as
+published by the Free Software Foundation.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ WARNING: THE HMC5883L IS NOT IDENTICAL TO THE HMC5883!
+ Datasheet for HMC5883L:
+ http://www51.honeywell.com/aero/common/documents/myaerospacecatalog-documents/Defense_Brochures-documents/HMC5883L_3-Axis_Digital_Compass_IC.pdf
+
+*/
+
+#ifndef HMC5883L_h
+#define HMC5883L_h
+
+#include <inttypes.h>
+#include "../Wire/Wire.h"
+
+#define HMC5883L_Address 0x1E
+#define ConfigurationRegisterA 0x00
+#define ConfigurationRegisterB 0x01
+#define ModeRegister 0x02
+#define DataRegisterBegin 0x03
+
+#define Measurement_Continuous 0x00
+#define Measurement_SingleShot 0x01
+#define Measurement_Idle 0x03
+
+#define ErrorCode_1 "Entered scale was not valid, valid gauss values are: 0.88, 1.3, 1.9, 2.5, 4.0, 4.7, 5.6, 8.1"
+#define ErrorCode_1_Num 1
+
+struct MagnetometerScaled
+{
+ float XAxis;
+ float YAxis;
+ float ZAxis;
+};
+
+struct MagnetometerRaw
+{
+ int XAxis;
+ int YAxis;
+ int ZAxis;
+};
+
+class HMC5883L
+{
+ public:
+ HMC5883L();
+
+ MagnetometerRaw ReadRawAxis();
+ MagnetometerScaled ReadScaledAxis();
+
+ int SetMeasurementMode(uint8_t mode);
+ int SetScale(float gauss);
+
+ char* GetErrorText(int errorCode);
+
+ protected:
+ void Write(int address, int byte);
+ uint8_t* Read(int address, int length);
+
+ private:
+ float m_Scale;
+};
+#endif \ No newline at end of file