@@ -454,7 +454,7 @@ void DallasTemperature::blockTillConversionComplete(uint8_t bitResolution) {
454454}
455455
456456// returns number of milliseconds to wait till conversion is complete (based on IC datasheet)
457- int16_t DallasTemperature::millisToWaitForConversion (uint8_t bitResolution) {
457+ uint16_t DallasTemperature::millisToWaitForConversion (uint8_t bitResolution) {
458458
459459 switch (bitResolution) {
460460 case 9 :
@@ -469,6 +469,11 @@ int16_t DallasTemperature::millisToWaitForConversion(uint8_t bitResolution) {
469469
470470}
471471
472+ // returns number of milliseconds to wait till conversion is complete (based on IC datasheet)
473+ uint16_t DallasTemperature::millisToWaitForConversion () {
474+ return millisToWaitForConversion (bitResolution);
475+ }
476+
472477// Sends command to one device to save values from scratchpad to EEPROM by index
473478// Returns true if no errors were encountered, false indicates failure
474479bool DallasTemperature::saveScratchPadByIndex (uint8_t deviceIndex) {
@@ -740,6 +745,19 @@ float DallasTemperature::rawToCelsius(int16_t raw) {
740745
741746}
742747
748+ // Convert from Celsius to raw returns temperature in raw integer format.
749+ // The rounding error in the conversion is smaller than 0.01°C
750+ // where the resolution of the sensor is at best 0.0625°C (in 12 bit mode).
751+ // Rounding error can be verified by running:
752+ // for (float t=-55.; t<125.; t+=0.01)
753+ // {
754+ // Serial.println( DallasTemperature::rawToCelsius(DallasTemperature::celsiusToRaw(t))-t, 4 );
755+ // }
756+ int16_t DallasTemperature::celsiusToRaw (float celsius) {
757+
758+ return static_cast <uint16_t >( celsius * 128 .f );
759+ }
760+
743761// convert from raw to Fahrenheit
744762float DallasTemperature::rawToFahrenheit (int16_t raw) {
745763
0 commit comments