26
26
27
27
import ustruct
28
28
29
- _REGISTER_TA = const (0x06 ) # ambient
30
- _REGISTER_TOBJ1 = const (0x07 ) # object
31
- _REGISTER_TOBJ2 = const (0x08 ) # object2
32
-
33
- class MLX90614 :
34
- def __init__ (self , i2c , address = 0x5a ):
35
- self .i2c = i2c
36
- self .address = address
37
- _config1 = i2c .readfrom_mem (address , 0x25 , 2 )
38
- _dz = ustruct .unpack ('<H' , _config1 )[0 ] & (1 << 6 )
39
- self .dual_zone = True if _dz else False
29
+ class SensorBase :
40
30
41
31
def read16 (self , register ):
42
32
data = self .i2c .readfrom_mem (self .address , register , 2 )
@@ -51,14 +41,14 @@ def read_temp(self, register):
51
41
return temp ;
52
42
53
43
def read_ambient_temp (self ):
54
- return self .read_temp (_REGISTER_TA )
44
+ return self .read_temp (self . _REGISTER_TA )
55
45
56
46
def read_object_temp (self ):
57
- return self .read_temp (_REGISTER_TOBJ1 )
47
+ return self .read_temp (self . _REGISTER_TOBJ1 )
58
48
59
49
def read_object2_temp (self ):
60
50
if self .dual_zone :
61
- return self .read_temp (_REGISTER_TOBJ2 )
51
+ return self .read_temp (self . _REGISTER_TOBJ2 )
62
52
else :
63
53
raise RuntimeError ("Device only has one thermopile" )
64
54
@@ -73,3 +63,26 @@ def object_temp(self):
73
63
@property
74
64
def object2_temp (self ):
75
65
return self .read_object2_temp ()
66
+
67
+ class MLX90614 (SensorBase ):
68
+
69
+ _REGISTER_TA = 0x06
70
+ _REGISTER_TOBJ1 = 0x07
71
+ _REGISTER_TOBJ2 = 0x08
72
+
73
+ def __init__ (self , i2c , address = 0x5a ):
74
+ self .i2c = i2c
75
+ self .address = address
76
+ _config1 = i2c .readfrom_mem (address , 0x25 , 2 )
77
+ _dz = ustruct .unpack ('<H' , _config1 )[0 ] & (1 << 6 )
78
+ self .dual_zone = True if _dz else False
79
+
80
+ class MLX90615 (SensorBase ):
81
+
82
+ _REGISTER_TA = 0x26
83
+ _REGISTER_TOBJ1 = 0x27
84
+
85
+ def __init__ (self , i2c , address = 0x5b ):
86
+ self .i2c = i2c
87
+ self .address = address
88
+ self .dual_zone = False
0 commit comments