52 writeReg(0x09, CONT | Hz200 | G8 | S512);
70 void writeReg(uint8_t reg, uint8_t val) {
85 this->Axes.x = rq.
data.buf[0] | (rq.
data.buf[1] << 8);
86 this->Axes.y = rq.
data.buf[2] | (rq.
data.buf[3] << 8);
87 this->Axes.z = rq.
data.buf[4] | (rq.
data.buf[5] << 8);
88 this->Temperature = ((double) (rq.
data.buf[7] | (rq.
data.buf[8] << 8)));
90 this->heading = atan2(this->Axes.y, this->Axes.x);
92 this->heading += this->declinationAngle;
94 this->heading += 2 * M_PI;
95 if(this->heading > 2 * M_PI)
96 this->heading -= 2 * M_PI;
99 double getHeadingDegree() {
100 return heading * 180 / M_PI;
104 double Temperature = 0;
110 double declinationAngle = 0.0303;
size_t size
total capacity of buffer
Definition buffer.h:23
generic I2C device wrapper.
Definition i2c.h:21
Device(Sink< Request > &bus, uint8_t address)
construct device on bus with given address
Definition i2c.h:26
struct defining an I2C request.
Definition i2c.h:37
Buffer< uint8_t > data
transfer data
Definition i2c.h:39
Implementation of the QMC5883L multi-chip three-axis magnetic sensor.
Definition QMC5883L.h:18
QMC5883L(Sink< I2C::Request > &bus, enum ADDR addr=DEFAULT)
initialize the sensor
Definition QMC5883L.h:47
void callback(const I2C::Request &rq) override
callback.
Definition QMC5883L.h:81
void measure()
start async read of angle
Definition QMC5883L.h:58
generic object sink, i.e.
Definition streams.h:15
virtual void push(const T &t)
copy semantics does not check for space. guard by using 'if (!full) { ... }'
Definition streams.h:20