Skip to content

Commit 9d73315

Browse files
authored
Add files via upload
1 parent fe08755 commit 9d73315

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

src/ADS1115_WE.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,7 @@ void ADS1115_WE::reset(){
3131
bool ADS1115_WE::init(bool ads1015){
3232
useADS1015 = ads1015;
3333

34-
#ifndef USE_TINY_WIRE_M_
35-
_wire->beginTransmission(i2cAddress);
36-
uint8_t success = _wire->endTransmission();
37-
#else
38-
TinyWireM.beginTransmission(i2cAddress);
39-
uint8_t success = TinyWireM.endTransmission();
40-
#endif
41-
if(success){
34+
if(isDisconnected()){
4235
return 0;
4336
}
4437
writeRegister(ADS1115_CONFIG_REG, ADS1115_REG_RESET_VAL);
@@ -50,6 +43,17 @@ bool ADS1115_WE::init(bool ads1015){
5043
return 1;
5144
}
5245

46+
uint8_t ADS1115_WE::isDisconnected(){
47+
#ifndef USE_TINY_WIRE_M_
48+
_wire->beginTransmission(i2cAddress);
49+
uint8_t success = _wire->endTransmission();
50+
#else
51+
TinyWireM.beginTransmission(i2cAddress);
52+
uint8_t success = TinyWireM.endTransmission();
53+
#endif
54+
return success;
55+
}
56+
5357
void ADS1115_WE::setAlertPinMode(ADS1115_COMP_QUE mode){
5458
uint16_t currentConfReg = readRegister(ADS1115_CONFIG_REG);
5559
currentConfReg &= ~(0x8003);

src/ADS1115_WE.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ class ADS1115_WE
158158

159159
void reset();
160160
bool init(bool ads1015 = false);
161+
uint8_t isDisconnected();
161162

162163
/* Set number of conversions after which the alert pin will be active
163164
* - or you can disable the alert

0 commit comments

Comments
 (0)