00001 00007 // 00008 // The contents of this file are subject to the Mozilla Public License 00009 // Version 1.0 (the "License"); you may not use this file except in 00010 // compliance with the License. You may obtain a copy of the License 00011 // at http://www.mozilla.org/MPL/ 00012 // 00013 // Software distributed under the License is distributed on an "AS IS" 00014 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 00015 // the License for the specific language governing rights and 00016 // limitations under the License. 00017 // 00018 // This software was developed as part of the legOS project. 00019 // 00020 // Contributor: Pat Welch (legOS@mousebrains.com) 00021 00022 #ifndef _TemperatureSensor_H_ 00023 #define _TemperatureSensor_H_ 00024 00025 #include <config.h> 00026 #include <c++/Sensor.H> 00027 00028 #if defined(CONF_DSENSOR) 00029 00053 class TemperatureSensor : public Sensor { 00054 public: 00062 TemperatureSensor(const Sensor::Port port) : Sensor(port, false) {} 00063 00067 ~TemperatureSensor() {} 00068 00074 float C() const { 00075 return 93.8136 - 0.122241 * static_cast<float>(get() >> 6); 00076 } 00077 00083 float F() const {return C() * 1.8 + 32;} 00084 00090 int tenths() const {return static_cast<int>(C() * 10.);} 00091 00097 int degrees() const {return static_cast<int>(C());} 00098 }; 00099 00100 #else // CONF_DSENSOR 00101 #warning Enable CONF_DSENSOR to use TemperatureSensor.H 00102 #endif // CONF_DSENSOR 00103 #endif // _TemperatureSensor_H_
brickOS is released under the
Mozilla Public License.
Original code copyright 1998-2002 by the authors. |