![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
First draft HMC5883 magnetometer sensor using physical quantities, outputting via serial port using std::cout on mbed os 5
hmc5883.h@3:2834be4e10ef, 2020-03-24 (annotated)
- Committer:
- skyscraper
- Date:
- Tue Mar 24 22:43:44 2020 +0000
- Revision:
- 3:2834be4e10ef
- Parent:
- 2:9ffb2f18756b
- Child:
- 8:c5dc1ce10722
Moved calibrate function out to separate source file.; Added raw values function
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
skyscraper | 3:2834be4e10ef | 1 | #ifndef SKYSCRAPER_MBED_HMC5883_H_INCLUDED |
skyscraper | 3:2834be4e10ef | 2 | #define SKYSCRAPER_MBED_HMC5883_H_INCLUDED |
skyscraper | 2:9ffb2f18756b | 3 | |
skyscraper | 2:9ffb2f18756b | 4 | #include <quan/out/magnetic_flux_density.hpp> |
skyscraper | 2:9ffb2f18756b | 5 | #include <quan/three_d/out/vect.hpp> |
skyscraper | 2:9ffb2f18756b | 6 | |
skyscraper | 2:9ffb2f18756b | 7 | //true if the hmc5883 is detected |
skyscraper | 2:9ffb2f18756b | 8 | bool mag_detected(); |
skyscraper | 2:9ffb2f18756b | 9 | |
skyscraper | 2:9ffb2f18756b | 10 | // only 1,2,4,8 available |
skyscraper | 2:9ffb2f18756b | 11 | // else returns false and does nothing |
skyscraper | 2:9ffb2f18756b | 12 | bool mag_set_samples_average(int n_samples); |
skyscraper | 2:9ffb2f18756b | 13 | |
skyscraper | 2:9ffb2f18756b | 14 | // set data rate specified as a rational |
skyscraper | 2:9ffb2f18756b | 15 | //data rate 0.75 <3,4>, 1.5 <3,2>, 3 <3>,7.5 <15,2>, 15 <15>(Default) |
skyscraper | 2:9ffb2f18756b | 16 | // , 30 <30>, 75 <75> |
skyscraper | 2:9ffb2f18756b | 17 | //N.B. wont link if other values specified |
skyscraper | 2:9ffb2f18756b | 18 | template <int N, int D=1> |
skyscraper | 2:9ffb2f18756b | 19 | bool mag_set_data_rate(); |
skyscraper | 2:9ffb2f18756b | 20 | |
skyscraper | 2:9ffb2f18756b | 21 | // set +- range |
skyscraper | 2:9ffb2f18756b | 22 | // sets the nearest greater equal +-range to abs(range_in) |
skyscraper | 2:9ffb2f18756b | 23 | // N.B so wont necessarily set exact range input |
skyscraper | 2:9ffb2f18756b | 24 | // TODO: get_range |
skyscraper | 2:9ffb2f18756b | 25 | // returns false if range is too big |
skyscraper | 2:9ffb2f18756b | 26 | bool mag_set_range(quan::magnetic_flux_density::uT const & range_in); |
skyscraper | 2:9ffb2f18756b | 27 | |
skyscraper | 2:9ffb2f18756b | 28 | quan::magnetic_flux_density::uT mag_get_range(); |
skyscraper | 2:9ffb2f18756b | 29 | |
skyscraper | 2:9ffb2f18756b | 30 | // probably remove and decide how to do this behind the scenes |
skyscraper | 2:9ffb2f18756b | 31 | // in concert with mag_set_data_rate |
skyscraper | 2:9ffb2f18756b | 32 | bool mag_set_continuous_measurement_mode(); |
skyscraper | 3:2834be4e10ef | 33 | |
skyscraper | 3:2834be4e10ef | 34 | // could rename to start single_measurement? |
skyscraper | 2:9ffb2f18756b | 35 | bool mag_set_single_measurement_mode(); |
skyscraper | 2:9ffb2f18756b | 36 | |
skyscraper | 2:9ffb2f18756b | 37 | bool mag_do_single_measurement( |
skyscraper | 2:9ffb2f18756b | 38 | quan::three_d::vect<quan::magnetic_flux_density::uT>& result |
skyscraper | 2:9ffb2f18756b | 39 | ); |
skyscraper | 2:9ffb2f18756b | 40 | |
skyscraper | 2:9ffb2f18756b | 41 | // TODO prefer mag enable / disable() ? |
skyscraper | 2:9ffb2f18756b | 42 | bool mag_set_idle_mode(); |
skyscraper | 2:9ffb2f18756b | 43 | |
skyscraper | 2:9ffb2f18756b | 44 | // TODO callback? |
skyscraper | 2:9ffb2f18756b | 45 | bool mag_data_ready(); |
skyscraper | 2:9ffb2f18756b | 46 | |
skyscraper | 2:9ffb2f18756b | 47 | // TODO ignore this make private |
skyscraper | 2:9ffb2f18756b | 48 | bool mag_data_locked(); |
skyscraper | 2:9ffb2f18756b | 49 | |
skyscraper | 2:9ffb2f18756b | 50 | bool mag_read(quan::three_d::vect<quan::magnetic_flux_density::uT> & v); |
skyscraper | 3:2834be4e10ef | 51 | |
skyscraper | 3:2834be4e10ef | 52 | #endif |
skyscraper | 3:2834be4e10ef | 53 |