CMPS03 Compass library with only PWM support. I2C support will be added shortly, while it will arrive, you may use MBED component library if you wish to use CMPS03 I2C interface
Dependents: TestBoussole FRC_2018 0hackton_08_06_18 lib_FRC_2019 ... more
CMPS03.cpp
- Committer:
- haarkon
- Date:
- 2018-05-31
- Revision:
- 3:3e9586433ce5
- Parent:
- 2:e09ad9c1f751
- Child:
- 5:7bfdf8ff9c5e
File content as of revision 3:3e9586433ce5:
#include "CMPS03.h" CMPS03::CMPS03(PinName pwm) : _boussole(pwm) { _boussole.rise(callback(this, &CMPS03::rise)); _boussole.fall(callback(this, &CMPS03::fall)); _boussole.enable_irq(); _tim.start(); } void CMPS03::rise(void) { _startTime = _tim.read_us(); } void CMPS03::fall(void) { _stopTime = _tim.read_us(); _pwmBearing = ((double)(_stopTime - _startTime - 1000)/100.0); } double CMPS03::getBearing(void) { return _pwmBearing; } CMPS03::operator double() { return _pwmBearing; }