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