File tree Expand file tree Collapse file tree 2 files changed +13
-8
lines changed
Expand file tree Collapse file tree 2 files changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -31,14 +31,7 @@ void ADS1115_WE::reset(){
3131bool 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+
5357void ADS1115_WE::setAlertPinMode (ADS1115_COMP_QUE mode){
5458 uint16_t currentConfReg = readRegister (ADS1115_CONFIG_REG);
5559 currentConfReg &= ~(0x8003 );
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments