Driver for MeCompass module.
More...
#include <src/MeCompass.h>
Driver for MeCompass module.
Class: MeCompass
- Description
- Declaration of Class MeCompass
- Copyright (C), 2012-2016, MakeBlock
◆ MeCompass() [1/3]
Alternate Constructor which can call your own function to map the MeCompass to arduino port, no pins are used or initialized here
◆ MeCompass() [2/3]
| MeCompass::MeCompass |
( |
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 |
◆ MeCompass() [3/3]
| MeCompass::MeCompass |
( |
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 |
◆ begin()
| void MeCompass::begin |
( |
void |
| ) |
|
- Function
- begin
- Description
- Initialize the MeCompass.
- Parameters
-
- Output
- None
- Returns
- None
- Others
- You can check the HMC5883 datasheet for the macro definition.
◆ getAngle()
| double MeCompass::getAngle |
( |
void |
| ) |
|
- Function
- getAngle
- Description
- Calculate the yaw angle by the calibrated sensor value.
- Parameters
-
- Output
- None
- Returns
- The angle value from 0 to 360 degrees. If not success, return an error code.
- Others
- Will return a correct angle when you keep the MeCompass working in the plane which have calibrated.
◆ getHeading()
| int16_t MeCompass::getHeading |
( |
int16_t * |
x, |
|
|
int16_t * |
y, |
|
|
int16_t * |
z |
|
) |
| |
- Function
- getHeading
- Description
- Get the sensor value of 3 axes including X-axis, Y-axis and Z-axis.
- Parameters
-
| [in] | x | - the address of the variable you want to store the value in. |
| [in] | y | - the address of the variable you want to store the value in. |
| [in] | z | - the address of the variable you want to store the value in. |
- Output
- None
- Returns
- If error, will return a error code, else return 0.
- Others
- The sequence of the sensor data registors of HMC5883 is X, Z, Y.
◆ getHeadingX()
| int16_t MeCompass::getHeadingX |
( |
void |
| ) |
|
- Function
- getHeadingX
- Description
- Get the sensor value of X-axis.
- Parameters
-
- Output
- None
- Returns
- The sensor value of X-axis. If error, will return a error code.
- Others
- The sensor value is a 16 bits signed integer.
◆ getHeadingY()
| int16_t MeCompass::getHeadingY |
( |
void |
| ) |
|
- Function
- getHeadingY
- Description
- Get the sensor value of Y-axis.
- Parameters
-
- Output
- None
- Returns
- The sensor value of Y-axis. If error, will return a error code.
- Others
- The sensor value is a 16 bits signed integer.
◆ getHeadingZ()
| int16_t MeCompass::getHeadingZ |
( |
void |
| ) |
|
- Function
- getHeadingZ
- Description
- Get the sensor value of Z-axis.
- Parameters
-
- Output
- None
- Returns
- The sensor value of Z-axis. If error, will return a error code.
- Others
- The sensor value is a 16 bits signed integer.
◆ setpin()
| void MeCompass::setpin |
( |
uint8_t |
keyPin, |
|
|
uint8_t |
ledPin |
|
) |
| |
- Function
- setpin
- Description
- Set the PIN of the button module.
- Parameters
-
| [in] | keyPin | - pin mapping for arduino |
| [in] | ledPin | - pin mapping for arduino |
- Output
- None
- Returns
- None.
- Others
- Set global variable _KeyPin, _ledPin, s1 and s2
◆ testConnection()
| bool MeCompass::testConnection |
( |
void |
| ) |
|
- Function
- testConnection
- Description
- Identify the device whether is the MeCompass.
- Parameters
-
- Output
- None
- Returns
- true or false
- Others
- You can check the HMC5883 datasheet for the identification code.
The documentation for this class was generated from the following files: