brickOS Kernel Developer v0.9.0
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
53class TemperatureSensor : public Sensor {
54public:
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_
C++ Sensor Class Interface.
Basic sensor interface.
Definition Sensor.H:54
unsigned int get() const
Get the current sensor reading.
Definition Sensor.H:109
Port
List of sensor identifiers (IDs).
Definition Sensor.H:67
Temperature-sensor interface.
float C() const
Get the current temperature in Celsius.
~TemperatureSensor()
Destroy this instance of TemperatureSensor.
int degrees() const
Get the current temperature in C, as an int.
int tenths() const
Get the current temperature in C * 10, as an int.
TemperatureSensor(const Sensor::Port port)
Construct a temperature sensor.
float F() const
Get the current temperature in F.
kernel configuration file