HMC6352 Library

Files at this revision

API Documentation at this revision

Comitter:
richardparker
Date:
Sun Mar 28 20:23:44 2010 +0000
Parent:
0:78e66010e47b
Child:
2:dc4867624d5a
Commit message:

Changed in this revision

HMC6352.cpp Show annotated file Show diff for this revision Revisions of this file
HMC6352.h Show annotated file Show diff for this revision Revisions of this file
--- a/HMC6352.cpp	Thu Feb 11 12:18:33 2010 +0000
+++ b/HMC6352.cpp	Sun Mar 28 20:23:44 2010 +0000
@@ -201,17 +201,27 @@
 
 void HMC6352::calibrate(int delay)
 {
+    startCalibrate();
+        
+    // Now wait an optimal 20s in which two full turns should be 
+    // made of the compass to gather enough data, see page 7 of 
+    // the data sheet.
+    wait(delay);
+
+    endCalibrate();    
+}
+
+void HMC6352::startCalibrate()
+{
     // Send the enter calibrate command.
     _buffer[0] = HMC6352_START_CAL;
     _i2c.write(this->address(), _buffer, 1);
     // Enter takes 10us.
     wait_us(10);
-    
-    // Now wait an optimal 20s in which two full turns should be 
-    // made of the compass to gather enough data, see page 7 of 
-    // the data sheet.
-    wait(delay);
-    
+}
+
+void HMC6352::endCalibrate()
+{
     // Send the exit calibrate command.
     _buffer[0] = HMC6352_END_CAL;
     _i2c.write(this->address(), _buffer, 1);
--- a/HMC6352.h	Thu Feb 11 12:18:33 2010 +0000
+++ b/HMC6352.h	Sun Mar 28 20:23:44 2010 +0000
@@ -55,6 +55,8 @@
     void wakeUp();
     void goToSleep();
     
+    void startCalibrate();
+    void endCalibrate();
     void calibrate(int delay = 20);
     
     // Get the mode section of tyhe operation byte from RAM.
@@ -68,6 +70,8 @@
     HMC6352::Output getOutput();
     void setOutput(HMC6352::Output output);
 
+    inline float version() const { return 0.1; }
+
 private:
     // Clears the contents of the buffer to 0x0
     void _clearBuffer();