diff --git a/CHANGELOG.md b/CHANGELOG.md index 6480184..bff8df1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,11 +6,15 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [0.3.3] - 2024-06-27 +- add connectCheck parameter to getTempC() +- update readme.md +- minor edits + ## [0.3.2] - 2024-01-03 - fix examples - minor edits - ## [0.3.1] - 2023-10-19 - update readme.md diff --git a/README.md b/README.md index 38efcac..3e6be5b 100644 --- a/README.md +++ b/README.md @@ -57,8 +57,9 @@ There will be a number of retries to connect, default 3. There will be a number of retries to connect, default 3. - **void requestTemperatures()** trigger temperature conversion. - **bool isConversionComplete()** check if conversion is complete. -- **int16_t getTempC()** returns temperature in whole degrees only. -55..125 -or -127 = DEVICE_DISCONNECTED +- **int16_t getTempC(bool connectCheck = true)** returns temperature in whole degrees only. +-55..125 or -127 = DEVICE_DISCONNECTED +Is faster when connectCheck is set to false. Default true = backwards compatible. - **bool getAddress()** returns true if the sensor is configured (available). diff --git a/examples/DS18B20_performance/DS18B20_performance.ino b/examples/DS18B20_performance/DS18B20_performance.ino index 0d049d4..fb4401a 100644 --- a/examples/DS18B20_performance/DS18B20_performance.ino +++ b/examples/DS18B20_performance/DS18B20_performance.ino @@ -97,6 +97,16 @@ void setup() Serial.println(stop - start); delay(10); + + start = micros(); + temp = sensor.getTempC(false); + stop = micros(); + Serial.print("\ngetTempC(false): \t"); + Serial.println(temp); + Serial.print("Time: \t"); + Serial.println(stop - start); + delay(10); + } diff --git a/library.json b/library.json index 80290e3..baf262f 100644 --- a/library.json +++ b/library.json @@ -23,7 +23,7 @@ "version": "^2.3.5" } ], - "version": "0.3.2", + "version": "0.3.3", "license": "MIT", "frameworks": "*", "platforms": "*", diff --git a/library.properties b/library.properties index 16c87b4..a55a8be 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=DS18B20_int -version=0.3.2 +version=0.3.3 author=Rob Tillaart maintainer=Rob Tillaart sentence=Library for DS18B20 restricted to a single sensor per pin. diff --git a/src/DS18B20_INT.cpp b/src/DS18B20_INT.cpp index cd818cb..b3cdb77 100644 --- a/src/DS18B20_INT.cpp +++ b/src/DS18B20_INT.cpp @@ -1,7 +1,7 @@ // // FILE: DS18B20_INT.cpp // AUTHOR: Rob.Tillaart -// VERSION: 0.3.2 +// VERSION: 0.3.3 // DATE: 2017-07-25 // PURPOSE: library for DS18B20 temperature sensor - integer only. // URL: https://github.com/RobTillaart/DS18B20_INT @@ -72,11 +72,14 @@ bool DS18B20_INT::isConversionComplete(void) } -int16_t DS18B20_INT::getTempC(void) +int16_t DS18B20_INT::getTempC(bool connectCheck) { - if (isConnected(3) == false) + if (connectCheck) { - return DEVICE_DISCONNECTED; + if (isConnected(3) == false) + { + return DEVICE_DISCONNECTED; + } } int16_t rawTemperature = _readRaw(); rawTemperature >>= 4; diff --git a/src/DS18B20_INT.h b/src/DS18B20_INT.h index f7ae647..e0117d5 100644 --- a/src/DS18B20_INT.h +++ b/src/DS18B20_INT.h @@ -2,7 +2,7 @@ // // FILE: DS18B20_INT.h // AUTHOR: Rob.Tillaart -// VERSION: 0.3.2 +// VERSION: 0.3.3 // DATE: 2017-07-25 // PURPOSE: Minimalistic library for DS18B20 temperature sensor // uses only integer math (no float to minimize footprint) @@ -25,7 +25,7 @@ #include "OneWire.h" -#define DS18B20_INT_LIB_VERSION (F("0.3.2")) +#define DS18B20_INT_LIB_VERSION (F("0.3.3")) // Error Code #define DEVICE_DISCONNECTED -127 @@ -42,7 +42,7 @@ class DS18B20_INT bool isConnected(uint8_t retries = 3); void requestTemperatures(void); - int16_t getTempC(void); + int16_t getTempC(bool connectCheck = true); bool isConversionComplete(void); bool getAddress(uint8_t* buf);