diff --git a/.gitignore b/.gitignore index c30b111..75c20ac 100644 --- a/.gitignore +++ b/.gitignore @@ -13,4 +13,4 @@ build .classpath .settings .gradle - +.vscode diff --git a/DallasTemperature.cpp b/DallasTemperature.cpp index c8e0b1e..ca81a82 100644 --- a/DallasTemperature.cpp +++ b/DallasTemperature.cpp @@ -155,7 +155,6 @@ void DallasTemperature::writeScratchPad(const uint8_t* deviceAddress, const uint if (deviceAddress[0] != DS18S20MODEL) _wire->write(scratchPad[CONFIGURATION]); _wire->reset(); - _wire->select(deviceAddress); // save the newly written values to eeprom _wire->select(deviceAddress); @@ -189,14 +188,20 @@ void DallasTemperature::setResolution(uint8_t newResolution){ for (int i=0; i newResolution)){ + bitResolution = newResolution; + DeviceAddress deviceAddr; + for (int i=0; i 125) celsius = 125; else if (celsius < -55) celsius = -55; @@ -610,6 +634,10 @@ void DallasTemperature::setHighAlarmTemp(const uint8_t* deviceAddress, char cels // accepts a float, but the alarm resolution will ignore anything // after a decimal point. valid range is -55C - 125C void DallasTemperature::setLowAlarmTemp(const uint8_t* deviceAddress, char celsius){ + + // return when stored value == new value + if(getLowAlarmTemp(deviceAddress) == celsius) return; + // make sure the alarm temperature is within the device's range if (celsius > 125) celsius = 125; else if (celsius < -55) celsius = -55; @@ -803,4 +831,4 @@ void DallasTemperature::operator delete(void* p){ free(p); // Free the memory } -#endif +#endif \ No newline at end of file diff --git a/DallasTemperature.h b/DallasTemperature.h index f14c4ef..4d6745f 100644 --- a/DallasTemperature.h +++ b/DallasTemperature.h @@ -110,7 +110,7 @@ class DallasTemperature uint8_t getResolution(const uint8_t*); // set resolution of a device to 9, 10, 11, or 12 bits - bool setResolution(const uint8_t*, uint8_t); + bool setResolution(const uint8_t*, uint8_t, bool skipGlobalBitResolutionCalculation = false); // sets/gets the waitForConversion flag void setWaitForConversion(bool); @@ -269,4 +269,4 @@ class DallasTemperature #endif }; -#endif +#endif \ No newline at end of file