Rover API Documentation
rover_hmc5883l.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 FH Dortmund and others
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Description:
9  * RoverHMC5883L API - Interfaces for Rover HMC5883L bearing sensor application development
10  * Header file
11  *
12  * Contributors:
13  * M.Ozcelikors <mozcelikors@gmail.com>, created RoverHMC5883L class 04.12.2017
14  * David Schmelter, Fraunhofer IEM - compass sensor initial implementation
15  *
16  */
17 
18 #ifndef ROVERAPI_ROVER_HMC5883L_HPP_
19 #define ROVERAPI_ROVER_HMC5883L_HPP_
20 
22 #include <stdint.h>
23 #include <stdio.h>
24 #include <unistd.h>
25 
26 namespace rover
27 {
31  class RoverHMC5883L : public RoverSensor
32  {
33  private:
34  /* Definitions related to compass sensor */
39 
44 
49 
53  mutable unsigned int calibration_start;
54 
59 
63  int16_t xMinRaw;
64 
68  int16_t xMaxRaw;
69 
73  int16_t yMinRaw;
74 
78  int16_t yMaxRaw;
79 
84 
85  public:
89  explicit RoverHMC5883L ();
90 
95 
100  void initialize (void);
101 
106  float read (void);
107 
112  void calibrate (void);
113 
119  void setHMC588LAddress (const int address);
120 
126  void setHMC588LCalibrationPeriod(const int period);
127 
133  void setHMC588LDeclinationAngle (const float angle);
134 
139  int getHMC588LAddress (void);
140 
145  int getHMC588LCalibrationPeriod (void);
146 
151  float getHMC588LDeclinationAngle (void);
152 
153  private:
154 
161  template<typename T>
162  inline T MINIMUM_ (const T& a, const T& b);
163 
170  template<typename T>
171  inline T MAXIMUM_ (const T& a, const T& b);
172 
173  };
174 }
175 
176 
177 
178 #endif /* ROVERAPI_ROVER_HMC5883L_HPP_ */
int16_t xMaxRaw
Calibration variable to hold the maximum of xRaw results.
Definition: rover_hmc5883l.hpp:68
RoverSensor class is an abstract class to define interface between common sensors used in the rover...
Definition: rover_sensor.hpp:48
int16_t xMinRaw
Calibration variable to hold the minimum of xRaw results.
Definition: rover_hmc5883l.hpp:63
float read(void)
Reads the bearing value from Bearing sensor Sunfounder HMC5883L (float).
Definition: rover_hmc5883l.cpp:95
RoverHMC5883L()
Constructor for the RoverHMC5883L class.
Definition: rover_hmc5883l.cpp:26
int getHMC588LAddress(void)
Returns the private attribute HMC588L_ADDRESS.
Definition: rover_hmc5883l.cpp:180
int CALIBRATION_DURATION
Calibration duration for compass sensor.
Definition: rover_hmc5883l.hpp:43
float DECLINATION_ANGLE
Declination angle / correction factor for compass sensor.
Definition: rover_hmc5883l.hpp:48
int16_t yMaxRaw
Calibration variable to hold the maximum of yRaw results.
Definition: rover_hmc5883l.hpp:78
rover Namespace contains classes to manage Rover sensors, gpio, buzzer, buttons, driving, utilities, and cloud.
Definition: rover_api.hpp:293
void setHMC588LCalibrationPeriod(const int period)
Sets the HMC588L Calibration Duration.
Definition: rover_hmc5883l.cpp:175
void setHMC588LAddress(const int address)
Sets the HMC588L Address.
Definition: rover_hmc5883l.cpp:165
T MAXIMUM_(const T &a, const T &b)
Inline macro to find maximum of two values regardles of their types (template).
Definition: rover_hmc5883l.cpp:202
float getHMC588LDeclinationAngle(void)
Returns the HMC588L Declination angle.
Definition: rover_hmc5883l.cpp:185
int16_t yMinRaw
Calibration variable to hold the minimum of yRaw results.
Definition: rover_hmc5883l.hpp:73
void initialize(void)
Function to setup HMC5883L sensor.
Definition: rover_hmc5883l.cpp:43
void calibrate(void)
Starts calibration for the bearing sensor.
Definition: rover_hmc5883l.cpp:73
RoverHMC5883L is a class that is inherited from RoverSensor abstract class. RoverHMC5883L class conta...
Definition: rover_hmc5883l.hpp:31
unsigned int calibration_start
Calibration variable for HMC5883L.
Definition: rover_hmc5883l.hpp:53
int getHMC588LCalibrationPeriod(void)
Returns the HMC588L Calibration Duration.
Definition: rover_hmc5883l.cpp:190
int i2c_hmc588l_fd
Private member attribute for I2C file descriptor.
Definition: rover_hmc5883l.hpp:83
void setHMC588LDeclinationAngle(const float angle)
Sets the HMC588L Declination angle.
Definition: rover_hmc5883l.cpp:170
int ROVERHMC5883L_SETUP_
Flag to hold if HMC5883L is set up.
Definition: rover_hmc5883l.hpp:58
T MINIMUM_(const T &a, const T &b)
Inline macro to find minimum of two values regardles of their types (template).
Definition: rover_hmc5883l.cpp:196
int HMC588L_ADDRESS
Address for compass sensor.
Definition: rover_hmc5883l.hpp:38
~RoverHMC5883L()
Destructor for the RoverHMC5883L class.
Definition: rover_hmc5883l.cpp:41