@@ -454,7 +454,7 @@ void DallasTemperature::blockTillConversionComplete(uint8_t bitResolution) {
454
454
}
455
455
456
456
// 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) {
458
458
459
459
switch (bitResolution) {
460
460
case 9 :
@@ -469,6 +469,11 @@ int16_t DallasTemperature::millisToWaitForConversion(uint8_t bitResolution) {
469
469
470
470
}
471
471
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
+
472
477
// Sends command to one device to save values from scratchpad to EEPROM by index
473
478
// Returns true if no errors were encountered, false indicates failure
474
479
bool DallasTemperature::saveScratchPadByIndex (uint8_t deviceIndex) {
@@ -740,6 +745,19 @@ float DallasTemperature::rawToCelsius(int16_t raw) {
740
745
741
746
}
742
747
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
+
743
761
// convert from raw to Fahrenheit
744
762
float DallasTemperature::rawToFahrenheit (int16_t raw) {
745
763
0 commit comments