Jacob Callahan
/
LSM9DS1_Library2
imported library
Fork of LSM9DS1_Library by
main.cpp@2:e8c2301f7523, 2016-02-03 (annotated)
- Committer:
- 4180_1
- Date:
- Wed Feb 03 18:24:29 2016 +0000
- Revision:
- 2:e8c2301f7523
- Parent:
- 0:e8167f37725c
ver 1.1
Who changed what in which revision?
User | Revision | Line number | New 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 | } |