A library for ADS1015 and ADS1115 from Texas Instruments.
Fork of ADS1015 by
Revision 7:72e307987683, committed 2018-07-24
- Comitter:
- cgoyette
- Date:
- Tue Jul 24 16:53:15 2018 +0000
- Parent:
- 6:4c38bb36099c
- Commit message:
- removed debug messages.
Changed in this revision
Adafruit_ADS1015.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 4c38bb36099c -r 72e307987683 Adafruit_ADS1015.cpp --- a/Adafruit_ADS1015.cpp Tue Jul 17 16:17:50 2018 +0000 +++ b/Adafruit_ADS1015.cpp Tue Jul 24 16:53:15 2018 +0000 @@ -32,20 +32,20 @@ /**************************************************************************/ void Adafruit_ADS1015::writeRegister(uint8_t i2cAddress, uint8_t reg, uint16_t value) { - printf("ADC-wr1\r\n"); + //printf("ADC-wr1\r\n"); char cmd[3]; cmd[0] = (char)reg; - printf("ADC-wr cmd0=%i\r\n", cmd[0]); - printf("ADC-wr2\r\n"); + //printf("ADC-wr cmd0=%i\r\n", cmd[0]); + //printf("ADC-wr2\r\n"); cmd[1] = (char)(value>>8); - printf("ADC-wr cmd1=%i\r\n", cmd[1]); - printf("ADC-wr3\r\n"); + //printf("ADC-wr cmd1=%i\r\n", cmd[1]); + //printf("ADC-wr3\r\n"); cmd[2] = (char)(value & 0xFF); - printf("ADC-wr cmd2=%i\r\n", cmd[2]); - printf("ADC-wr4\r\n"); - + //printf("ADC-wr cmd2=%i\r\n", cmd[2]); + //printf("ADC-wr4\r\n"); + //printf("i2c-Write return = %i\r\n", m_i2c->write(i2cAddress, cmd, 3)); m_i2c->write(i2cAddress, cmd, 3); - printf("ADC-wr5\r\n"); + //printf("ADC-wr5\r\n"); } /**************************************************************************/ @@ -55,15 +55,15 @@ /**************************************************************************/ uint16_t Adafruit_ADS1015::readRegister(uint8_t i2cAddress, uint8_t reg) { - printf("ADC-RR1\r\n"); + //printf("ADC-RR1\r\n"); char data[2]; - printf("ADC-RR2\r\n"); + //printf("ADC-RR2\r\n"); data[0] = reg; // temporary use this to send address to conversion register - printf("ADC-RR3\r\n"); + //printf("ADC-RR3\r\n"); m_i2c->write(i2cAddress, data, 1); - printf("ADC-RR4\r\n"); + //printf("ADC-RR4\r\n"); m_i2c->read(i2cAddress, data, 2); - printf("ADC-RR5\r\n"); + //printf("ADC-RR5\r\n"); return (data[0] << 8 | data [1]); } @@ -91,7 +91,7 @@ { // shift 7 bit address 1 left: read expects 8 bit address, see mbed's I2C.h m_i2cAddress = i2cAddress << 1; - printf("12c-address=%i\r\n", m_i2cAddress); + //printf("12c-address=%i\r\n", m_i2cAddress); m_conversionDelay = ADS1115_CONVERSIONDELAY; m_bitShift = 0; m_gain = GAIN_TWOTHIRDS; /* +/- 6.144V range (limited to VDD +0.3V max!) */ @@ -125,13 +125,13 @@ /**************************************************************************/ uint16_t Adafruit_ADS1015::readADC_SingleEnded(uint8_t channel) { - printf("ADC1\r\n"); - printf("channel = %i\r\n", channel); + //printf("ADC1\r\n"); + //printf("channel = %i\r\n", channel); if (channel > 3) { - printf("ADC2\r\n"); + //printf("ADC2\r\n"); return 0; } - printf("ADC3\r\n"); + //printf("ADC3\r\n"); // Start with default values uint16_t config = ADS1015_REG_CONFIG_CQUE_NONE | // Disable the comparator (default val) ADS1015_REG_CONFIG_CLAT_NONLAT | // Non-latching (default val) @@ -141,48 +141,48 @@ ADS1015_REG_CONFIG_MODE_SINGLE; // Single-shot mode (default) // Set PGA/voltage range - printf("ADC4\r\n"); + //printf("ADC4\r\n"); config |= m_gain; - printf("ADC5\r\n"); + //printf("ADC5\r\n"); // Set single-ended input channel switch (channel) { case (0): - printf("ADC6\r\n"); + //printf("ADC6\r\n"); config |= ADS1015_REG_CONFIG_MUX_SINGLE_0; - printf("ADC7\r\n"); + //printf("ADC7\r\n"); break; case (1): - printf("ADC8\r\n"); + //printf("ADC8\r\n"); config |= ADS1015_REG_CONFIG_MUX_SINGLE_1; - printf("ADC9\r\n"); + //printf("ADC9\r\n"); break; case (2): - printf("ADC10\r\n"); + //printf("ADC10\r\n"); config |= ADS1015_REG_CONFIG_MUX_SINGLE_2; - printf("ADC11\r\n"); + //printf("ADC11\r\n"); break; case (3): - printf("ADC12\r\n"); + //printf("ADC12\r\n"); config |= ADS1015_REG_CONFIG_MUX_SINGLE_3; - printf("ADC13\r\n"); + //printf("ADC13\r\n"); break; } // Set 'start single-conversion' bit - printf("ADC14\r\n"); + //printf("ADC14\r\n"); config |= ADS1015_REG_CONFIG_OS_SINGLE; // Write config register to the ADC - printf("ADC15\r\n"); + //printf("ADC15\r\n"); writeRegister(m_i2cAddress, ADS1015_REG_POINTER_CONFIG, config); // Wait for the conversion to complete - printf("ADC16\r\n"); + //printf("ADC16\r\n"); wait_ms(m_conversionDelay); // Read the conversion results // Shift 12-bit results right 4 bits for the ADS1015 - printf("ADC17\r\n"); + //printf("ADC17\r\n"); return readRegister(m_i2cAddress, ADS1015_REG_POINTER_CONVERT) >> m_bitShift; }