Yet Another WebIOPi+
Main Page
Related Pages
Packages
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Macros
Pages
python
webiopi
devices
sensor
tmpXXX.py
Go to the documentation of this file.
1
# Copyright 2012-2013 Eric Ptak - trouch.com
2
#
3
# Licensed under the Apache License, Version 2.0 (the "License");
4
# you may not use this file except in compliance with the License.
5
# You may obtain a copy of the License at
6
#
7
# http://www.apache.org/licenses/LICENSE-2.0
8
#
9
# Unless required by applicable law or agreed to in writing, software
10
# distributed under the License is distributed on an "AS IS" BASIS,
11
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
# See the License for the specific language governing permissions and
13
# limitations under the License.
14
15
from
webiopi.utils.types
import
toint, signInteger
16
from
webiopi.devices.i2c
import
I2C
17
from
webiopi.devices.sensor
import
Temperature
18
19
class
TMP102
(
I2C
,
Temperature
):
20
def
__init__
(self, slave=0x48):
21
I2C.__init__(self,
toint
(slave))
22
23
def
__str__
(self):
24
return
"TMP102(slave=0x%02X)"
% self.
slave
25
26
def
__getKelvin__
(self):
27
return
self.
Celsius2Kelvin
()
28
29
def
__getCelsius__
(self):
30
d = self.
readBytes
(2)
31
count = ((d[0] << 4) | (d[1] >> 4)) & 0xFFF
32
return
signInteger
(count, 12)*0.0625
33
34
def
__getFahrenheit__
(self):
35
return
self.
Celsius2Fahrenheit
()
36
37
class
TMP75
(
TMP102
):
38
def
__init__
(self, slave=0x48, resolution=12):
39
TMP102.__init__(self, slave)
40
resolution =
toint
(resolution)
41
if
not
resolution
in
range(9,13):
42
raise
ValueError(
"%dbits resolution out of range [%d..%d]bits"
% (resolution, 9, 12))
43
self.
resolution
= resolution
44
45
config = self.
readRegister
(0x01)
46
config &= ~0x60
47
config |= (self.
resolution
- 9) << 5
48
self.
writeRegister
(0x01, config)
49
self.
readRegisters
(0x00, 2)
50
51
def
__str__
(self):
52
return
"TMP75(slave=0x%02X, resolution=%d-bits)"
% (self.
slave
, self.
resolution
)
53
54
class
TMP275
(
TMP75
):
55
def
__init__
(self, slave=0x48, resolution=12):
56
TMP75.__init__(self, slave, resolution)
57
58
def
__str__
(self):
59
return
"TMP275(slave=0x%02X, resolution=%d-bits)"
% (self.
slave
, self.
resolution
)
60
webiopi.utils.types
Definition:
types.py:1
webiopi.devices.sensor.tmpXXX.TMP102.__getCelsius__
def __getCelsius__
Definition:
tmpXXX.py:29
webiopi.devices.sensor.tmpXXX.TMP75.__str__
def __str__
Definition:
tmpXXX.py:51
webiopi.devices.sensor.tmpXXX.TMP102
Definition:
tmpXXX.py:19
webiopi.devices.i2c.I2C.readRegisters
def readRegisters
Definition:
i2c.py:64
webiopi.devices.sensor.tmpXXX.TMP102.__init__
def __init__
Definition:
tmpXXX.py:20
webiopi.devices.sensor.Temperature
Definition:
__init__.py:65
webiopi.devices.i2c.I2C.readRegister
def readRegister
Definition:
i2c.py:60
webiopi.devices.i2c.I2C.slave
slave
Definition:
i2c.py:53
webiopi.devices.sensor.tmpXXX.TMP275.__init__
def __init__
Definition:
tmpXXX.py:55
webiopi.devices.sensor.Temperature.Celsius2Kelvin
def Celsius2Kelvin
Definition:
__init__.py:88
webiopi.devices.i2c.I2C.writeRegister
def writeRegister
Definition:
i2c.py:68
webiopi.devices.sensor.tmpXXX.TMP75
Definition:
tmpXXX.py:37
webiopi.devices.sensor.tmpXXX.TMP75.__init__
def __init__
Definition:
tmpXXX.py:38
webiopi.devices.i2c.I2C
Definition:
i2c.py:46
webiopi.devices.i2c
Definition:
i2c.py:1
webiopi.devices.sensor.tmpXXX.TMP102.__getFahrenheit__
def __getFahrenheit__
Definition:
tmpXXX.py:34
webiopi.devices.sensor.tmpXXX.TMP102.__str__
def __str__
Definition:
tmpXXX.py:23
webiopi.utils.types.signInteger
def signInteger
Definition:
types.py:27
webiopi.devices.sensor.tmpXXX.TMP275.__str__
def __str__
Definition:
tmpXXX.py:58
webiopi.devices.sensor.Temperature.Celsius2Fahrenheit
def Celsius2Fahrenheit
Definition:
__init__.py:93
webiopi.devices.sensor
Definition:
__init__.py:1
webiopi.devices.sensor.tmpXXX.TMP102.__getKelvin__
def __getKelvin__
Definition:
tmpXXX.py:26
webiopi.devices.sensor.tmpXXX.TMP75.resolution
resolution
Definition:
tmpXXX.py:43
webiopi.devices.sensor.tmpXXX.TMP275
Definition:
tmpXXX.py:54
webiopi.utils.types.toint
def toint
Definition:
types.py:16
webiopi.devices.bus.Bus.readBytes
def readBytes
Definition:
bus.py:101
Generated on Sat Sep 10 2016 09:37:12 for Yet Another WebIOPi+ by
1.8.8