New code working with imu reading, tests are not working currently

pull/1/head
EmaMaker 2019-10-21 15:30:28 +02:00
parent da20da5e0a
commit 66b82e5ee0
4 changed files with 22 additions and 8 deletions

View File

@ -7,7 +7,6 @@ class DataSourceBNO055 : public DataSource{
public:
DataSourceBNO055();
void readSensor();
void postProcess();
public:
Adafruit_BNO055 bno;

View File

@ -35,6 +35,10 @@ void DataSource::update(){
postProcess();
}
void DataSource::postProcess(){
}
void DataSource::readSensor(){
if(protocol == 1) value = i2c->read();
else if(protocol == 2) while(ser->available() > 0) value = ser->read();
@ -44,5 +48,5 @@ void DataSource::readSensor(){
void DataSource::test(){
update();
DEBUG_PRINT.println(value);
DEBUG_PRINT.println(getValue());
}

View File

@ -1,15 +1,18 @@
#include "data_source_bno055.h"
//bool loaded = false;
DataSourceBNO055::DataSourceBNO055(){
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;
}
void DataSourceBNO055::readSensor(){
imu::Vector<3> euler = bno.getVector(Adafruit_BNO055::VECTOR_EULER);
if (euler.x() != value) {
value = euler.x();
}
// if(loaded){
imu::Vector<3> euler = bno.getVector(Adafruit_BNO055::VECTOR_EULER);
value = (int) euler.x();
// }
}

View File

@ -1,12 +1,20 @@
#include <Arduino.h>
#include "vars.h"
#include "data_source_bno055.h"
// #include <imu_class/imu.cpp>
//cyao c:
DataSourceBNO055* compass;
void setup() {
DEBUG_PRINT.begin(9600);
compass = new DataSourceBNO055();
}
void loop() {
compass->readSensor();
DEBUG_PRINT.println(compass->getValue());
//DEBUG_PRINT.println("Ciaooo");
delay(100);
}