TemperatureSensor.H
Go to the documentation of this file.
1 
7 //
8 // The contents of this file are subject to the Mozilla Public License
9 // Version 1.0 (the "License"); you may not use this file except in
10 // compliance with the License. You may obtain a copy of the License
11 // at http://www.mozilla.org/MPL/
12 //
13 // Software distributed under the License is distributed on an "AS IS"
14 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
15 // the License for the specific language governing rights and
16 // limitations under the License.
17 //
18 // This software was developed as part of the legOS project.
19 //
20 // Contributor: Pat Welch (legOS@mousebrains.com)
21 
22 #ifndef _TemperatureSensor_H_
23 #define _TemperatureSensor_H_
24 
25 #include <config.h>
26 #include <c++/Sensor.H>
27 
28 #if defined(CONF_DSENSOR)
29 
53 class TemperatureSensor : public Sensor {
54 public:
62  TemperatureSensor(const Sensor::Port port) : Sensor(port, false) {}
63 
68 
74  float C() const {
75  return 93.8136 - 0.122241 * static_cast<float>(get() >> 6);
76  }
77 
83  float F() const {return C() * 1.8 + 32;}
84 
90  int tenths() const {return static_cast<int>(C() * 10.);}
91 
97  int degrees() const {return static_cast<int>(C());}
98 };
99 
100 #else // CONF_DSENSOR
101 #warning Enable CONF_DSENSOR to use TemperatureSensor.H
102 #endif // CONF_DSENSOR
103 #endif // _TemperatureSensor_H_
TemperatureSensor
Definition: TemperatureSensor.H:53
Sensor
Definition: Sensor.H:54
TemperatureSensor::TemperatureSensor
TemperatureSensor(const Sensor::Port port)
Construct a temperature sensor.
Definition: TemperatureSensor.H:62
TemperatureSensor::tenths
int tenths() const
Get the current temperature in C * 10, as an int.
Definition: TemperatureSensor.H:90
TemperatureSensor::degrees
int degrees() const
Get the current temperature in C, as an int.
Definition: TemperatureSensor.H:97
TemperatureSensor::F
float F() const
Get the current temperature in F.
Definition: TemperatureSensor.H:83
TemperatureSensor::~TemperatureSensor
~TemperatureSensor()
Destroy this instance of TemperatureSensor.
Definition: TemperatureSensor.H:67
Sensor.H
C++ Sensor Class Interface.
Sensor::get
unsigned int get() const
Get the current sensor reading.
Definition: Sensor.H:109
Sensor::Port
Port
List of sensor identifiers (IDs).
Definition: Sensor.H:67
TemperatureSensor::C
float C() const
Get the current temperature in Celsius.
Definition: TemperatureSensor.H:74

brickOS is released under the Mozilla Public License.
Original code copyright 1998-2005 by the authors.

Generated for brickOS C++ by doxygen 1.8.16