Adafruit_AHRS/examples/calibrated_orientation/LSM6DS_LIS3MDL.h
Limor "Ladyada" Fried e07ec313ef
full refactor (#7)
* moved files and added NXP fusion

* rename and make unique names

* renamed files and made a multi-filter tester

* USB and Mahony examples are now superceded by one calibrated_orientation example

* add lsm9ds0 fusion demo to calibrated_orientation and removed standalone version
also moving really old 10dof/9dof demos

* make one unified calibrator

* add CI

* add some deps

* add more deps

* more deps

* update naming

* more deps

* skip and dep

* manually add conversion const

* more fixfix

* change default to mahony

* fix skips

* clangclang

* moreclang
2020-02-02 13:26:56 -05:00

31 lines
879 B
C

#include <Adafruit_LIS3MDL.h>
Adafruit_LIS3MDL lis3mdl;
// Can change this to be LSM6DSOX or whatever ya like
#include <Adafruit_LSM6DS33.h>
Adafruit_LSM6DS33 lsm6ds;
bool init_sensors(void) {
if (!lsm6ds.begin_I2C() || !lis3mdl.begin_I2C()) {
return false;
}
accelerometer = lsm6ds.getAccelerometerSensor();
gyroscope = lsm6ds.getGyroSensor();
magnetometer = &lis3mdl;
return true;
}
void setup_sensors(void) {
// set lowest range
lsm6ds.setAccelRange(LSM6DS_ACCEL_RANGE_2_G);
lsm6ds.setGyroRange(LSM6DS_GYRO_RANGE_250_DPS);
lis3mdl.setRange(LIS3MDL_RANGE_4_GAUSS);
// set slightly above refresh rate
lsm6ds.setAccelDataRate(LSM6DS_RATE_104_HZ);
lsm6ds.setGyroDataRate(LSM6DS_RATE_104_HZ);
lis3mdl.setDataRate(LIS3MDL_DATARATE_1000_HZ);
lis3mdl.setPerformanceMode(LIS3MDL_MEDIUMMODE);
lis3mdl.setOperationMode(LIS3MDL_CONTINUOUSMODE);
}