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