this library has few cahnges from the original library, for effects of this work.
Fork of ADS1015 by
Diff: Adafruit_ADS1015.h
- Revision:
- 2:d864e21d4e58
- Parent:
- 0:8174d9ceeca1
- Child:
- 4:6445a678d458
--- a/Adafruit_ADS1015.h Sun Nov 10 18:44:47 2013 +0000 +++ b/Adafruit_ADS1015.h Sat Oct 11 08:20:09 2014 +0000 @@ -104,47 +104,46 @@ #define ADS1015_REG_CONFIG_CQUE_NONE (0x0003) // Disable the comparator and put ALERT/RDY in high state (default) /*=========================================================================*/ -typedef enum -{ - GAIN_TWOTHIRDS = ADS1015_REG_CONFIG_PGA_6_144V, - GAIN_ONE = ADS1015_REG_CONFIG_PGA_4_096V, - GAIN_TWO = ADS1015_REG_CONFIG_PGA_2_048V, - GAIN_FOUR = ADS1015_REG_CONFIG_PGA_1_024V, - GAIN_EIGHT = ADS1015_REG_CONFIG_PGA_0_512V, - GAIN_SIXTEEN = ADS1015_REG_CONFIG_PGA_0_256V +typedef enum { + GAIN_TWOTHIRDS = ADS1015_REG_CONFIG_PGA_6_144V, + GAIN_ONE = ADS1015_REG_CONFIG_PGA_4_096V, + GAIN_TWO = ADS1015_REG_CONFIG_PGA_2_048V, + GAIN_FOUR = ADS1015_REG_CONFIG_PGA_1_024V, + GAIN_EIGHT = ADS1015_REG_CONFIG_PGA_0_512V, + GAIN_SIXTEEN = ADS1015_REG_CONFIG_PGA_0_256V } adsGain_t; class Adafruit_ADS1015 { protected: - // Instance-specific properties - uint8_t m_i2cAddress; - uint8_t m_conversionDelay; - uint8_t m_bitShift; - adsGain_t m_gain; - I2C* m_i2c; - + // Instance-specific properties + uint8_t m_i2cAddress; + uint8_t m_conversionDelay; + uint8_t m_bitShift; + adsGain_t m_gain; + I2C* m_i2c; + - public: - Adafruit_ADS1015(I2C* i2c = 0, uint8_t i2cAddress = ADS1015_ADDRESS); // set i2c adress = 0 to allow ADS1115 to use this as default constructor - uint16_t readADC_SingleEnded(uint8_t channel); - int16_t readADC_Differential_0_1(void); - int16_t readADC_Differential_2_3(void); - void startComparator_SingleEnded(uint8_t channel, int16_t threshold); - int16_t getLastConversionResults(); - void setGain(adsGain_t gain); - adsGain_t getGain(void); +public: + Adafruit_ADS1015(I2C* i2c = 0, uint8_t i2cAddress = ADS1015_ADDRESS); // set i2c adress = 0 to allow ADS1115 to use this as default constructor + uint16_t readADC_SingleEnded(uint8_t channel); + int16_t readADC_Differential_0_1(void); + int16_t readADC_Differential_2_3(void); + void startComparator_SingleEnded(uint8_t channel, int16_t threshold); + int16_t getLastConversionResults(); + void setGain(adsGain_t gain); + adsGain_t getGain(void); - private: - uint16_t readRegister(uint8_t i2cAddress, uint8_t reg); - void writeRegister(uint8_t i2cAddress, uint8_t reg, uint16_t value); +private: + uint16_t readRegister(uint8_t i2cAddress, uint8_t reg); + void writeRegister(uint8_t i2cAddress, uint8_t reg, uint16_t value); }; // Derive from ADS1105 & override construction to set properties class Adafruit_ADS1115 : public Adafruit_ADS1015 { - public: - Adafruit_ADS1115(I2C* i2c, uint8_t i2cAddress = ADS1015_ADDRESS); +public: + Adafruit_ADS1115(I2C* i2c, uint8_t i2cAddress = ADS1015_ADDRESS); - private: +private: }; \ No newline at end of file