Fork of DS1820 that can function with the data and parasite power pin being the same.
Dependents: AutonomousDAQ AutonomousDAQ
Fork of DS1820 by
Diff: DS1820.h
- Revision:
- 6:c78fb487c397
- Parent:
- 5:00539fbc6d79
- Child:
- 7:aceafdd78b28
diff -r 00539fbc6d79 -r c78fb487c397 DS1820.h --- a/DS1820.h Mon Sep 22 00:21:07 2014 +0000 +++ b/DS1820.h Mon Sep 22 00:38:39 2014 +0000 @@ -248,6 +248,28 @@ */ bool read_power_supply(devices device=this_device); + /** Allow the parasite pin to be set at any time. If it is set + * to "NC", then parasite mode is turned off. It is ok if this + * pin is the same as the datapin. + * + * @param parasitePin The pin to use for parasite power, or NC for + * external power + * @returns true if the parasite power is set to a connected pin + * false if parasite power is not connected (external power) + */ + bool set_parasite_pin(DigitalInOut parasitePin) { + _parasitepin = parasitePin; + _parasite_power = (NC!=parasitePin); + return _parasite_power; + } + + /** Check if parasite power is being used. + * + * @returns true if using parasite power + * false if using external power + */ + bool is_on_parasite_power() const { return _parasite_power; } + private: bool _parasite_power; char CRC_byte (char CRC, char byte );