MPU

Init()

Function:

Initialize the attitude sensor.

Syntax:

int Init()

Example:

#include "M5Atom.h"
void setup(){
    M5.begin(true, true, true); //Clear the serial buffer, set the serial baud rate to 115200; initialize I2C; initialize the LED matrix
}

getAccelAdc()

Function:

Read the data of the accelerometer.

Syntax:

void getAccelAdc(int16_t* ax, int16_t* ay, int16_t* az)

Example:

#include "M5Atom.h"

void setup(){
  M5.begin(true, false, true);
  M5.IMU.Init();
}

int16_t x,y,z;

void loop(){
  M5.IMU.getAccelAdc(&x,&y,&z);
  Serial.printf("Ax:%d Ay:%d Az:%d/n",x ,y,z);
  delay(100);
}

getTempAdc()

Function:

Read the status of the button.

Syntax:

void getTempAdc(int16_t *t)

Example:

void M5Atom::update()
{
    M5.Btn.read();
}

getAccelData()

Function:

Read the value of a three-axis accelerometer.

Syntax:

void getAccelData(float* ax, float* ay, float* az)

Example:

#include "M5Atom.h"

void setup(){
  M5.begin(true, false, true);
  M5.IMU.Init();
}

float accX = 0.0F;
float accY = 0.0F;
float accZ = 0.0F;

void loop(){
  M5.IMU.getAccelData(&accX,&accY,&accZ);
  Serial.printf("accX,   accY,  accZ/n");
  Serial.printf("%5.2f  %5.2f  %5.2f G/n", accX, accY, accZ);
  delay(100);
}

getGyroData()

Function:

Read the value of a three-axis gyroscope.

Syntax:

void getGyroData(float* gx, float* gy, float* gz)

Example:

#include "M5Atom.h"

void setup(){
  M5.begin(true, false, true);
  M5.IMU.Init();
}

float gyroX = 0.0F;
float gyroY = 0.0F;
float gyroZ = 0.0F;

void loop(){
  M5.IMU.getGyroData(&gyroX,&gyroY,&gyroZ);
  Serial.printf("gyroX,  gyroY, gyroZ/n");
  Serial.printf("%6.2f %6.2f%6.2f o/s/n", gyroX, gyroY, gyroZ);
  delay(100);
}

getAttitude()

Function:

Read posture.

Syntax:

void getAttitude(double *pitch, double *roll)

Example:

#include "M5Atom.h"

void setup(){
  M5.begin(true, false, true);
  M5.IMU.Init();
}

double pitch, roll;
double r_rand = 180 / PI;

void loop(){
  M5.IMU.getAttitude(&pitch, &roll);
  double arc = atan2(pitch, roll) * r_rand + 180;
  double val = sqrt(pitch * pitch + roll * roll);
  Serial.printf("%.2f, %.2f, %.2f, %.2f/n", pitch, roll, arc, val);  //serial port output the formatted string
  delay(100);
}

getTempData()

Function:

Read the temperature of the sensor.

Syntax:

void update()

Example:

#include "M5Atom.h"

void setup(){
  M5.begin(true, false, true);
  M5.IMU.Init();
}

float temp = 0.0F;

void loop(){
  M5.IMU.getTempData(&temp);
  Serial.printf("Temperature : %.2f C/n", temp);
  delay(100);
}

getAhrsData()

Function:

Read the status of the button.

Syntax:

void getAhrsData(float *pitch,float *roll,float *yaw)

Example:

void M5Atom::update()
{
    M5.Btn.read();
}

SetGyroFsr()

Function:

Read the status of the button.

Syntax:

void SetGyroFsr(Gscale scale)

Example:

void M5Atom::update()
{
    M5.Btn.read();
}

SetAccelFsr()

Function:

Read the status of the button.

Syntax:

void SetAccelFsr(Ascale scale)

Example:

void M5Atom::update()
{
    M5.Btn.read();
}
On This Page