Skip to content

Commit 4924e2b

Browse files
authored
Merge pull request #248 from cjoach/no-shadow
Remove shadowing by making use of more explicit names
2 parents e3c7276 + e3827fb commit 4924e2b

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

DallasTemperature.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ void DallasTemperature::setOneWire(OneWire* _oneWire) {
101101
devices = 0;
102102
ds18Count = 0;
103103
parasite = false;
104-
bitResolution = 9;
104+
globalBitResolution = 9;
105105
waitForConversion = true;
106106
checkForConversion = true;
107107
autoSaveScratchPad = true;
@@ -129,7 +129,7 @@ void DallasTemperature::begin(void) {
129129
parasite = true;
130130

131131
uint8_t b = getResolution(deviceAddress);
132-
if (b > bitResolution) bitResolution = b;
132+
if (b > globalBitResolution) globalBitResolution = b;
133133
}
134134
}
135135
}
@@ -259,12 +259,12 @@ bool DallasTemperature::readPowerSupply(const uint8_t* deviceAddress)
259259
// if new resolution is out of range, it is constrained.
260260
void DallasTemperature::setResolution(uint8_t newResolution) {
261261

262-
bitResolution = constrain(newResolution, 9, 12);
262+
globalBitResolution = constrain(newResolution, 9, 12);
263263
DeviceAddress deviceAddress;
264264
_wire->reset_search();
265265
for (uint8_t i = 0; i < devices; i++) {
266266
if(_wire->search(deviceAddress) && validAddress(deviceAddress)) {
267-
setResolution(deviceAddress, bitResolution, true);
267+
setResolution(deviceAddress, globalBitResolution, true);
268268
}
269269
}
270270
}
@@ -325,15 +325,15 @@ bool DallasTemperature::setResolution(const uint8_t* deviceAddress,
325325

326326
// do we need to update the max resolution used?
327327
if (skipGlobalBitResolutionCalculation == false) {
328-
bitResolution = newResolution;
328+
globalBitResolution = newResolution;
329329
if (devices > 1) {
330330
DeviceAddress deviceAddr;
331331
_wire->reset_search();
332332
for (uint8_t i = 0; i < devices; i++) {
333-
if (bitResolution == 12) break;
333+
if (globalBitResolution == 12) break;
334334
if (_wire->search(deviceAddr) && validAddress(deviceAddr)) {
335335
uint8_t b = getResolution(deviceAddr);
336-
if (b > bitResolution) bitResolution = b;
336+
if (b > globalBitResolution) globalBitResolution = b;
337337
}
338338
}
339339
}
@@ -345,7 +345,7 @@ bool DallasTemperature::setResolution(const uint8_t* deviceAddress,
345345

346346
// returns the global resolution
347347
uint8_t DallasTemperature::getResolution() {
348-
return bitResolution;
348+
return globalBitResolution;
349349
}
350350

351351
// returns the current resolution of the device, 9-12
@@ -426,7 +426,7 @@ DallasTemperature::request_t DallasTemperature::requestTemperatures() {
426426
req.timestamp = millis();
427427
if (!waitForConversion)
428428
return req;
429-
blockTillConversionComplete(bitResolution, req.timestamp);
429+
blockTillConversionComplete(globalBitResolution, req.timestamp);
430430
return req;
431431
}
432432

@@ -435,8 +435,8 @@ DallasTemperature::request_t DallasTemperature::requestTemperatures() {
435435
// returns TRUE otherwise
436436
DallasTemperature::request_t DallasTemperature::requestTemperaturesByAddress(const uint8_t* deviceAddress) {
437437
DallasTemperature::request_t req = {};
438-
uint8_t bitResolution = getResolution(deviceAddress);
439-
if (bitResolution == 0) {
438+
uint8_t deviceBitResolution = getResolution(deviceAddress);
439+
if (deviceBitResolution == 0) {
440440
req.result = false;
441441
return req; //Device disconnected
442442
}
@@ -451,7 +451,7 @@ DallasTemperature::request_t DallasTemperature::requestTemperaturesByAddress(con
451451
if (!waitForConversion)
452452
return req;
453453

454-
blockTillConversionComplete(bitResolution, req.timestamp);
454+
blockTillConversionComplete(deviceBitResolution, req.timestamp);
455455

456456
return req;
457457

@@ -501,7 +501,7 @@ uint16_t DallasTemperature::millisToWaitForConversion(uint8_t bitResolution) {
501501

502502
// returns number of milliseconds to wait till conversion is complete (based on IC datasheet)
503503
uint16_t DallasTemperature::millisToWaitForConversion() {
504-
return millisToWaitForConversion(bitResolution);
504+
return millisToWaitForConversion(globalBitResolution);
505505
}
506506

507507
// Sends command to one device to save values from scratchpad to EEPROM by index

DallasTemperature.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ class DallasTemperature {
299299

300300
// used to determine the delay amount needed to allow for the
301301
// temperature conversion to take place
302-
uint8_t bitResolution;
302+
uint8_t globalBitResolution;
303303

304304
// used to requestTemperature with or without delay
305305
bool waitForConversion;

0 commit comments

Comments
 (0)