/ Adafruit_H3LIS331.h
Adafruit_H3LIS331.h
1 /*! 2 * @file Adafruit_H3LIS331.h 3 * 4 * This is a library for the Adafruit H3LIS331 Accel breakout board 5 * 6 * Designed specifically to work with the [Adafruit H3LIS331 High-G Triple-Axis 7 * Accelerometer (+-100g/200g/400g)](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 #ifndef ADAFRUIT_H3LIS331_H 21 #define ADAFRUIT_H3LIS331_H 22 23 #include "Adafruit_LIS331.h" 24 25 /** A structure to represent scales **/ 26 typedef enum { 27 H3LIS331_RANGE_100_G = 0x0, ///< +/- 100g 28 H3LIS331_RANGE_200_G = 0x1, ///< +/- 200g 29 H3LIS331_RANGE_400_G = 0x03, ///< +/- 400g 30 } h3lis331dl_range_t; 31 32 /*! 33 * @brief Class that stores state and functions for interacting with 34 * Adafruit_H3LIS331 35 */ 36 class Adafruit_H3LIS331 : public Adafruit_LIS331 { 37 public: 38 Adafruit_H3LIS331(); 39 40 bool begin_I2C(uint8_t i2c_addr = LIS331_DEFAULT_ADDRESS, 41 TwoWire *wire = &Wire, int32_t sensorID = 0); 42 43 bool begin_SPI(uint8_t cs_pin, SPIClass *theSPI = &SPI, 44 int32_t sensor_id = 0); 45 bool begin_SPI(int8_t cs_pin, int8_t sck_pin, int8_t miso_pin, 46 int8_t mosi_pin, int32_t sensor_id = 0); 47 48 void setRange(h3lis331dl_range_t range); 49 h3lis331dl_range_t getRange(void); 50 51 private: 52 bool _init(int32_t sensor_id); 53 void _scaleValues(void); 54 }; 55 56 #endif