JM9 XRCU Board 0.1.3a
Libraries API Reference
Loading...
Searching...
No Matches
General_compass Class Referenceabstract

General Compass Driver. More...

#include <General_compass.h>

Inheritance diagram for General_compass:
Heading_sensor Supported_sensor Supported_module Hmc5883l Qmc5883l

Public Member Functions

virtual bool update ()=0
 Fetches and updates new data from the 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.
 

Protected Member Functions

void set_raw_data (Mag_field_raw_t data)
 Sets the latest raw values of magnetic field strength in 3 axes.
 
virtual double raw_to_uT (const int16_t raw)=0
 The function to convert raw values to field strength in microTesla.
 
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

General Compass Driver.

Handles high-level calibration, retrieve heading and reset heading.

Author
YH Choi @ JM9

Member Function Documentation

◆ compass_cal()

bool General_compass::compass_cal ( )

Calibrates the compass, and find the ranges of each axis respectively for compass usage.

This function calibrates in a blocking manner. When this function is returned, calibration is guaranteed to be either completed or failed. ATTENTION: WHEN MAGNETOMETER CALIBRATION IS IN PROGRESS, SWING THE CHIP IN ALL DIRECTIONS OF X, Y AND Z.

Returns
true if compass is successfully calibrated, false otherwise

◆ get_eeprom_caled_vals()

Compass_cal_vals_t General_compass::get_eeprom_caled_vals ( )
protected

Loads calibration values from EEPROM.

Returns
The previously calibrated values of the compass stored in EEPROM.

◆ get_heading()

uint16_t General_compass::get_heading ( )
virtual

Gets the heading of compass in degrees.

Returns
the heading of compass in degrees [ 0 : 359 ]

Implements Heading_sensor.

◆ get_prev_caled_vals()

Compass_cal_vals_t General_compass::get_prev_caled_vals ( )

Gets the previously calibrated values of the compass.

Returns
the previously calibrated values of the compass

◆ get_raw_mag()

Mag_field_raw_t General_compass::get_raw_mag ( )

Gets a package of magnetic field strengths in 3 axes in raw value.

Returns
a package of raw values measured by the magnetometer in 3 axes

◆ get_raw_x()

int16_t General_compass::get_raw_x ( )

Gets the magnetic field strength in X-axis in raw value.

Returns
the raw value of magnetic field strength measured by the magnetometer in the X-axis

◆ get_raw_y()

int16_t General_compass::get_raw_y ( )

Gets the magnetic field strength in Y-axis in raw value.

Returns
the raw value of magnetic field strength measured by the magnetometer in the Y-axis

◆ get_raw_z()

int16_t General_compass::get_raw_z ( )

Gets the magnetic field strength in Z-axis in raw value.

Returns
the raw value of magnetic field strength measured by the magnetometer in the Z-axis

◆ get_re_zero_heading()

int16_t General_compass::get_re_zero_heading ( )

Gets the real-world heading referenced as zero-degrees.

Returns
the real-world heading that is referenced as zero-degrees in our program

◆ get_uT_mag()

Mag_field_uT_t General_compass::get_uT_mag ( )

Gets a package of magnetic field strengths in 3 axes in µT (microTesla).

Returns
a package of magnetic field strength measured by the magnetometer in 3 axes

◆ get_uT_x()

double General_compass::get_uT_x ( )

Gets the magnetic field strength in X-axis in µT (microTesla).

Returns
the magnetic field strength measured by the magnetometer in the X-axis

◆ get_uT_y()

double General_compass::get_uT_y ( )

Gets the magnetic field strength in Y-axis in µT (microTesla).

Returns
the magnetic field strength measured by the magnetometer in the Y-axis

◆ get_uT_z()

double General_compass::get_uT_z ( )

Gets the magnetic field strength in Z-axis in µT (microTesla).

Returns
the magnetic field strength measured by the magnetometer in the Z-axis

◆ reset_heading()

bool General_compass::reset_heading ( )
virtual

Takes the current heading of compass as zero.

Returns
true if compass heading is resetted, false otherwise.

Implements Heading_sensor.

◆ set_cal_vals()

void General_compass::set_cal_vals ( Compass_cal_vals_t vals)
protected

Sets the calibration values.

Parameters
valsthe calibration values

◆ set_raw_data()

void General_compass::set_raw_data ( Mag_field_raw_t data)
protected

Sets the latest raw values of magnetic field strength in 3 axes.

Parameters
datathe latest raw values of magnetic field strength in 3 axes

◆ update()

virtual bool General_compass::update ( )
pure 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

Implemented in Hmc5883l, and Qmc5883l.


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