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 16:0764e4de41d2, committed 2018-04-30
- Comitter:
- lucian@Lucians-MacBook-Pro.local
- Date:
- Mon Apr 30 14:40:29 2018 +0300
- Parent:
- 15:8b82d53770df
- Child:
- 17:325cd3a6cbbb
- Commit message:
- IEM-396 Add DS18B20 sensor lib & unit tests
Changed in this revision
| DS1820.cpp | Show annotated file Show diff for this revision Revisions of this file |
| DS1820.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/DS1820.cpp Sat Apr 28 19:26:09 2018 +0300
+++ b/DS1820.cpp Mon Apr 30 14:40:29 2018 +0300
@@ -193,7 +193,7 @@
*/
uint8_t DS1820::read(float &temp) {
uint16_t temp_uint16 = 0;
- uint8_t result = read_uint16(temp_uint16);
+ uint8_t result = readRaw(temp_uint16);
bool temp_available = 0 == result;
if (temp_available) {
@@ -215,7 +215,7 @@
* 1 - sensor not present ('temp' is not updated)
* 2 - CRC error ('temp' is not updated)
*/
-uint8_t DS1820::read_uint16(uint16_t &temp) {
+uint8_t DS1820::readRaw(uint16_t &temp) {
if (present) {
oneWire.reset();
oneWire.skip();
--- a/DS1820.h Sat Apr 28 19:26:09 2018 +0300
+++ b/DS1820.h Mon Apr 30 14:40:29 2018 +0300
@@ -13,8 +13,6 @@
uint8_t data[12];
uint8_t addr[8];
- float toFloat(uint16_t word);
-
public:
DS1820(PinName pin);
@@ -27,11 +25,14 @@
void setResolution(uint8_t res);
- void startConversion(void);
+ virtual void startConversion(void);
- uint8_t read_uint16(uint16_t &temp);
+ virtual uint8_t readRaw(uint16_t &temp);
uint8_t read(float &temp);
+
+protected:
+ float toFloat(uint16_t word);
};
#endif /* DS1820_H_ */
