Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: DallasTemperature project1
OneWireThermometer.h
00001 /* 00002 * OneWireThermometer. Base class for Maxim One-Wire Thermometers. 00003 * Uses the OneWireCRC library. 00004 * 00005 * Copyright (C) <2010> Petras Saduikis <petras@petras.co.uk> 00006 * 00007 * This file is part of OneWireThermometer. 00008 * 00009 * OneWireThermometer is free software: you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation, either version 3 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * OneWireThermometer is distributed in the hope that it will be useful, 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 * GNU General Public License for more details. 00018 * 00019 * You should have received a copy of the GNU General Public License 00020 * along with OneWireThermometer. If not, see <http://www.gnu.org/licenses/>. 00021 */ 00022 00023 #ifndef SNATCH59_ONEWIRETHERMOMETER_H 00024 #define SNATCH59_ONEWIRETHERMOMETER_H 00025 00026 #include "mbed.h" 00027 #include "OneWireCRC.h" 00028 #include "OneWireDefs.h" 00029 00030 typedef unsigned char BYTE; // something a byte wide 00031 00032 class OneWireThermometer { 00033 public: 00034 OneWireThermometer(PinName pin, bool crcOn, bool useAddr, bool parasitic, int device_id, unsigned char *Address ); 00035 00036 bool initialize(); 00037 float readTemperature(); 00038 virtual void setResolution(eResolution resln) = 0; 00039 00040 protected: 00041 bool _useParasiticPower; 00042 bool _useCRC; 00043 bool _useAddress; 00044 int _deviceId; 00045 00046 eResolution _resolution; 00047 BYTE _ROMCode[8]; 00048 00049 00050 OneWireCRC oneWire; 00051 00052 void resetAndAddress(); 00053 bool readAndValidateData(BYTE* data); 00054 virtual float calculateTemperature(BYTE* data) = 0; // device specific 00055 }; 00056 00057 #endif
Generated on Fri Jul 22 2022 03:20:41 by
1.7.2