Skip to content

Commit

Permalink
bmi160 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rtlopez committed Sep 21, 2023
1 parent 2f10631 commit 19ed007
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 38 deletions.
39 changes: 4 additions & 35 deletions lib/Espfc/src/Device/GyroBMI160.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,11 @@ class GyroBMI160: public GyroDevice
delay(1);

// Enable accel offset
_bus->writeBitsBMI160(_addr, BMI160_RA_OFFSET_6, BMI160_ACC_OFFSET_EN, BMI160_ACC_OFFSET_LEN, BMI160_RESULT_OK);
//_bus->writeBitsBMI160(_addr, BMI160_RA_OFFSET_6, BMI160_ACC_OFFSET_EN, BMI160_ACC_OFFSET_LEN, BMI160_RESULT_OK);
delay(1);

// Enable gyro offset
_bus->writeBitsBMI160(_addr, BMI160_RA_OFFSET_6, BMI160_GYR_OFFSET_EN, BMI160_GYR_OFFSET_LEN, BMI160_RESULT_OK);
//_bus->writeBitsBMI160(_addr, BMI160_RA_OFFSET_6, BMI160_GYR_OFFSET_EN, BMI160_GYR_OFFSET_LEN, BMI160_RESULT_OK);
delay(1);

// Enable data ready interrupt
Expand All @@ -175,7 +175,7 @@ class GyroBMI160: public GyroDevice
delay(1);

// Set Accel rate 1600HZ
_bus->writeByte(_addr, BMI160_RA_ACCEL_CONF, BMI160_ACCEL_RATE_1600HZ);
_bus->writeByte(_addr, BMI160_RA_ACCEL_CONF, BMI160_ACCEL_RATE_800HZ);
delay(1);

// Set Gyro rate 3200HZ
Expand Down Expand Up @@ -222,38 +222,7 @@ class GyroBMI160: public GyroDevice

int getRate() const override
{
uint8_t valRate = 0;
_bus->readBitsBMI160(_addr, BMI160_RA_GYRO_CONF, BMI160_GYRO_RATE_SEL_BIT, BMI160_GYRO_RATE_SEL_LEN, &valRate);

switch (valRate)
{
case BMI160_GYRO_RATE_3200HZ:
return 3200;
break;
case BMI160_GYRO_RATE_1600HZ:
return 1600;
break;
case BMI160_GYRO_RATE_800HZ:
return 800;
break;
case BMI160_GYRO_RATE_400HZ:
return 400;
break;
case BMI160_GYRO_RATE_200HZ:
return 200;
break;
case BMI160_GYRO_RATE_100HZ:
return 100;
break;
case BMI160_GYRO_RATE_50HZ:
return 50;
break;
case BMI160_GYRO_RATE_25HZ:
return 25;
break;
default:
return 99; //detect error
}
return 3200;
}

void setRate(int rate) override
Expand Down
3 changes: 0 additions & 3 deletions lib/Espfc/src/Sensor/BaseSensor.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
#ifndef _ESPFC_SENSOR_BASE_SENSOR_H_
#define _ESPFC_SENSOR_BASE_SENSOR_H_

#define ESPFC_FUZZY_ACCEL_ZERO 0.05
#define ESPFC_FUZZY_GYRO_ZERO 0.20

#include "Model.h"
#include "Hardware.h"

Expand Down

0 comments on commit 19ed007

Please sign in to comment.