Rock Monitoring  V 1.0
FXLS8471Q.h
Go to the documentation of this file.
1 #ifndef FXLS8471Q_H
2 #define FXLS8471Q_H
3 
4 // FXLS8471Q internal register addresses
5 #define FXLS8471Q_STATUS 0x00
6 #define FXLS8471Q_WHOAMI 0x0D
7 #define FXLS8471Q_XYZ_DATA_CFG 0x0E
8 #define FXLS8471Q_CTRL_REG1 0x2A
9 #define FXLS8471Q_CTRL_REG2 0x2B
10 #define FXLS8471Q_CTRL_REG3 0X2C
11 #define FXLS8471Q_WHOAMI_VAL 0x6A
12 
13 //constants
14 #define FXLS8471Q_READ_LEN 7 // number of bytes to be read from FXLS8471Q status plus 3 accelerometer channels
15 #define FXLS8471Q_Sensitivity 0.000244
16 
17 //includes
18 #include <util/twi.h>
19 #include <stdlib.h>
20 #include <string.h>
21 #include <inttypes.h>
22 #include "Wire.h"
23 #include "WaspClasses.h"
24 #include "../Constants/Constants.h"
25 
26 class FXLS8471Q
27 {
28 public:
29 //typedefs
30  typedef struct //Struct containing the X, Y and Z values
31  {
32  int16_t x;
33  int16_t y;
34  int16_t z;
35  } structXYZ;
36 
37  typedef struct //Struct containing the pitch and roll values
38  {
39  int16_t pitch;
40  int16_t roll;
42 
43 //methods
44  FXLS8471Q(); //Constructor
45 
46  void init(uint8_t slaveAddr); // Method that confiugres FXLS8471Q accelerometer sensor
47 
48  uint8_t getAccXYZ(FXLS8471Q::structXYZ * xyz); //Method that reads the accelerometer x, y and z values
49  uint8_t getAccPitchRoll(FXLS8471Q::structPitchRoll * PitchRoll); //Method that reads the accelerometer pitch and roll angle
50 
51  void goToSleep(); //sets accelerometer to sleep mode
52 
53 private:
54 //attributes
55  uint8_t i2cSlaveAddr;
56 };
57 
58 #endif /* FXLS8471Q_H */
uint8_t i2cSlaveAddr
Definition: FXLS8471Q.h:55
void goToSleep()
This method sets the Accelerometer in Standby.
Definition: FXLS8471Q.cpp:166
Class that handles the communication to the Accelerometer FXLS8471Q.
Definition: FXLS8471Q.h:26
uint8_t getAccXYZ(FXLS8471Q::structXYZ *xyz)
This method returns the values of the X, Y and Z axis of the Accelerometer FXLS8471Q.
Definition: FXLS8471Q.cpp:101
uint8_t getAccPitchRoll(FXLS8471Q::structPitchRoll *PitchRoll)
This method returns the values of the pitch and roll angles of the Accelerometer FXLS8471Q.
Definition: FXLS8471Q.cpp:125
void init(uint8_t slaveAddr)
This method initializes the Accelerometer FXLS8471Q.
Definition: FXLS8471Q.cpp:12