Skip to content

[PXCT-768] Modulino Movement Gyroscope readings #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,15 @@ Represents a Modulino Movement module.
- **`float getZ()`**
Returns the Z-axis acceleration.

- **`float getRoll()`**
Returns the angular velocity around X-axis.

- **`float getPitch()`**
Returns the angular velocity around Y-axis.

- **`float getYaw()`**
Returns the angular velocity around Z-axis.

---

### ModulinoThermo
Expand Down
36 changes: 26 additions & 10 deletions examples/Modulino_Movement/Movement_Basic/Movement_Basic.ino
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
// Create a ModulinoMovement
ModulinoMovement movement;

float x;
float y;
float z;

float x, y, z;
float roll, pitch, yaw;


void setup() {
Serial.begin(9600);
Expand All @@ -24,19 +25,34 @@ void setup() {
}

void loop() {
// Read new acceleration data from the sensor
// Read new movement data from the sensor
movement.update();

// Get the acceleration values for each axis (in Gs)
// Get acceleration and gyroscope values
x = movement.getX();
y = movement.getY();
z = movement.getZ();
roll = movement.getRoll();
pitch = movement.getPitch();
yaw = movement.getYaw();

Serial.print("Movement data: ");
Serial.print("x ");
// Print acceleration values
Serial.print("A: ");
Serial.print(x, 3);
Serial.print(" y ");
Serial.print(", ");
Serial.print(y, 3);
Serial.print(" z ");
Serial.println(z, 3);
Serial.print(", ");
Serial.print(z, 3);

// Print divider between acceleration and gyroscope
Serial.print(" | G: ");

// Print gyroscope values
Serial.print(roll, 1);
Serial.print(", ");
Serial.print(pitch, 1);
Serial.print(", ");
Serial.println(yaw, 1);

delay(200);
}
16 changes: 14 additions & 2 deletions src/Modulino.h
Original file line number Diff line number Diff line change
Expand Up @@ -313,13 +313,15 @@ class ModulinoMovement : public Module {
}
int update() {
if (initialized) {
return _imu->readAcceleration(x, y, z);
int accel = _imu->readAcceleration(x, y, z);
int gyro = _imu->readGyroscope(roll, pitch, yaw);
return accel && gyro;
}
return 0;
}
int available() {
if (initialized) {
return _imu->accelerationAvailable();
return _imu->accelerationAvailable() && _imu->gyroscopeAvailable();
}
return 0;
}
Expand All @@ -332,9 +334,19 @@ class ModulinoMovement : public Module {
float getZ() {
return z;
}
float getRoll() {
return roll;
}
float getPitch() {
return pitch;
}
float getYaw() {
return yaw;
}
private:
LSM6DSOXClass* _imu = nullptr;
float x,y,z;
float roll,pitch,yaw; //gx, gy, gz
int initialized = 0;
};

Expand Down