IMU LSM9DS1 Library (fixed)

Dependencies:   PinDetect

Fork of LSM9DS1_Library by Jason Mar

Committer:
cduck
Date:
Thu Aug 03 15:50:09 2017 -0700
Revision:
5:8da857db15e0
Parent:
main.cpp@0:e8167f37725c
Rename main.cpp so it isn't compiled as part of the library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jmar7 0:e8167f37725c 1 #include "LSM9DS1.h"
jmar7 0:e8167f37725c 2
jmar7 0:e8167f37725c 3 DigitalOut myled(LED1);
jmar7 0:e8167f37725c 4 Serial pc(USBTX, USBRX);
jmar7 0:e8167f37725c 5
jmar7 0:e8167f37725c 6 int main() {
jmar7 0:e8167f37725c 7 //LSM9DS1 lol(p9, p10, 0x6B, 0x1E);
jmar7 0:e8167f37725c 8 LSM9DS1 lol(p9, p10, 0xD6, 0x3C);
jmar7 0:e8167f37725c 9 lol.begin();
jmar7 0:e8167f37725c 10 if (!lol.begin()) {
jmar7 0:e8167f37725c 11 pc.printf("Failed to communicate with LSM9DS1.\n");
jmar7 0:e8167f37725c 12 }
jmar7 0:e8167f37725c 13 lol.calibrate();
jmar7 0:e8167f37725c 14 while(1) {
jmar7 0:e8167f37725c 15 lol.readTemp();
jmar7 0:e8167f37725c 16 lol.readMag();
jmar7 0:e8167f37725c 17 lol.readGyro();
jmar7 0:e8167f37725c 18
jmar7 0:e8167f37725c 19 //pc.printf("%d %d %d %d %d %d %d %d %d\n\r", lol.calcGyro(lol.gx), lol.calcGyro(lol.gy), lol.calcGyro(lol.gz), lol.ax, lol.ay, lol.az, lol.mx, lol.my, lol.mz);
jmar7 0:e8167f37725c 20 //pc.printf("%d %d %d\n\r", lol.calcGyro(lol.gx), lol.calcGyro(lol.gy), lol.calcGyro(lol.gz));
jmar7 0:e8167f37725c 21 pc.printf("gyro: %d %d %d\n\r", lol.gx, lol.gy, lol.gz);
jmar7 0:e8167f37725c 22 pc.printf("accel: %d %d %d\n\r", lol.ax, lol.ay, lol.az);
jmar7 0:e8167f37725c 23 pc.printf("mag: %d %d %d\n\n\r", lol.mx, lol.my, lol.mz);
jmar7 0:e8167f37725c 24 myled = 1;
jmar7 0:e8167f37725c 25 wait(2);
jmar7 0:e8167f37725c 26 myled = 0;
jmar7 0:e8167f37725c 27 wait(2);
jmar7 0:e8167f37725c 28 }
jmar7 0:e8167f37725c 29 }