File tree Expand file tree Collapse file tree 2 files changed +32
-5
lines changed
examples/Modulino_Movement/Basic Expand file tree Collapse file tree 2 files changed +32
-5
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,9 @@ ModulinoMovement movement;
5
5
float x;
6
6
float y;
7
7
float z;
8
+ float gx;
9
+ float gy;
10
+ float gz;
8
11
9
12
void setup () {
10
13
Serial.begin (9600 );
@@ -19,11 +22,23 @@ void loop() {
19
22
y = movement.getY ();
20
23
z = movement.getZ ();
21
24
25
+ gx = movement.getGyroX ();
26
+ gy = movement.getGyroY ();
27
+ gz = movement.getGyroZ ();
28
+
22
29
Serial.print (" Movement data: " );
30
+
23
31
Serial.print (" x " );
24
- Serial.print (x, 3 );
32
+ Serial.print (x,3 );
25
33
Serial.print (" y " );
26
- Serial.print (y, 3 );
34
+ Serial.print (y,3 );
27
35
Serial.print (" z " );
28
- Serial.println (z, 3 );
36
+ Serial.print (z,3 );
37
+
38
+ Serial.print (" \t\t gx " );
39
+ Serial.print (gx,1 );
40
+ Serial.print (" |gy " );
41
+ Serial.print (gy,1 );
42
+ Serial.print (" |gz " );
43
+ Serial.println (gz,1 );
29
44
}
Original file line number Diff line number Diff line change @@ -313,13 +313,15 @@ class ModulinoMovement : public Module {
313
313
}
314
314
int update () {
315
315
if (initialized) {
316
- return _imu->readAcceleration (x, y, z);
316
+ int accel = _imu->readAcceleration (x, y, z);
317
+ int gyro = _imu->readGyroscope (gx, gy, gz);
318
+ return accel && gyro;
317
319
}
318
320
return 0 ;
319
321
}
320
322
int available () {
321
323
if (initialized) {
322
- return _imu->accelerationAvailable ();
324
+ return _imu->accelerationAvailable () && _imu-> gyroscopeAvailable () ;
323
325
}
324
326
return 0 ;
325
327
}
@@ -332,9 +334,19 @@ class ModulinoMovement : public Module {
332
334
float getZ () {
333
335
return z;
334
336
}
337
+ float getGyroX () {
338
+ return gx;
339
+ }
340
+ float getGyroY () {
341
+ return gy;
342
+ }
343
+ float getGyroZ () {
344
+ return gz;
345
+ }
335
346
private:
336
347
LSM6DSOXClass* _imu = nullptr ;
337
348
float x,y,z;
349
+ float gx,gy,gz;
338
350
int initialized = 0 ;
339
351
};
340
352
You can’t perform that action at this time.
0 commit comments