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

Revision:
8:c5dc1ce10722
Parent:
3:2834be4e10ef
Child:
9:87a7169b4d5c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/magnetometer.h	Thu Mar 26 21:13:44 2020 +0000
@@ -0,0 +1,65 @@
+#ifndef SKYSCRAPER_MBED_MAGNETOMETER_H_INCLUDED
+#define SKYSCRAPER_MBED_MAGNETOMETER_H_INCLUDED
+
+#include <quan/out/time.hpp>
+#include <quan/out/magnetic_flux_density.hpp>
+#include <quan/three_d/out/vect.hpp>
+
+QUAN_QUANTITY_LITERAL(magnetic_flux_density,gauss);
+QUAN_QUANTITY_LITERAL(magnetic_flux_density,milli_gauss);
+QUAN_QUANTITY_LITERAL(magnetic_flux_density,uT);
+
+bool mag_init();
+bool mag_start_measurement();
+bool mag_data_ready();
+bool mag_read(quan::three_d::vect<quan::magnetic_flux_density::uT> & v);
+
+#if 0
+//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();
+
+// could rename to start single_measurement?
+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);
+
+#endif
+#endif
+