2019-10-21 08:06:37 +02:00
|
|
|
#include "data_source_bno055.h"
|
|
|
|
|
2019-10-21 15:30:28 +02:00
|
|
|
//bool loaded = false;
|
|
|
|
|
2019-10-21 08:57:58 +02:00
|
|
|
DataSourceBNO055::DataSourceBNO055(){
|
2019-11-18 15:07:46 +01:00
|
|
|
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;
|
2020-01-31 13:35:40 +01:00
|
|
|
lastTime = 0;
|
2019-10-21 08:06:37 +02:00
|
|
|
}
|
|
|
|
|
2019-10-21 08:57:58 +02:00
|
|
|
void DataSourceBNO055::readSensor(){
|
2020-01-31 13:35:40 +01:00
|
|
|
if(millis() - lastTime > DATA_CLOCK){
|
|
|
|
imu::Vector<3> euler = bno.getVector(Adafruit_BNO055::VECTOR_EULER);
|
|
|
|
this->value = (int) euler.x();
|
|
|
|
lastTime = millis();
|
|
|
|
}
|
2020-02-12 21:43:20 +01:00
|
|
|
CURRENT_INPUT_WRITE.IMUAngle = this->value;
|
|
|
|
CURRENT_DATA_WRITE.IMUAngle = this->value;
|
2019-11-11 22:26:34 +01:00
|
|
|
}
|