upm  0.5.1
Sensor/Actuator repository for libmraa (v0.9.1)
 All Data Structures Files Functions Variables Enumerations Enumerator Macros Groups Pages
hmc5883l.h
1 /*
2  * Author: Brendan Le Foll <brendan.le.foll@intel.com>
3  * Contributions: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
4  * Copyright (c) 2014 Intel Corporation.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining
7  * a copy of this software and associated documentation files (the
8  * "Software"), to deal in the Software without restriction, including
9  * without limitation the rights to use, copy, modify, merge, publish,
10  * distribute, sublicense, and/or sell copies of the Software, and to
11  * permit persons to whom the Software is furnished to do so, subject to
12  * the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be
15  * included in all copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24  */
25 #pragma once
26 
27 #include <mraa/i2c.hpp>
28 
29 #define MAX_BUFFER_LENGTH 6
30 
31 namespace upm {
32 
60 class Hmc5883l {
61 public:
67  Hmc5883l(int bus);
68 
69  /*
70  * Returns the direction
71  */
72  float direction();
73 
74  /*
75  * Returns the heading
76  */
77  float heading();
78 
84  int16_t* coordinates();
85 
91  mraa::Result update();
92 
96  void set_declination(float dec);
97 
103  float get_declination();
104 private:
105  int16_t m_coor[3];
106  float m_declination;
107  uint8_t m_rx_tx_buf[MAX_BUFFER_LENGTH];
108  mraa::I2c m_i2c;
109 };
110 
111 }
void set_declination(float dec)
Definition: hmc5883l.cxx:162
mraa::Result update()
Definition: hmc5883l.cxx:121
API for the HMC5883L 3-Axis Digital Compass.
Definition: hmc5883l.h:60
Hmc5883l(int bus)
Definition: hmc5883l.cxx:84
float get_declination()
Definition: hmc5883l.cxx:168
int16_t * coordinates()
Definition: hmc5883l.cxx:156