|
PebbleOS
|
3-axis magnetometer driver interface. More...
Data Structures | |
| struct | MagData |
| 3-axis magnetometer sample, in milligauss, in the watch frame. More... | |
Enumerations | |
| enum | MagReadStatus { MagReadSuccess = 0 , MagReadClobbered = -1 , MagReadCommunicationFail = -2 , MagReadMagOff = -3 , MagReadNoMag = -4 } |
| Result of mag_read_data(). More... | |
| enum | MagSampleRate { MagSampleRate20Hz , MagSampleRate5Hz } |
| Magnetometer sampling rate. More... | |
Functions | |
| void | mag_init (void) |
| Initialize the magnetometer. | |
| void | mag_use (void) |
| Take a reference on the magnetometer hardware. | |
| void | mag_start_sampling (void) |
| Take a reference on the magnetometer and start sampling at 5 Hz. | |
| void | mag_release (void) |
| Drop a reference on the magnetometer hardware. | |
| MagReadStatus | mag_read_data (MagData *data) |
| Read the latest sample. | |
| bool | mag_change_sample_rate (MagSampleRate rate) |
| Change the sampling rate. | |
3-axis magnetometer driver interface.
The hardware is reference counted: it is powered while at least one user holds it through mag_use() or mag_start_sampling(), and turned off when the last user calls mag_release().
| struct MagData |
| enum MagReadStatus |
Result of mag_read_data().
| enum MagSampleRate |
| bool mag_change_sample_rate | ( | MagSampleRate | rate | ) |
Change the sampling rate.
Does nothing and succeeds when no reference is held.
| rate | New sampling rate. |
| void mag_init | ( | void | ) |
Initialize the magnetometer.
Called once at startup, before any other function in this API.
| MagReadStatus mag_read_data | ( | MagData * | data | ) |
Read the latest sample.
The caller must hold a reference and the magnetometer must be sampling.
| [out] | data | Sample. |
data was filled. | void mag_release | ( | void | ) |
Drop a reference on the magnetometer hardware.
The hardware is turned off when the last reference is dropped.
| void mag_start_sampling | ( | void | ) |
Take a reference on the magnetometer and start sampling at 5 Hz.
Must be matched with a call to mag_release().
| void mag_use | ( | void | ) |
Take a reference on the magnetometer hardware.
Must be matched with a call to mag_release().