@Test public void readSingle_returnsCorrectValue() throws IOException { Ads1015Device mockDevice = new Ads1015Device(); mockDevice.setChannelValue(2.048f); Ads1xxx driver = new Ads1xxx(mockDevice, Ads1xxx.Configuration.ADS1015); int result = driver.readSingleEndedInput(0); assertEquals(2047, result); }
public int readSingleEndedInput(int channel) throws IOException { if (mChipConfiguration != Configuration.ADS1015 && mChipConfiguration != Configuration.ADS1115) { throw new UnsupportedOperationException("Single ended input only supported on ADS1x15 chips"); } if (channel > 3) { throw new IllegalArgumentException("Channel cannot be greater than 3"); } int mode = FLAG_SINGLE_ENDED | channel; short config = getConfigRegister(); config &= ~INPUT_MASK; config |= (mode << 12) & INPUT_MASK; config |= FLAG_START_READ; setConfigRegister(config); return readRawValue(); }
Ads1xxx implements AutoCloseable { public int readSingleEndedInput(int channel) throws IOException { if (mChipConfiguration != Configuration.ADS1015 && mChipConfiguration != Configuration.ADS1115) { throw new UnsupportedOperationException("Single ended input only supported on ADS1x15 chips"); } if (channel > 3) { throw new IllegalArgumentException("Channel cannot be greater than 3"); } int mode = FLAG_SINGLE_ENDED | channel; short config = getConfigRegister(); config &= ~INPUT_MASK; config |= (mode << 12) & INPUT_MASK; config |= FLAG_START_READ; setConfigRegister(config); return readRawValue(); } }
Ads1xxx implements AutoCloseable { public int readSingleEndedInput(int channel) throws IOException { if (mChipConfiguration != Configuration.ADS1015 && mChipConfiguration != Configuration.ADS1115) { throw new UnsupportedOperationException("Single ended input only supported on ADS1x15 chips"); } if (channel > 3) { throw new IllegalArgumentException("Channel cannot be greater than 3"); } int mode = FLAG_SINGLE_ENDED | channel; short config = getConfigRegister(); config &= ~INPUT_MASK; config |= (mode << 12) & INPUT_MASK; config |= FLAG_START_READ; setConfigRegister(config); return readRawValue(); } Ads1xxx(String i2cName, Configuration chip);  Ads1xxx(String i2cName, int i2cAddress, Configuration chip); @VisibleForTesting  Ads1xxx(I2cDevice i2cDevice, Configuration chip); }
Ads1xxx implements AutoCloseable { public int readSingleEndedInput(int channel) throws IOException { if (mChipConfiguration != Configuration.ADS1015 && mChipConfiguration != Configuration.ADS1115) { throw new UnsupportedOperationException("Single ended input only supported on ADS1x15 chips"); } if (channel > 3) { throw new IllegalArgumentException("Channel cannot be greater than 3"); } int mode = FLAG_SINGLE_ENDED | channel; short config = getConfigRegister(); config &= ~INPUT_MASK; config |= (mode << 12) & INPUT_MASK; config |= FLAG_START_READ; setConfigRegister(config); return readRawValue(); } Ads1xxx(String i2cName, Configuration chip);  Ads1xxx(String i2cName, int i2cAddress, Configuration chip); @VisibleForTesting  Ads1xxx(I2cDevice i2cDevice, Configuration chip); void setInputRange(@InputRange int range); @InputRange int getInputRange(); void setComparatorMode(@ComparatorMode int mode); @ComparatorMode int getComparatorMode(); void setComparatorThreshold(short loThresh, short hiThresh); int readSingleEndedInput(int channel); double readSingleEndedVoltage(int channel); int readDifferentialInput(@DifferentialMode int mode); double readDifferentialVoltage(@DifferentialMode int mode); @Override void close(); }
Ads1xxx implements AutoCloseable { public int readSingleEndedInput(int channel) throws IOException { if (mChipConfiguration != Configuration.ADS1015 && mChipConfiguration != Configuration.ADS1115) { throw new UnsupportedOperationException("Single ended input only supported on ADS1x15 chips"); } if (channel > 3) { throw new IllegalArgumentException("Channel cannot be greater than 3"); } int mode = FLAG_SINGLE_ENDED | channel; short config = getConfigRegister(); config &= ~INPUT_MASK; config |= (mode << 12) & INPUT_MASK; config |= FLAG_START_READ; setConfigRegister(config); return readRawValue(); } Ads1xxx(String i2cName, Configuration chip);  Ads1xxx(String i2cName, int i2cAddress, Configuration chip); @VisibleForTesting  Ads1xxx(I2cDevice i2cDevice, Configuration chip); void setInputRange(@InputRange int range); @InputRange int getInputRange(); void setComparatorMode(@ComparatorMode int mode); @ComparatorMode int getComparatorMode(); void setComparatorThreshold(short loThresh, short hiThresh); int readSingleEndedInput(int channel); double readSingleEndedVoltage(int channel); int readDifferentialInput(@DifferentialMode int mode); double readDifferentialVoltage(@DifferentialMode int mode); @Override void close(); static final int RANGE_6_144V; static final int RANGE_4_096V; static final int RANGE_2_048V; static final int RANGE_1_024V; static final int RANGE_0_512V; static final int RANGE_0_256V; static final int COMPARATOR_MODE_1; static final int COMPARATOR_MODE_2; static final int COMPARATOR_MODE_4; static final int COMPARATOR_DISABLED; static final int INPUT_DIFF_0P_1N; static final int INPUT_DIFF_0P_3N; static final int INPUT_DIFF_1P_3N; static final int INPUT_DIFF_2P_3N; static final int DEFAULT_ADDRESS; }