-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.ino
70 lines (57 loc) · 1.27 KB
/
main.ino
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include "Sensor.h"
#include "SystemVersion.h"
#include "SystemTickCounter.h"
#include "telemetry.h"
static char buffInfo[128];
static DevI2C *ext_i2c;
static LSM6DSLSensor *acc_gyro;
void getDevKitGyroscopeValue(int *x, int *y, int *z)
{
int axes[3];
acc_gyro->getGAxes(axes);
*x = axes[0];
*y = axes[1];
*z = axes[2];
}
void getDevKitAcceleratorValue(int *x, int *y, int *z)
{
int axes[3];
acc_gyro->getXAxes(axes);
*x = axes[0];
*y = axes[1];
*z = axes[2];
}
void showMotionAccelSensor()
{
int aX, aY, aZ;
int gX, gY, gZ;
getDevKitAcceleratorValue(&aX, &aY, &aZ);
getDevKitGyroscopeValue(&gX, &gY, &gZ);
snprintf(buffInfo, sizeof(buffInfo), "[%d,%d,%d,%d,%d,%d]", aX, aY, aZ, gX, gY, gZ);
Serial.println(buffInfo);
}
void setup()
{
Screen.init();
if ((ext_i2c = new DevI2C(D14, D15)) == NULL)
{
Serial.println("Failed to initialize I2C.");
for (;;)
;
}
if ((acc_gyro = new LSM6DSLSensor(*ext_i2c, D4, D5)) == NULL)
{
Serial.println("Failed to initialize gyroscope and accelerator sensor.");
for (;;)
;
}
acc_gyro->init(NULL);
acc_gyro->enableAccelerator();
acc_gyro->enableGyroscope();
Screen.clean();
Screen.print(0, "Capturing data", 1);
}
void loop()
{
showMotionAccelSensor();
}