First draft HMC5883 magnetometer sensor using physical quantities, outputting via serial port using std::cout on mbed os 5

Revision:
2:9ffb2f18756b
Child:
3:2834be4e10ef
diff -r e11ab941748b -r 9ffb2f18756b hmc5883.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hmc5883.h	Tue Mar 24 15:21:34 2020 +0000
@@ -0,0 +1,46 @@
+
+#include <quan/out/magnetic_flux_density.hpp>
+#include <quan/three_d/out/vect.hpp>
+
+//true if the hmc5883 is detected
+bool mag_detected();
+
+// only 1,2,4,8 available 
+// else returns false and does nothing
+bool mag_set_samples_average(int n_samples);
+
+// set data rate specified as a rational
+//data rate 0.75 <3,4>, 1.5 <3,2>, 3 <3>,7.5 <15,2>, 15 <15>(Default) 
+// , 30 <30>, 75 <75>
+//N.B. wont link if other values specified
+template <int N, int D=1>
+bool mag_set_data_rate();
+
+// set +- range
+// sets the nearest greater equal +-range to abs(range_in)
+// N.B so wont necessarily set exact range input
+// TODO: get_range
+// returns false if range is too big
+bool mag_set_range(quan::magnetic_flux_density::uT const & range_in);
+
+quan::magnetic_flux_density::uT mag_get_range();
+
+// probably remove and decide how to do this behind the scenes
+// in concert with mag_set_data_rate
+bool mag_set_continuous_measurement_mode();
+bool mag_set_single_measurement_mode();
+
+bool mag_do_single_measurement(
+    quan::three_d::vect<quan::magnetic_flux_density::uT>& result
+    );
+
+// TODO prefer mag enable / disable() ?
+bool mag_set_idle_mode();
+
+// TODO callback?
+bool mag_data_ready();
+
+// TODO ignore this make private
+bool mag_data_locked();
+
+bool mag_read(quan::three_d::vect<quan::magnetic_flux_density::uT> & v);