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