SPQR-Team-2019-REVAMPED/src/data_source_bno055.cpp

25 lines
643 B
C++
Raw Normal View History

2019-10-21 08:06:37 +02:00
#include "data_source_bno055.h"
//bool loaded = false;
2019-10-21 08:57:58 +02:00
DataSourceBNO055::DataSourceBNO055(){
protocol = P_I2C;
2019-11-18 14:37:55 +01:00
bno = Adafruit_BNO055();
bno.begin(bno.OPERATION_MODE_IMUPLUS); //Posizione impostata a P7 alle righe 105,107 di Adafruit_BNO55.cpp
bno.setExtCrystalUse(true);
//loaded = true;
value = 0;
lastTime = 0;
2019-10-21 08:06:37 +02:00
}
2019-10-21 08:57:58 +02:00
void DataSourceBNO055::readSensor(){
if(millis() - lastTime > DATA_CLOCK){
imu::Vector<3> euler = bno.getVector(Adafruit_BNO055::VECTOR_EULER);
this->value = (int) euler.x();
lastTime = millis();
}
CURRENT_INPUT_WRITE.IMUAngle = this->value;
CURRENT_DATA_WRITE.IMUAngle = this->value;
}