forked from bolderflight/invensense-imu
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
36 lines (26 loc) · 930 Bytes
/
main.cpp
File metadata and controls
36 lines (26 loc) · 930 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <stdio.h>
//#include <string.h>
#include "pico/stdlib.h"
#include "MPU9250.h"
#pragma clang diagnostic push
#pragma ide diagnostic ignored "EndlessLoop"
MPU9250 IMU(0, 5);
int main() {
stdio_init_all();
int i = IMU.begin();
absolute_time_t from;
int64_t time_diff;
while (1) {
from = get_absolute_time();
IMU.readSensor();
time_diff = absolute_time_diff_us(from, get_absolute_time());
printf("Accel. X = %f, Y = %f, Z = %f \n", IMU.getAccelX_mss(), IMU.getAccelY_mss(), IMU.getAccelZ_mss());
printf("Gyro. X = %f, Y = %f, Z = %f \n", IMU.getGyroX_rads(), IMU.getGyroY_rads(), IMU.getGyroZ_rads());
printf("Magn. X = %f, Y = %f, Z = %f \n", IMU.getMagX_uT(), IMU.getMagY_uT(), IMU.getMagZ_uT());
printf("Time taken (us): %lli", time_diff);
printf("\n");
sleep_ms(2000);
}
return 0;
}
#pragma clang diagnostic pop