First draft HMC5883 magnetometer sensor using physical quantities, outputting via serial port using std::cout on mbed os 5
Diff: main.cpp
- Revision:
- 9:87a7169b4d5c
- Parent:
- 8:c5dc1ce10722
- Child:
- 10:75c8ce89aeb7
--- a/main.cpp Thu Mar 26 21:13:44 2020 +0000 +++ b/main.cpp Thu Mar 26 21:35:19 2020 +0000 @@ -1,9 +1,7 @@ #include "mbed.h" #include "magnetometer.h" -#include <quan/max.hpp> -#include <quan/min.hpp> -#include <quan/time.hpp> + void mag_adjusted_values( quan::time::ms const & update_rate, @@ -15,8 +13,6 @@ namespace { - QUAN_QUANTITY_LITERAL(time,ms); - // terminal loop, printing message periodically void loop_forever(std::string const & str) { @@ -53,8 +49,9 @@ auto prev_led = Kernel::get_ms_count(); auto now = Kernel::get_ms_count(); - // TODO Thread for this + for (;;){ + mag_start_measurement(); do{ ThisThread::sleep_for(10U); @@ -62,7 +59,7 @@ quan::three_d::vect<quan::magnetic_flux_density::uT> v; if (mag_read(v)){ - callback(v); + callback(v); } if ( (now - prev_led) >= 500U){ prev_led = now;