JM9 XRCU Board 0.1.1
Libraries API Reference
Loading...
Searching...
No Matches
General_compass.h
Go to the documentation of this file.
1
8
9#ifndef GENERAL_COMPASS_H
10#define GENERAL_COMPASS_H
11
12#include <Arduino.h>
13#include <EEPROM.h>
14
15#include <Heading_sensor.h>
16
25 int16_t x, y, z;
26};
27
36 double x, y, z;
37};
38
53
61 private:
65 uint16_t heading;
66
70 int16_t re_zero_heading;
71
75 Mag_field_raw_t raw_data;
76
80 Compass_cal_vals_t cal_vals;
81
86 int16_t get_eeprom_re_zero_heading ();
87
88 protected:
93 void set_raw_data (Mag_field_raw_t data);
94
98 virtual double raw_to_uT (const int16_t raw) = 0;
99
105
111
116
121
122 public:
123 // // @brief Configures the settings of the chip and communication protocols.
124 // virtual bool begin () = 0;
125
126 // low-level functions
127
132 virtual bool update () = 0;
133
138 int16_t get_raw_x ();
139
144 int16_t get_raw_y ();
145
150 int16_t get_raw_z ();
151
157
162 double get_uT_x ();
163
168 double get_uT_y ();
169
174 double get_uT_z ();
175
181
182 // high-level functions
183
192 bool compass_cal ();
193
199
203 void save_caled_vals ();
204
209 bool reset_heading ();
210
215 int16_t get_re_zero_heading ();
216
220 void save_re_zero_heading ();
221
227 virtual uint16_t get_heading ();
228};
229
230#endif // #ifndef GENERAL_COMPASS_H
bool reset_heading()
Takes the current heading of compass as zero.
Definition General_compass.cpp:131
int16_t get_raw_y()
Gets the magnetic field strength in Y-axis in raw value.
Definition General_compass.cpp:23
double get_uT_x()
Gets the magnetic field strength in X-axis in µT (microTesla).
Definition General_compass.cpp:27
Mag_field_uT_t get_uT_mag()
Gets a package of magnetic field strengths in 3 axes in µT (microTesla).
Definition General_compass.cpp:30
double get_uT_z()
Gets the magnetic field strength in Z-axis in µT (microTesla).
Definition General_compass.cpp:29
void set_cal_vals(Compass_cal_vals_t vals)
Sets the calibration values.
Definition General_compass.cpp:36
Compass_cal_vals_t get_prev_caled_vals()
Gets the previously calibrated values of the compass.
Definition General_compass.cpp:87
int16_t get_raw_x()
Gets the magnetic field strength in X-axis in raw value.
Definition General_compass.cpp:22
Mag_field_raw_t get_raw_mag()
Gets a package of magnetic field strengths in 3 axes in raw value.
Definition General_compass.cpp:25
Compass_cal_vals_t get_eeprom_caled_vals()
Loads calibration values from EEPROM.
Definition General_compass.cpp:111
virtual double raw_to_uT(const int16_t raw)=0
The function to convert raw values to field strength in microTesla.
virtual bool update()=0
Fetches and updates new data from the compass.
virtual uint16_t get_heading()
Gets the heading of compass in degrees.
Definition General_compass.cpp:169
void set_raw_data(Mag_field_raw_t data)
Sets the latest raw values of magnetic field strength in 3 axes.
Definition General_compass.cpp:32
bool compass_cal()
Calibrates the compass, and find the ranges of each axis respectively for compass usage.
Definition General_compass.cpp:40
int16_t get_re_zero_heading()
Gets the real-world heading referenced as zero-degrees.
Definition General_compass.cpp:147
double get_uT_y()
Gets the magnetic field strength in Y-axis in µT (microTesla).
Definition General_compass.cpp:28
int16_t get_raw_z()
Gets the magnetic field strength in Z-axis in raw value.
Definition General_compass.cpp:24
void use_eeprom_re_zero_heading()
Uses the re-zero heading from EEPROM.
Definition General_compass.cpp:165
General_compass()
Creates a General_compass object.
Definition General_compass.cpp:13
void save_caled_vals()
Saves the calibrated values into local EEPROM.
Definition General_compass.cpp:91
void save_re_zero_heading()
Saves the real-world heading referenced as zero-degrees into local EEPROM.
Definition General_compass.cpp:151
Heading_sensor()
Creates a Heading_sensor object.
Definition Heading_sensor.h:28
Calibration values of a compass.
Definition General_compass.h:43
Mag_field_raw_t base
Hard iron calibration value.
Definition General_compass.h:47
Mag_field_raw_t range
Soft iron calibration value.
Definition General_compass.h:51
Magnetic field strength (in raw values) packet.
Definition General_compass.h:24
Magnetic field strength (in microTesla) packet.
Definition General_compass.h:35