diff --git a/ADS1X15.cpp b/ADS1X15.cpp index 4960cab..f764958 100644 --- a/ADS1X15.cpp +++ b/ADS1X15.cpp @@ -1,7 +1,7 @@ // // FILE: ADS1X15.cpp // AUTHOR: Rob Tillaart -// VERSION: 0.3.3 +// VERSION: 0.3.4 // DATE: 2013-03-24 // PUPROSE: Arduino library for ADS1015 and ADS1115 // URL: https://github.com/RobTillaart/ADS1X15 @@ -22,6 +22,8 @@ // 0.3.1 2021-04-25 #22, add get/setClock() for Wire speed + reset() // 0.3.2 2021-10-07 fix build-CI; update readme + add new examples // 0.3.3 2021-10-17 update build-CI (esp32), readme.md, keywords.txt +// 0.3.4 2021-12-11 update library.json, license, minor edits incl layout) +// add unit test constants. #include "ADS1X15.h" @@ -102,7 +104,7 @@ differs for different devices, check datasheet or readme.md #define ADS1X15_COMP_QUE_1_CONV 0x0000 // trigger alert after 1 convert #define ADS1X15_COMP_QUE_2_CONV 0x0001 // trigger alert after 2 converts #define ADS1X15_COMP_QUE_4_CONV 0x0002 // trigger alert after 4 converts -#define ADS1X15_COMP_QUE_NONE 0x0003 // dosable comparator +#define ADS1X15_COMP_QUE_NONE 0x0003 // disable comparator // _CONFIG masks @@ -230,21 +232,21 @@ uint8_t ADS1X15::getGain() } -float ADS1X15::toVoltage(int16_t val) +float ADS1X15::toVoltage(int16_t value) { - if (val == 0) return 0; + if (value == 0) return 0; float volts = getMaxVoltage(); if (volts < 0) return volts; - volts *= val; + volts *= value; if (_config & ADS_CONF_RES_16) { - volts /= 32767; // val = 16 bits - sign bit = 15 bits mantissa + volts /= 32767; // value = 16 bits - sign bit = 15 bits mantissa } else { - volts /= 2047; // val = 12 bits - sign bit = 11 bit mantissa + volts /= 2047; // value = 12 bits - sign bit = 11 bit mantissa } return volts; } @@ -418,6 +420,7 @@ int16_t ADS1X15::_readADC(uint16_t readmode) return getValue(); } + void ADS1X15::_requestADC(uint16_t readmode) { // write to register is needed in continuous mode as other flags can be changed @@ -436,6 +439,7 @@ void ADS1X15::_requestADC(uint16_t readmode) _writeRegister(_address, ADS1X15_REG_CONFIG, config); } + bool ADS1X15::_writeRegister(uint8_t address, uint8_t reg, uint16_t value) { _wire->beginTransmission(address); @@ -445,6 +449,7 @@ bool ADS1X15::_writeRegister(uint8_t address, uint8_t reg, uint16_t value) return (_wire->endTransmission() == 0); } + uint16_t ADS1X15::_readRegister(uint8_t address, uint8_t reg) { _wire->beginTransmission(address); @@ -506,43 +511,49 @@ ADS1015::ADS1015(uint8_t address, TwoWire *wire) _maxPorts = 4; } + int16_t ADS1015::readADC_Differential_0_3() { return _readADC(ADS1X15_MUX_DIFF_0_3); } + int16_t ADS1015::readADC_Differential_1_3() { return _readADC(ADS1X15_MUX_DIFF_1_3); } + int16_t ADS1015::readADC_Differential_2_3() { return _readADC(ADS1X15_MUX_DIFF_2_3); } + int16_t ADS1015::readADC_Differential_0_2() { return readADC(2) - readADC(0); } + int16_t ADS1015::readADC_Differential_1_2() { return readADC(2) - readADC(1);; } - void ADS1015::requestADC_Differential_0_3() { _requestADC(ADS1X15_MUX_DIFF_0_3); } + void ADS1015::requestADC_Differential_1_3() { _requestADC(ADS1X15_MUX_DIFF_1_3); } + void ADS1015::requestADC_Differential_2_3() { _requestADC(ADS1X15_MUX_DIFF_2_3); @@ -593,44 +604,54 @@ ADS1115::ADS1115(uint8_t address, TwoWire *wire) _maxPorts = 4; } + int16_t ADS1115::readADC_Differential_0_3() { return _readADC(ADS1X15_MUX_DIFF_0_3); } + int16_t ADS1115::readADC_Differential_1_3() { return _readADC(ADS1X15_MUX_DIFF_1_3); } + int16_t ADS1115::readADC_Differential_2_3() { return _readADC(ADS1X15_MUX_DIFF_2_3); } + int16_t ADS1115::readADC_Differential_0_2() { return readADC(2) - readADC(0); } + int16_t ADS1115::readADC_Differential_1_2() { return readADC(2) - readADC(1);; } + void ADS1115::requestADC_Differential_0_3() { _requestADC(ADS1X15_MUX_DIFF_0_3); } + void ADS1115::requestADC_Differential_1_3() { _requestADC(ADS1X15_MUX_DIFF_1_3); } + void ADS1115::requestADC_Differential_2_3() { _requestADC(ADS1X15_MUX_DIFF_2_3); } + // --- END OF FILE + diff --git a/ADS1X15.h b/ADS1X15.h index 2ec9dd7..966e227 100644 --- a/ADS1X15.h +++ b/ADS1X15.h @@ -2,7 +2,7 @@ // // FILE: ADS1X15.H // AUTHOR: Rob Tillaart -// VERSION: 0.3.3 +// VERSION: 0.3.4 // DATE: 2013-03-24 // PUPROSE: Arduino library for ADS1015 and ADS1115 // URL: https://github.com/RobTillaart/ADS1X15 @@ -12,7 +12,7 @@ #include "Arduino.h" #include "Wire.h" -#define ADS1X15_LIB_VERSION (F("0.3.3")) +#define ADS1X15_LIB_VERSION (F("0.3.4")) // allow compile time default address // address in { 0x48, 0x49, 0x4A, 0x4B }, no test... @@ -53,7 +53,7 @@ class ADS1X15 uint8_t getGain(); // 0xFF == invalid gain error. // both may return ADS1X15_INVALID_VOLTAGE if the gain is invalid. - float toVoltage(int16_t val = 1); // converts raw to voltage + float toVoltage(int16_t value = 1); // converts raw to voltage float getMaxVoltage(); // -100 == invalid voltage error // 0 = CONTINUOUS diff --git a/LICENSE b/LICENSE index 39d07e3..c9bd779 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2013-2021 Rob Tillaart +Copyright (c) 2013-2022 Rob Tillaart Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 441b626..0c364fa 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ # ADS1X15 -Arduino library for I2C ADC ADS1015, ADS1115, +Arduino library for I2C ADC ADS1015, ADS1115, and similar. ## Description @@ -31,7 +31,7 @@ differential measurement. ## Interface -The address of the ADS1113/4/5 is determined by to which pin the ADDR +The address of the ADS1113/4/5 is determined by to which pin the **ADDR** is connected to: | ADDR pin connected to | Address | Notes | @@ -42,7 +42,7 @@ is connected to: | SCL | 0x4B | | -- **ADS1x15()** constructor, should not be used. +- **ADS1x15()** base constructor, should not be used. - **ADS1013(address, TwoWire \*wire = &Wire)** Constructor with device address, and optional the Wire interface as parameter. - **ADS1014(address, TwoWire \*wire = &Wire)** Constructor with device address, @@ -170,7 +170,7 @@ in terms of code { if (ADS.isReady()) { - val = ADS.getValue(); + value = ADS.getValue(); ADS.requestADC(pin); // request new conversion } // do other things here @@ -183,6 +183,7 @@ See examples ## ReadADC Differential For reading the ADC in a differential way there are 4 calls possible. + - **int16_t readADC_Differential_0_1()** returns the difference between 2 ADC pins. - **int16_t readADC_Differential_0_3()** ADS1x15 only - **int16_t readADC_Differential_1_3()** ADS1x15 only @@ -191,6 +192,7 @@ For reading the ADC in a differential way there are 4 calls possible. - **int16_t readADC_Differential_1_2()** ADS1x15 only - in software (no async equivalent) The differential reading of the ADC can also be done with asynchronous calls. + - **void requestADC_Differential_0_1()** starts conversion for differential reading - **void requestADC_Differential_0_3()** ADS1x15 only - **void requestADC_Differential_1_3()** ADS1x15 only @@ -199,8 +201,8 @@ The differential reading of the ADC can also be done with asynchronous calls. After one of these calls one need to call - **int16_t getValue()** Read the result of the last conversion. -The readiness of a CONTINUOUS conversion can only be detected by the RDY line. -Use interrupt for this, see examples. +The readiness of a CONTINUOUS conversion can only be detected by the **RDY** line. +Best to use an interrupt for this, see examples. #### ReadADC continuous mode @@ -226,6 +228,7 @@ See examples. If the thresholdHigh is set to 0x0100 and the thresholdLow to 0x0000 the **ALERT/RDY** pin is triggered when a conversion is ready. + - **void setComparatorThresholdLow(int16_t lo)** writes value to device directly. - **void setComparatorThresholdHigh(int16_t hi)** writes value to device directly. - **int16_t getComparatorThresholdLow()** reads value from device. @@ -304,6 +307,7 @@ A value of 3 (or above) effectively disables the comparator. See table below. Depending on the comparator mode **TRADITIONAL** or **WINDOW** the thresholds registers mean something different see - Comparator Mode above or datasheet. + - **void setComparatorThresholdLow(int16_t lo)** set the low threshold; take care the hi >= lo. - **void setComparatorThresholdHigh(int16_t hi)** set the high threshold; take care the hi >= lo. - **int16_t getComparatorThresholdLow()** reads value from device. diff --git a/examples/ADS_async_16_channel/ADS_async_16_channel.ino b/examples/ADS_async_16_channel/ADS_async_16_channel.ino index 4fcc8bb..f2897fe 100644 --- a/examples/ADS_async_16_channel/ADS_async_16_channel.ino +++ b/examples/ADS_async_16_channel/ADS_async_16_channel.ino @@ -22,6 +22,7 @@ int idx = 0; uint32_t last = 0, now = 0; + void setup() { Serial.begin(115200); @@ -116,4 +117,6 @@ void ADS_print_all() Serial.println(); } + // -- END OF FILE -- + diff --git a/examples/ADS_async_8_channel/ADS_async_8_channel.ino b/examples/ADS_async_8_channel/ADS_async_8_channel.ino index 3e0ad54..f493672 100644 --- a/examples/ADS_async_8_channel/ADS_async_8_channel.ino +++ b/examples/ADS_async_8_channel/ADS_async_8_channel.ino @@ -28,6 +28,7 @@ int idx = 0; uint32_t lastTime = 0; + void setup() { Serial.begin(115200); @@ -133,4 +134,6 @@ void ADS_print_all() // Serial.println(); } + // -- END OF FILE -- + diff --git a/examples/ADS_async_differential/ADS_async_differential.ino b/examples/ADS_async_differential/ADS_async_differential.ino index 36103c9..edbe73b 100644 --- a/examples/ADS_async_differential/ADS_async_differential.ino +++ b/examples/ADS_async_differential/ADS_async_differential.ino @@ -18,6 +18,7 @@ #include "ADS1X15.h" + // choose you sensor // ADS1013 ADS(0x48); // ADS1014 ADS(0x48); @@ -51,6 +52,7 @@ void setup() ADS.requestADC_Differential_0_1(); } + void loop() { if (handleConversion() == true) @@ -92,4 +94,6 @@ bool handleConversion() return false; // default not all read } + // -- END OF FILE -- + diff --git a/examples/ADS_continuous/ADS_continuous.ino b/examples/ADS_continuous/ADS_continuous.ino index 2e0c343..3c6a7e0 100644 --- a/examples/ADS_continuous/ADS_continuous.ino +++ b/examples/ADS_continuous/ADS_continuous.ino @@ -16,6 +16,7 @@ #include "ADS1X15.h" + // choose you sensor // ADS1013 ADS(0x48); // ADS1014 ADS(0x48); @@ -39,9 +40,13 @@ void setup() ADS.readADC(0); // first read to trigger } + void loop() { Serial.println(ADS.getValue()); + // optional other code here } -// -- END OF FILE -- \ No newline at end of file + +// -- END OF FILE -- + diff --git a/examples/ADS_continuous_4_channel/ADS_continuous_4_channel.ino b/examples/ADS_continuous_4_channel/ADS_continuous_4_channel.ino index 22666be..1e83f8b 100644 --- a/examples/ADS_continuous_4_channel/ADS_continuous_4_channel.ino +++ b/examples/ADS_continuous_4_channel/ADS_continuous_4_channel.ino @@ -18,8 +18,10 @@ // so one can see these as references in the output. // + #include "ADS1X15.h" + // choose you sensor // ADS1013 ADS(0x48); // ADS1014 ADS(0x48); @@ -32,6 +34,7 @@ volatile bool RDY = false; uint8_t channel = 0; int16_t val[4] = { 0, 0, 0, 0 }; + void setup() { Serial.begin(115200); @@ -59,6 +62,7 @@ void setup() ADS.readADC(channel); // trigger first read } + void loop() { handleConversion(); @@ -73,11 +77,15 @@ void loop() delay(100); } + +// interrupt service routine +// kept as minimal as possible void adsReady() { RDY = true; } + void handleConversion() { if (RDY) @@ -91,4 +99,7 @@ void handleConversion() RDY = false; } } + + // -- END OF FILE -- + diff --git a/examples/ADS_continuous_8_channel/ADS_continuous_8_channel.ino b/examples/ADS_continuous_8_channel/ADS_continuous_8_channel.ino index cee55b0..f586c17 100644 --- a/examples/ADS_continuous_8_channel/ADS_continuous_8_channel.ino +++ b/examples/ADS_continuous_8_channel/ADS_continuous_8_channel.ino @@ -18,18 +18,25 @@ // so one can see these as references in the output. // + #include "ADS1X15.h" + // adjust addresses if needed ADS1115 ADS_1(0x49); ADS1115 ADS_2(0x48); +// two interrupt flags volatile bool RDY_1 = false; volatile bool RDY_2 = false; -uint8_t channel_1 = 0; -uint8_t channel_2 = 0; + +uint8_t channel_1 = 0; // channel from device 1 +uint8_t channel_2 = 0; // channel from device 2 + +// array to hold the data. int16_t val[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; + void setup() { Serial.begin(115200); @@ -73,6 +80,7 @@ void setup() ADS_2.readADC(channel_2); // trigger first read } + void loop() { handleConversion(); @@ -87,17 +95,20 @@ void loop() delay(100); } -// catch interrupt and set flag + +// catch interrupt and set flag device 1 void adsReady_1() { RDY_1 = true; } +// catch interrupt and set flag device 1 void adsReady_2() { RDY_2 = true; } + // handle conversions that are ready void handleConversion() { @@ -123,4 +134,6 @@ void handleConversion() } } + // -- END OF FILE -- + diff --git a/examples/ADS_continuous_differential/ADS_continuous_differential.ino b/examples/ADS_continuous_differential/ADS_continuous_differential.ino index 7a83336..d689fc6 100644 --- a/examples/ADS_continuous_differential/ADS_continuous_differential.ino +++ b/examples/ADS_continuous_differential/ADS_continuous_differential.ino @@ -18,12 +18,14 @@ #include "ADS1X15.h" + // choose you sensor // ADS1013 ADS(0x48); // ADS1014 ADS(0x48); // ADS1015 ADS(0x48); // ADS1113 ADS(0x48); // ADS1114 ADS(0x48); + ADS1115 ADS(0x48); @@ -87,12 +89,14 @@ void loop() // delay(10); } -// interrupt handler, just sets the RDY flag + +// interrupt handler, sets the RDY flag void adsReady() { RDY = true; } + // can be changed to hold other differentials or normal reads too. bool handleConversion() { @@ -121,3 +125,4 @@ bool handleConversion() // -- END OF FILE -- + diff --git a/examples/ADS_differential/ADS_differential.ino b/examples/ADS_differential/ADS_differential.ino index 91711a8..c1a05cb 100644 --- a/examples/ADS_differential/ADS_differential.ino +++ b/examples/ADS_differential/ADS_differential.ino @@ -26,10 +26,12 @@ // measure at x and y (connect to AIN0 and AIN1). // range from -VDD .. +VDD are possible + #include ADS1115 ADS(0x48); + void setup() { Serial.begin(115200); @@ -41,6 +43,7 @@ void setup() ADS.setGain(0); } + void loop() { int16_t val_01 = ADS.readADC_Differential_0_1(); @@ -61,4 +64,6 @@ void loop() delay(1000); } + // -- END OF FILE -- + diff --git a/examples/ADS_high_speed_differential/ADS_high_speed_differential.ino b/examples/ADS_high_speed_differential/ADS_high_speed_differential.ino index d548029..252a95c 100644 --- a/examples/ADS_high_speed_differential/ADS_high_speed_differential.ino +++ b/examples/ADS_high_speed_differential/ADS_high_speed_differential.ino @@ -71,6 +71,7 @@ void setup() ADS_2.readADC(channel); // trigger first read } + void loop() { if (handleConversion() == true) @@ -82,8 +83,6 @@ void loop() } Serial.println(); } - - } @@ -122,3 +121,4 @@ bool handleConversion() // -- END OF FILE -- + diff --git a/examples/ADS_minimum/ADS_minimum.ino b/examples/ADS_minimum/ADS_minimum.ino index d854951..7e948d1 100644 --- a/examples/ADS_minimum/ADS_minimum.ino +++ b/examples/ADS_minimum/ADS_minimum.ino @@ -15,16 +15,20 @@ // view with Serial Plotter + #include "ADS1X15.h" + // choose you sensor // ADS1013 ADS(0x48); // ADS1014 ADS(0x48); // ADS1015 ADS(0x48); // ADS1113 ADS(0x48); // ADS1114 ADS(0x48); + ADS1115 ADS(0x48); + void setup() { Serial.begin(115200); @@ -37,10 +41,13 @@ void setup() Serial.println("Voltage"); } + void loop() { int16_t raw = ADS.readADC(0); Serial.println(ADS.toVoltage(raw), 3); } + // -- END OF FILE -- + diff --git a/examples/ADS_performance/ADS_performance.ino b/examples/ADS_performance/ADS_performance.ino index a94d8b8..c1ef141 100644 --- a/examples/ADS_performance/ADS_performance.ino +++ b/examples/ADS_performance/ADS_performance.ino @@ -16,17 +16,20 @@ #include "ADS1X15.h" + // choose you sensor // ADS1013 ADS(0x48); // ADS1014 ADS(0x48); // ADS1015 ADS(0x48); // ADS1113 ADS(0x48); // ADS1114 ADS(0x48); + ADS1115 ADS(0x48); uint32_t start, d1, d2; int x; + void setup() { Serial.begin(115200); @@ -53,10 +56,12 @@ void setup() Serial.println("\nDone..."); } + void loop() { } + void test_single_shot() { Serial.print(__FUNCTION__); @@ -73,6 +78,7 @@ void test_single_shot() Serial.println(d1); } + void test_continuous() { Serial.print(__FUNCTION__); @@ -89,4 +95,6 @@ void test_continuous() Serial.println(d2); } -// -- END OF FILE -- \ No newline at end of file + +// -- END OF FILE -- + diff --git a/examples/ADS_read/ADS_read.ino b/examples/ADS_read/ADS_read.ino index dba2f67..49a8aae 100644 --- a/examples/ADS_read/ADS_read.ino +++ b/examples/ADS_read/ADS_read.ino @@ -14,10 +14,12 @@ // measure at x (connect to AIN0). // + #include "ADS1X15.h" ADS1115 ADS(0x48); + void setup() { Serial.begin(115200); @@ -28,6 +30,7 @@ void setup() ADS.begin(); } + void loop() { ADS.setGain(0); @@ -48,4 +51,6 @@ void loop() delay(1000); } + // -- END OF FILE -- + diff --git a/examples/ADS_read_RDY/ADS_read_RDY.ino b/examples/ADS_read_RDY/ADS_read_RDY.ino index fa84eb6..7daf00b 100644 --- a/examples/ADS_read_RDY/ADS_read_RDY.ino +++ b/examples/ADS_read_RDY/ADS_read_RDY.ino @@ -19,10 +19,12 @@ // The RDY pin (or ALERT Pin) is triggered when conversion is ready // + #include "ADS1X15.h" ADS1115 ADS(0x48); + void setup() { Serial.begin(115200); @@ -43,6 +45,7 @@ void setup() ADS.setComparatorLatch(0); } + void loop() { ADS.setGain(0); @@ -59,4 +62,6 @@ void loop() delay(1000); } + // -- END OF FILE -- + diff --git a/examples/ADS_read_async/ADS_read_async.ino b/examples/ADS_read_async/ADS_read_async.ino index 174f919..abb8445 100644 --- a/examples/ADS_read_async/ADS_read_async.ino +++ b/examples/ADS_read_async/ADS_read_async.ino @@ -14,11 +14,13 @@ // measure at x (connect to AIN0). // + #include "ADS1X15.h" ADS1115 ADS(0x48); float f = 0; + void setup() { Serial.begin(115200); @@ -32,6 +34,7 @@ void setup() ADS.requestADC(0); } + void loop() { if (ADS.isBusy() == false) @@ -47,4 +50,6 @@ void loop() delay(2000); } + // -- END OF FILE -- + diff --git a/examples/ADS_read_async_rdy/ADS_read_async_rdy.ino b/examples/ADS_read_async_rdy/ADS_read_async_rdy.ino index 9b04081..847a1f1 100644 --- a/examples/ADS_read_async_rdy/ADS_read_async_rdy.ino +++ b/examples/ADS_read_async_rdy/ADS_read_async_rdy.ino @@ -19,11 +19,13 @@ // The RDY pin (or ALERT Pin) is triggered when conversion is ready // + #include "ADS1X15.h" ADS1115 ADS(0x48); float f = 0; + void setup() { Serial.begin(115200); @@ -44,6 +46,7 @@ void setup() ADS.setComparatorLatch(0); } + void loop() { if (ADS.isReady()) @@ -59,4 +62,6 @@ void loop() delay(2000); } + // -- END OF FILE -- + diff --git a/examples/ADS_read_comparator_1/ADS_read_comparator_1.ino b/examples/ADS_read_comparator_1/ADS_read_comparator_1.ino index e7315c1..d188bbb 100644 --- a/examples/ADS_read_comparator_1/ADS_read_comparator_1.ino +++ b/examples/ADS_read_comparator_1/ADS_read_comparator_1.ino @@ -25,6 +25,7 @@ ADS1115 ADS(0x48); + void setup() { Serial.begin(115200); @@ -55,9 +56,9 @@ void setup() Serial.println(ADS.getComparatorThresholdLow()); Serial.println(ADS.getComparatorThresholdHigh()); - } + void loop() { ADS.setGain(0); @@ -79,4 +80,6 @@ void loop() delay(100); } + // -- END OF FILE -- + diff --git a/examples/ADS_setWireClock/ADS_setWireClock.ino b/examples/ADS_setWireClock/ADS_setWireClock.ino index d2f0232..558a44a 100644 --- a/examples/ADS_setWireClock/ADS_setWireClock.ino +++ b/examples/ADS_setWireClock/ADS_setWireClock.ino @@ -14,10 +14,12 @@ // measure at x (connect to AIN0). // + #include "ADS1X15.h" ADS1115 ADS(0x48); + void setup() { Serial.begin(115200); @@ -39,6 +41,7 @@ void setup() Serial.println(); } + void loop() { ADS.setGain(0); @@ -59,4 +62,6 @@ void loop() delay(1000); } + // -- END OF FILE -- + diff --git a/keywords.txt b/keywords.txt index f9f6801..414a842 100644 --- a/keywords.txt +++ b/keywords.txt @@ -1,6 +1,6 @@ -# Syntax Coloring Map For ADS1X15 +# Syntax Colouring Map For ADS1X15 -# Datatypes (KEYWORD1) +# Data types (KEYWORD1) ADS1X13 KEYWORD1 ADS1014 KEYWORD1 ADS1015 KEYWORD1 @@ -61,6 +61,7 @@ requestADC_Differential_2_3 KEYWORD2 # Constants (LITERAL1) ADS1X15_LIB_VERSION LITERAL1 + ADS1X15_INVALID_VOLTAGE LITERAL1 ADS1X15_INVALID_GAIN LITERAL1 ADS1X15_INVALID_MODE LITERAL1 diff --git a/library.json b/library.json index 283be3a..8e881d5 100644 --- a/library.json +++ b/library.json @@ -15,9 +15,9 @@ "type": "git", "url": "https://github.com/RobTillaart/ADS1X15" }, - "version": "0.3.3", + "version": "0.3.4", "license": "MIT", "frameworks": "*", "platforms": "*", - "headers": "AD1x15.h" + "headers": "ADS1X15.h" } diff --git a/library.properties b/library.properties index 7d44a46..6c8bf29 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=ADS1X15 -version=0.3.3 +version=0.3.4 author=Rob Tillaart maintainer=Rob Tillaart sentence=Arduino library for ADS1015 - I2C 12 bit ADC and ADS1115 I2C 16 bit ADC diff --git a/test/unit_test_001.cpp b/test/unit_test_001.cpp index 0489204..5f0a395 100644 --- a/test/unit_test_001.cpp +++ b/test/unit_test_001.cpp @@ -29,10 +29,25 @@ unittest_setup() { } + unittest_teardown() { } + +unittest(test_constants) +{ + fprintf(stderr, "ADS1X15_LIB_VERSION: %s\n", (char *) ADS1X15_LIB_VERSION); + + assertEqual(0x48, ADS1015_ADDRESS); + assertEqual(0x48, ADS1115_ADDRESS); + assertEqual( 0, ADS1X15_OK); + assertEqual(-100, ADS1X15_INVALID_VOLTAGE); + assertEqual(0xFF, ADS1X15_INVALID_GAIN); + assertEqual(0xFE, ADS1X15_INVALID_MODE); +} + + unittest(test_begin) { ADS1115 ADS(0x48); @@ -41,6 +56,7 @@ unittest(test_begin) assertTrue(ADS.isBusy()); } + unittest(test_gain) { ADS1115 ADS(0x48); @@ -58,6 +74,7 @@ unittest(test_gain) assertEqual(0, ADS.getGain()); } + unittest(test_Voltage) { ADS1115 ADS(0x48); @@ -78,4 +95,5 @@ unittest(test_Voltage) unittest_main() + // --------