Skip to content

Commit c4e76a5

Browse files
authored
Merge pull request #261 from 1-hexene/master
Revert commit cced10d
2 parents cced10d + 71db0ff commit c4e76a5

File tree

2 files changed

+17
-22
lines changed

2 files changed

+17
-22
lines changed

DallasTemperature.cpp

+15-20
Original file line numberDiff line numberDiff line change
@@ -152,19 +152,19 @@ bool DallasTemperature::validAddress(const uint8_t* deviceAddress) {
152152
// finds an address at a given index on the bus
153153
// returns true if the device was found
154154
bool DallasTemperature::getAddress(uint8_t* deviceAddress, uint8_t index) {
155-
if (index < devices) {
156-
uint8_t depth = 0;
157155

158-
_wire->reset_search();
156+
uint8_t depth = 0;
159157

160-
while (depth <= index && _wire->search(deviceAddress)) {
161-
if (depth == index && validAddress(deviceAddress))
162-
return true;
163-
depth++;
164-
}
158+
_wire->reset_search();
159+
160+
while (depth <= index && _wire->search(deviceAddress)) {
161+
if (depth == index && validAddress(deviceAddress))
162+
return true;
163+
depth++;
165164
}
166165

167166
return false;
167+
168168
}
169169

170170
// attempt to determine if the device at the given address is connected to the bus
@@ -723,27 +723,22 @@ int32_t DallasTemperature::calculateTemperature(const uint8_t* deviceAddress,
723723
// the numeric value of DEVICE_DISCONNECTED_RAW is defined in
724724
// DallasTemperature.h. It is a large negative number outside the
725725
// operating range of the device
726-
int32_t DallasTemperature::getTemp(const uint8_t* deviceAddress, byte retryCount = 0) {
726+
int32_t DallasTemperature::getTemp(const uint8_t* deviceAddress) {
727727

728728
ScratchPad scratchPad;
729-
730-
byte retries = 0;
731-
732-
while (retries++ <= retryCount) {
733-
if (isConnected(deviceAddress, scratchPad))
734-
return calculateTemperature(deviceAddress, scratchPad);
735-
}
736-
737-
return DEVICE_DISCONNECTED_RAW;
729+
if (isConnected(deviceAddress, scratchPad))
730+
return calculateTemperature(deviceAddress, scratchPad);
731+
return DEVICE_DISCONNECTED_RAW;
732+
738733
}
739734

740735
// returns temperature in degrees C or DEVICE_DISCONNECTED_C if the
741736
// device's scratch pad cannot be read successfully.
742737
// the numeric value of DEVICE_DISCONNECTED_C is defined in
743738
// DallasTemperature.h. It is a large negative number outside the
744739
// operating range of the device
745-
float DallasTemperature::getTempC(const uint8_t* deviceAddress, byte retryCount = 0) {
746-
return rawToCelsius(getTemp(deviceAddress, retryCount));
740+
float DallasTemperature::getTempC(const uint8_t* deviceAddress) {
741+
return rawToCelsius(getTemp(deviceAddress));
747742
}
748743

749744
// returns temperature in degrees F or DEVICE_DISCONNECTED_F if the

DallasTemperature.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,10 @@ class DallasTemperature {
159159
request_t requestTemperaturesByIndex(uint8_t);
160160

161161
// returns temperature raw value (12 bit integer of 1/128 degrees C)
162-
int32_t getTemp(const uint8_t*, byte retryCount = 0);
162+
int32_t getTemp(const uint8_t*);
163163

164164
// returns temperature in degrees C
165-
float getTempC(const uint8_t*, byte retryCount = 0);
165+
float getTempC(const uint8_t*);
166166

167167
// returns temperature in degrees F
168168
float getTempF(const uint8_t*);

0 commit comments

Comments
 (0)