MakeBlock Drive Updated Updated library for MakeBlock Ranger

Loading...
Searching...
No Matches
Public Member Functions | List of all members
MeGyro Class Reference

Driver for MeGyro module. More...

`#include <src/MeGyro.h>`

Inheritance diagram for MeGyro:
[legend]
Collaboration diagram for MeGyro:
[legend]

## Public Member Functions
| MeGyro (void)
| MeGyro (uint8_t port)
| MeGyro (uint8_t port, uint8_t address)
void | setpin (uint8_t AD0, uint8_t INT)
void | begin ()
void | update (void)
void | fast_update (void)
uint8_t | getDevAddr (void) const
double | getAngleX (void) const
double | getAngleY (void) const
double | getAngleZ (void) const
double | getGyroX (void) const
double | getGyroY (void) const
double | getGyroZ (void) const
double | getAngle (uint8_t index) const
void | resetData (void)
Public Member Functions inherited from MePort
| MePort (void)
| MePort (uint8_t port)
| MePort (uint8_t port, uint8_t slot)
uint8_t | getPort (void)
uint8_t | getSlot (void)
bool | dRead1 (uint8_t mode=INPUT)
bool | dRead2 (uint8_t mode=INPUT)
bool | dpRead1 (void)
bool | dpRead2 (void)
void | dWrite1 (bool value)
void | dWrite2 (bool value)
int16_t | aRead1 (void)
int16_t | aRead2 (void)
void | aWrite1 (int16_t value)
void | aWrite2 (int16_t value)
void | reset (uint8_t port)
void | reset (uint8_t port, uint8_t slot)
uint8_t | pin1 (void)
uint8_t | pin2 (void)
uint8_t | pin (void)
uint8_t | pin (uint8_t port, uint8_t slot)

## Additional Inherited Members
Protected Attributes inherited from MePort
uint8_t | s1
uint8_t | s2
uint8_t | _port
uint8_t | _slot

## Detailed Description

Driver for MeGyro module.

Class: MeGyro

Description
  Declaration of Class MeGyro

Copyright (C), 2012-2016, MakeBlock

## Constructor & Destructor Documentation

## ◆ MeGyro() [1/3]

MeGyro::MeGyro | ( | void |  | ) |

Alternate Constructor which can call your own function to map the MeCompass to arduino port, no pins are used or initialized here

Alternate Constructor which can call your own function to map the MeGyro to arduino port, no pins are used or initialized here

## ◆ MeGyro() [2/3]

MeGyro::MeGyro | ( | uint8_t | port | ) |

Alternate Constructor which can call your own function to map the MeCompass to arduino port, no pins are used or initialized here, but PWM frequency set to 976 Hz

Parameters

  [in] | port | - RJ25 port from PORT_1 to M2

Alternate Constructor which can call your own function to map the MeGyro to arduino port, no pins are used or initialized here, but PWM frequency set to 976 Hz

Parameters

  [in] | port | - RJ25 port from PORT_1 to M2

## ◆ MeGyro() [3/3]

MeGyro::MeGyro | ( | uint8_t | port,
|  | uint8_t | address
| ) |  |

Alternate Constructor which can call your own function to map the MeCompass to arduino port and change the i2c device address no pins are used or initialized here, but PWM frequency set to 976 Hz

Parameters

  [in] | port | - RJ25 port from PORT_1 to M2
  [in] | address | - the i2c address you want to set

Alternate Constructor which can call your own function to map the MeGyro to arduino port and change the i2c device address no pins are used or initialized here, but PWM frequency set to 976 Hz

Parameters

  [in] | port | - RJ25 port from PORT_1 to M2
  [in] | address | - the i2c address you want to set

## Member Function Documentation

## ◆ begin()

void MeGyro::begin | ( | void |  | ) |

Function
  begin

Description
  Initialize the MeGyro.

Parameters

  [in] | None |

Output
  None

Returns
  None

Others
  You can check the MPU6050 datasheet for the registor address.

## ◆ fast_update()

void MeGyro::fast_update | ( | void |  | ) |

Function
  fast_update

Description
  Fast update some calculated angle values to the variable.

Parameters

  [in] | None |

Output
  None

Returns
  None

Others
  The angle values are calculated by complementary filter. The time constant of filter is set to 0.5 second, but period dt is not a constant, so the filter coefficient will be calculated dynamically.

## ◆ getAngle()

double MeGyro::getAngle | ( | uint8_t | index | ) | const

Function
  getAngle

Description
  Get the angle value of setting axis.

Parameters

  [in] | index | - Axis settings(1:X-axis, 2:Y-axis, 3:Z-axis)

Output
  None

Returns
  The angle value of setting axis

Others
  Z-axis angle value is integral of Z-axis angular velocity.

## ◆ getAngleX()

double MeGyro::getAngleX | ( | void |  | ) | const

Function
  getAngleX

Description
  Get the angle value of X-axis.

Parameters

  [in] | None |

Output
  None

Returns
  The angle value of X-axis

Others
  X-axis angle value is calculated by complementary filter.

Function
  getAngleY

Description
  Get the angle value of X-axis.

Parameters

  [in] | None |

Output
  None

Returns
  The angle value of X-axis

Others
  X-axis angle value is calculated by complementary filter.

## ◆ getAngleY()

double MeGyro::getAngleY | ( | void |  | ) | const

Function
  getAngleY

Description
  Get the angle value of Y-axis.

Parameters

  [in] | None |

Output
  None

Returns
  The angle value of Y-axis

Others
  Y-axis angle value is calculated by complementary filter.

## ◆ getAngleZ()

double MeGyro::getAngleZ | ( | void |  | ) | const

Function
  getAngleZ

Description
  Get the angle value of Z-axis.

Parameters

  [in] | None |

Output
  None

Returns
  The angle value of Z-axis

Others
  Z-axis angle value is integral of Z-axis angular velocity.

## ◆ getDevAddr()

uint8_t MeGyro::getDevAddr | ( | void |  | ) | const

Function
  getDevAddr

Description
  Get the device address of Gyro.

Parameters

  [in] | None |

Output
  None

Returns
  The device address of Gyro

Others
  None

## ◆ getGyroX()

double MeGyro::getGyroX | ( | void |  | ) | const

Function
  getGyroX

Description
  Get the data of gyroXrate.

Parameters

  [in] | None |

Output
  None

Returns
  The data of gyroXrate

Others
  None

## ◆ getGyroY()

double MeGyro::getGyroY | ( | void |  | ) | const

Function
  getGyroY

Description
  Get the data of gyroYrate.

Parameters

  [in] | None |

Output
  None

Returns
  The data of gyroYrate

Others
  None

## ◆ getGyroZ()

double MeGyro::getGyroZ | ( | void |  | ) | const

Function
  getGyroZ

Description
  Get the data of gyroZrate.

Parameters

  [in] | None |

Output
  None

Returns
  The data of gyroZrate

Others
  None

## ◆ resetData()

void MeGyro::resetData | ( | void |  | ) |

Function
  resetData

Description
  Reset the angle value of setting axis.

Parameters

  [in] | None |

Output
  None

Returns
  None

Others
  None

Author
  Nicolas Bourré

## ◆ setpin()

void MeGyro::setpin | ( | uint8_t | AD0,
|  | uint8_t | INT
| ) |  |

Function
  setpin

Description
  Set the PIN of the button module.

Parameters

  [in] | AD0 | - pin mapping for arduino
  [in] | INT | - pin mapping for arduino

Output
  None

Returns
  None.

Others
  Set global variable _AD0, _INT, s1 and s2

## ◆ update()

void MeGyro::update | ( | void |  | ) |

Function
  update

Description
  Update some calculated angle values to the variable.

Parameters

  [in] | None |

Output
  None

Returns
  None

Others
  The angle values are calculated by complementary filter. The time constant of filter is set to 0.5 second, but period dt is not a constant, so the filter coefficient will be calculated dynamically.

The documentation for this class was generated from the following files:

- src/MeGyro.h
- src/MeGyro.cpp