PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Simple-Libraries
Learn
Simple Libraries
Sensor
liblsm9ds1
liblsm9ds1.c
1
16
#include "
simpletools.h
"
17
#include "lsm9ds1.h"
18
19
20
#define TEST_HARNESS 1
21
22
23
int
main
() {
24
25
#ifdef TEST_HARNESS
26
27
float
gx, gy, gz;
// x, y, and z axis readings of the gyroscope
28
float
ax, ay, az;
// x, y, and z axis readings of the accelerometer
29
float
mx, my, mz;
// x, y, and z axis readings of the magnetometer
30
float
tmp;
31
32
int
whoAmI =
imu_init
(0, 1, 2, 3);
33
34
print
(
"Who Am I? %x\r"
, whoAmI);
35
36
37
38
imu_clearAccelInterrupt();
39
//imu_setAccelInterrupt(Y_AXIS, 1.1, 20, 1, 0);
40
41
high
(26);
42
imu_calibrateMag();
43
low
(26);
44
45
pause
(3000);
46
high
(26);
47
//imu_calibrateAG();
48
low
(26);
49
50
pause
(3000);
51
52
while
(1) {
53
/*
54
if(input(10))
55
{
56
high(26);
57
imu_readAccelCalculated(&ax, &ay, &az);
58
print("Accel:\t%.2f\t%.2f\t%.2f\r", ax, ay, az);
59
60
pause(250);
61
}
62
else
63
{
64
low(26);
65
pause(1);
66
}
67
*/
68
imu_readGyroCalculated(&gx, &gy, &gz);
69
print
(
"Gyro:\t%.2f\t%.2f\t%.2f\r"
, gx, gy, gz);
70
71
imu_readAccelCalculated(&ax, &ay, &az);
72
print
(
"Accel:\t%.2f\t%.2f\t%.2f\r"
, ax, ay, az);
73
74
imu_readMagCalculated(&mx, &my, &mz);
75
print
(
"Mag:\t%.2f\t%.2f\t%.2f\r"
, mx, my, mz);
76
77
imu_readTempCalculated(&tmp,
FAHRENHEIT
);
78
print
(
"Temp:\t%.2f\r\r"
, tmp);
79
/*
80
imu_readGyro(&gx, &gy, &gz);
81
print("Gyro:\t%d\t%d\t%d\r", gx, gy, gz);
82
83
imu_readAccel(&ax, &ay, &az);
84
print("Accel:\t%d\t%d\t%d\r", ax, ay, az);
85
86
imu_readMag(&mz, &my, &mz);
87
print("Mag:\t%d\t%d\t%d\r", mz, my, mz);
88
89
imu_readTemp(&tmp);
90
print("Temp:\t%d\r\r", tmp);
91
*/
92
pause
(500);
93
}
94
95
96
#endif
97
}
98
99
100
101
imu_init
int imu_init(int pinSCL, int pinSDIO, int pinAG, int pinM)
Initializes the LSM9DS1 IMU module.
Definition:
imu_init.c:25
pause
void pause(int time)
Delay cog from moving on to the next statement for a certain length of time.
Definition:
libws2812.c:125
low
void low(int pin)
Set an I/O pin to output-low.
Definition:
low.c:19
simpletools.h
This library provides convenient functions for a variety of microcontroller I/O, timing,...
print
int print(const char *format,...) __attribute__((format(printf
Print format "..." args to the default simple terminal device. The output is limited to 256 bytes.
main
int main(void)
Definition:
GraphicsTest.c:20
FAHRENHEIT
#define FAHRENHEIT
Definition:
bme680.h:38
high
void high(int pin)
Set an I/O pin to output-high.
Definition:
high.c:19
Generated on Fri May 20 2022 16:48:05 for PropWare by
1.8.17