Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of DS1820 by
Revision 10:d297ce9ce422, committed 2015-01-30
- Comitter:
- florian
- Date:
- Fri Jan 30 11:07:10 2015 +0000
- Parent:
- 9:3821ca0b7f14
- Commit message:
- correction of bugs compared to original library.; _Unitialized variable; _Wrong reading of temperature (when subdegree precision is required)
Changed in this revision
| DS1820.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 3821ca0b7f14 -r d297ce9ce422 DS1820.cpp
--- a/DS1820.cpp Thu Jan 29 19:27:32 2015 +0000
+++ b/DS1820.cpp Fri Jan 30 11:07:10 2015 +0000
@@ -361,18 +361,16 @@
}
answer = reading +0.0; // convert to floating point
if ((FAMILY_CODE == FAMILY_CODE_DS18B20 ) || (FAMILY_CODE == FAMILY_CODE_DS1822 )) {
- answer = answer / 8.0;
+ answer = answer / 16.0;
}
else {
remaining_count = RAM[6];
count_per_degree = RAM[7];
- answer = answer - 0.25 + (count_per_degree - remaining_count) / count_per_degree;
+ answer = floor(answer/2.0) - 0.25 + (count_per_degree - remaining_count) / count_per_degree;
}
- if (scale=='C' or scale=='c')
- answer = answer / 2.0;
- else
+ if (scale=='F' or scale=='f')
// Convert to deg F
- answer = answer * 9.0 / 10.0 + 32.0;
+ answer = answer * 9.0 / 5.0 + 32.0;
}
return answer;
}
