JM9 XRCU Board 0.1.0
Libraries API Reference
Loading...
Searching...
No Matches
Qmc5883l Class Reference

QMC5883L Compass Driver for XRCU. More...

#include <Qmc5883l.h>

Inheritance diagram for Qmc5883l:
General_compass Heading_sensor Supported_sensor Supported_module

Public Member Functions

 Qmc5883l (const uint32_t init_port)
 Creates a new Qmc5883l object.
 
bool begin (const uint8_t init_i2c_address=DEFAULT_I2C_ADDRESS)
 Configures the settings of the I2C bus and the QMC5883L magnetometer.
 
bool begin (const Compass_cal_vals_t compass_cal_values, const uint8_t init_i2c_address=DEFAULT_I2C_ADDRESS)
 Configures the settings of the I2C bus and the QMC5883L magnetometer.
 
bool reset ()
 Software-resets the QMC5883L.
 
bool update ()
 Fetches and updates new data from the compass.
 
int16_t get_raw_temp ()
 Gets the raw temperature reading.
 
uint8_t id ()
 Reads the identification register.
 
bool is_mag_present ()
 Checks for the presence of the HMC5883L magnetometer on the I2C bus.
 
- Public Member Functions inherited from General_compass
int16_t get_raw_x ()
 Gets the magnetic field strength in X-axis in raw value.
 
int16_t get_raw_y ()
 Gets the magnetic field strength in Y-axis in raw value.
 
int16_t get_raw_z ()
 Gets the magnetic field strength in Z-axis in raw value.
 
Mag_field_raw_t get_raw_mag ()
 Gets a package of magnetic field strengths in 3 axes in raw value.
 
double get_uT_x ()
 Gets the magnetic field strength in X-axis in µT (microTesla).
 
double get_uT_y ()
 Gets the magnetic field strength in Y-axis in µT (microTesla).
 
double get_uT_z ()
 Gets the magnetic field strength in Z-axis in µT (microTesla).
 
Mag_field_uT_t get_uT_mag ()
 Gets a package of magnetic field strengths in 3 axes in µT (microTesla).
 
bool compass_cal ()
 Calibrates the compass, and find the ranges of each axis respectively for compass usage.
 
Compass_cal_vals_t get_prev_caled_vals ()
 Gets the previously calibrated values of the compass.
 
void save_caled_vals ()
 Saves the calibrated values into local EEPROM.
 
bool reset_heading ()
 Takes the current heading of compass as zero.
 
int16_t get_re_zero_heading ()
 Gets the real-world heading referenced as zero-degrees.
 
void save_re_zero_heading ()
 Saves the real-world heading referenced as zero-degrees into local EEPROM.
 
virtual uint16_t get_heading ()
 Gets the heading of compass in degrees.
 

Additional Inherited Members

- Protected Member Functions inherited from General_compass
void set_raw_data (Mag_field_raw_t data)
 Sets the latest raw values of magnetic field strength in 3 axes.
 
void set_cal_vals (Compass_cal_vals_t vals)
 Sets the calibration values.
 
Compass_cal_vals_t get_eeprom_caled_vals ()
 Loads calibration values from EEPROM.
 
void use_eeprom_re_zero_heading ()
 Uses the re-zero heading from EEPROM.
 
 General_compass ()
 Creates a General_compass object.
 
- Protected Member Functions inherited from Heading_sensor
 Heading_sensor ()
 Creates a Heading_sensor object.
 
- Protected Member Functions inherited from Supported_sensor
 Supported_sensor ()
 Creates an object of a supported sensor.
 
- Protected Member Functions inherited from Supported_module
 Supported_module ()
 Creates an object of a supported module.
 

Detailed Description

QMC5883L Compass Driver for XRCU.

Author
YH Choi @ JM9

Constructor & Destructor Documentation

◆ Qmc5883l()

Qmc5883l::Qmc5883l ( const uint32_t init_port)

Creates a new Qmc5883l object.

Parameters
init_portthe I2C port connected to this QMC5883L magnetometer.

Member Function Documentation

◆ begin() [1/2]

bool Qmc5883l::begin ( const Compass_cal_vals_t compass_cal_values,
const uint8_t init_i2c_address = DEFAULT_I2C_ADDRESS )

Configures the settings of the I2C bus and the QMC5883L magnetometer.

YOU MUST CALL THIS FUNCTION IN void setup () FUNCTION TO USE THIS OBJECT PROPERLY.

Parameters
compass_cal_valuesthe calibrated values of the QMC5883L magnetometer
init_i2c_addressthe 7-bit I2C address of the QMC5883L magnetometer
Returns
true if activation succeed, false if activation failed

◆ begin() [2/2]

bool Qmc5883l::begin ( const uint8_t init_i2c_address = DEFAULT_I2C_ADDRESS)

Configures the settings of the I2C bus and the QMC5883L magnetometer.

YOU MUST CALL THIS FUNCTION IN void setup () FUNCTION TO USE THIS OBJECT PROPERLY.

Parameters
init_i2c_addressthe 7-bit I2C address of the QMC5883L magnetometer
Returns
true if activation succeed, false if activation failed

◆ get_raw_temp()

int16_t Qmc5883l::get_raw_temp ( )

Gets the raw temperature reading.

The gain is factory-calibrated, but not the offset, so only the relative temperature is accurate.

Returns
the raw value of temperature sensor recorded by the chip in 2's complement (100 LSB / degree Celsius)

◆ id()

uint8_t Qmc5883l::id ( )

Reads the identification register.

Returns
the identification register, which should have a value of ASCII-encoded "H4C"

◆ is_mag_present()

bool Qmc5883l::is_mag_present ( )

Checks for the presence of the HMC5883L magnetometer on the I2C bus.

Returns
true if the HMC5883L magnetometer is found on the I2C bus, false otherwise

◆ reset()

bool Qmc5883l::reset ( )

Software-resets the QMC5883L.

Returns
true if software-reset signal is sent successfully, false if the signal failed to send

◆ update()

bool Qmc5883l::update ( )
virtual

Fetches and updates new data from the compass.

Returns
true if new data is fetched and updated, false if new data is not ready

Implements General_compass.


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