Sensor with Web Server
Dependencies: EthernetInterface mbed-rpc mbed-rtos mbed
OneWireThermometer.h@0:c385e589a779, 2014-04-08 (annotated)
- Committer:
- afilipem
- Date:
- Tue Apr 08 12:13:32 2014 +0000
- Revision:
- 0:c385e589a779
1 version;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
afilipem | 0:c385e589a779 | 1 | /* |
afilipem | 0:c385e589a779 | 2 | * OneWireThermometer. Base class for Maxim One-Wire Thermometers. |
afilipem | 0:c385e589a779 | 3 | * Uses the OneWireCRC library. |
afilipem | 0:c385e589a779 | 4 | * |
afilipem | 0:c385e589a779 | 5 | * Copyright (C) <2010> Petras Saduikis <petras@petras.co.uk> |
afilipem | 0:c385e589a779 | 6 | * |
afilipem | 0:c385e589a779 | 7 | * This file is part of OneWireThermometer. |
afilipem | 0:c385e589a779 | 8 | * |
afilipem | 0:c385e589a779 | 9 | * OneWireThermometer is free software: you can redistribute it and/or modify |
afilipem | 0:c385e589a779 | 10 | * it under the terms of the GNU General Public License as published by |
afilipem | 0:c385e589a779 | 11 | * the Free Software Foundation, either version 3 of the License, or |
afilipem | 0:c385e589a779 | 12 | * (at your option) any later version. |
afilipem | 0:c385e589a779 | 13 | * |
afilipem | 0:c385e589a779 | 14 | * OneWireThermometer is distributed in the hope that it will be useful, |
afilipem | 0:c385e589a779 | 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
afilipem | 0:c385e589a779 | 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
afilipem | 0:c385e589a779 | 17 | * GNU General Public License for more details. |
afilipem | 0:c385e589a779 | 18 | * |
afilipem | 0:c385e589a779 | 19 | * You should have received a copy of the GNU General Public License |
afilipem | 0:c385e589a779 | 20 | * along with OneWireThermometer. If not, see <http://www.gnu.org/licenses/>. |
afilipem | 0:c385e589a779 | 21 | */ |
afilipem | 0:c385e589a779 | 22 | |
afilipem | 0:c385e589a779 | 23 | #ifndef SNATCH59_ONEWIRETHERMOMETER_H |
afilipem | 0:c385e589a779 | 24 | #define SNATCH59_ONEWIRETHERMOMETER_H |
afilipem | 0:c385e589a779 | 25 | |
afilipem | 0:c385e589a779 | 26 | #include <mbed.h> |
afilipem | 0:c385e589a779 | 27 | #include "OneWireCRC.h" |
afilipem | 0:c385e589a779 | 28 | #include "OneWireDefs.h" |
afilipem | 0:c385e589a779 | 29 | |
afilipem | 0:c385e589a779 | 30 | typedef unsigned char BYTE; // something a byte wide |
afilipem | 0:c385e589a779 | 31 | |
afilipem | 0:c385e589a779 | 32 | class OneWireThermometer |
afilipem | 0:c385e589a779 | 33 | { |
afilipem | 0:c385e589a779 | 34 | public: |
afilipem | 0:c385e589a779 | 35 | OneWireThermometer(bool crcOn, bool useAddr, bool parasitic, PinName pin, int device_id); |
afilipem | 0:c385e589a779 | 36 | |
afilipem | 0:c385e589a779 | 37 | bool initialize(); |
afilipem | 0:c385e589a779 | 38 | float readTemperature(); |
afilipem | 0:c385e589a779 | 39 | virtual void setResolution(eResolution resln) = 0; |
afilipem | 0:c385e589a779 | 40 | |
afilipem | 0:c385e589a779 | 41 | protected: |
afilipem | 0:c385e589a779 | 42 | const bool useParasiticPower; |
afilipem | 0:c385e589a779 | 43 | const bool useCRC; |
afilipem | 0:c385e589a779 | 44 | const bool useAddress; |
afilipem | 0:c385e589a779 | 45 | const int deviceId; |
afilipem | 0:c385e589a779 | 46 | |
afilipem | 0:c385e589a779 | 47 | eResolution resolution; |
afilipem | 0:c385e589a779 | 48 | BYTE address[8]; |
afilipem | 0:c385e589a779 | 49 | |
afilipem | 0:c385e589a779 | 50 | OneWireCRC oneWire; |
afilipem | 0:c385e589a779 | 51 | |
afilipem | 0:c385e589a779 | 52 | void resetAndAddress(); |
afilipem | 0:c385e589a779 | 53 | bool readAndValidateData(BYTE* data); |
afilipem | 0:c385e589a779 | 54 | virtual float calculateTemperature(BYTE* data) = 0; // device specific |
afilipem | 0:c385e589a779 | 55 | }; |
afilipem | 0:c385e589a779 | 56 | |
afilipem | 0:c385e589a779 | 57 | #endif |