/ Adafruit_LIS331HH.h
Adafruit_LIS331HH.h
1 /*! 2 * @file Adafruit_LIS331HH.h 3 * 4 * This is a library for the Adafruit LIS331HH Accel breakout board 5 * 6 * Designed specifically to work with the [Adafruit LIS331HH Triple-Axis 7 * Accelerometer (+-6g/12g/24g)](https://www.adafruit.com/product/4XXX) 8 * 9 * This sensor communicates over I2C or SPI (our library code supports both) so 10 * you can share it with a bunch of other sensors on the same I2C bus. 11 * 12 * Adafruit invests time and resources providing this open source code, 13 * please support Adafruit andopen-source hardware by purchasing products 14 * from Adafruit! 15 * 16 * Bryan Siepert for Adafruit Industries 17 * BSD license, all text above must be included in any redistribution 18 * 19 */ 20 21 #ifndef ADAFRUIT_LIS331HH_H 22 #define ADAFRUIT_LIS331HH_H 23 24 #include "Adafruit_LIS331.h" 25 26 /** I2C ADDRESS/BITS **/ 27 #define LIS331HH_DEFAULT_ADDRESS (0x18) // if SDO/SA0 is 3V, its 0x19 28 29 /** A structure to represent scales **/ 30 typedef enum { 31 LIS331HH_RANGE_6_G = 0x0, ///< +/- 6G 32 LIS331HH_RANGE_12_G = 0x1, ///< +/- 12G 33 LIS331HH_RANGE_24_G = 0x03, ///< +/- 24Gvalue) 34 } lis331hh_range_t; 35 36 /*! 37 * @brief Class that stores state and functions for interacting with 38 * Adafruit_LIS331HH 39 */ 40 class Adafruit_LIS331HH : public Adafruit_LIS331 { 41 public: 42 Adafruit_LIS331HH(); 43 44 bool begin_I2C(uint8_t i2c_addr = LIS331_DEFAULT_ADDRESS, 45 TwoWire *wire = &Wire, int32_t sensorID = 0); 46 47 bool begin_SPI(uint8_t cs_pin, SPIClass *theSPI = &SPI, 48 int32_t sensor_id = 0); 49 bool begin_SPI(int8_t cs_pin, int8_t sck_pin, int8_t miso_pin, 50 int8_t mosi_pin, int32_t sensor_id = 0); 51 52 void setRange(lis331hh_range_t range); 53 lis331hh_range_t getRange(void); 54 55 private: 56 bool _init(int32_t sensor_id); 57 void _scaleValues(void); 58 }; 59 60 #endif