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

hardware
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: public:
DataSourceBNO055(); DataSourceBNO055();
void readSensor(); void readSensor();
void postProcess();
public: public:
Adafruit_BNO055 bno; Adafruit_BNO055 bno;

View File

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

View File

@ -1,15 +1,18 @@
#include "data_source_bno055.h" #include "data_source_bno055.h"
//bool loaded = false;
DataSourceBNO055::DataSourceBNO055(){ DataSourceBNO055::DataSourceBNO055(){
bno = Adafruit_BNO055(); bno = Adafruit_BNO055();
bno.begin(bno.OPERATION_MODE_IMUPLUS); //Posizione impostata a P7 alle righe 105,107 di Adafruit_BNO55.cpp bno.begin(bno.OPERATION_MODE_IMUPLUS); //Posizione impostata a P7 alle righe 105,107 di Adafruit_BNO55.cpp
bno.setExtCrystalUse(true); bno.setExtCrystalUse(true);
//loaded = true;
value = 0;
} }
void DataSourceBNO055::readSensor(){ void DataSourceBNO055::readSensor(){
imu::Vector<3> euler = bno.getVector(Adafruit_BNO055::VECTOR_EULER); // if(loaded){
imu::Vector<3> euler = bno.getVector(Adafruit_BNO055::VECTOR_EULER);
if (euler.x() != value) { value = (int) euler.x();
value = euler.x(); // }
}
} }

View File

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