23
23
**Notes:**
24
24
"""
25
25
26
- __version__ = "0.0.0-auto.0"
27
- __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_AMG88xx"
26
+ __version__ : str = "0.0.0-auto.0"
27
+ __repo__ : str = "https://github.com/adafruit/Adafruit_CircuitPython_AMG88xx"
28
28
29
29
from adafruit_bus_device .i2c_device import I2CDevice
30
30
from adafruit_register import i2c_bit , i2c_bits
31
+ from adafruit_register .i2c_bits import RWBits , ROBits
32
+ from adafruit_register .i2c_bit import RWBit , ROBit
31
33
from micropython import const
34
+ import busio
32
35
36
+ try :
37
+ from typing import List
38
+ except ImportError :
39
+ pass
33
40
34
41
# Registers are defined below in the class. These are possible register values.
35
42
36
43
# Operating Modes
37
- _NORMAL_MODE = const (0x00 )
38
- _SLEEP_MODE = const (0x10 )
39
- _STAND_BY_60 = const (0x20 )
40
- _STAND_BY_10 = const (0x21 )
44
+ _NORMAL_MODE : int = const (0x00 )
45
+ _SLEEP_MODE : int = const (0x10 )
46
+ _STAND_BY_60 : int = const (0x20 )
47
+ _STAND_BY_10 : int = const (0x21 )
41
48
42
49
# sw resets
43
- _FLAG_RESET = const (0x30 )
44
- _INITIAL_RESET = const (0x3F )
50
+ _FLAG_RESET : int = const (0x30 )
51
+ _INITIAL_RESET : int = const (0x3F )
45
52
46
53
# frame rates
47
- _FPS_10 = const (0x00 )
48
- _FPS_1 = const (0x01 )
54
+ _FPS_10 : int = const (0x00 )
55
+ _FPS_1 : int = const (0x01 )
49
56
50
57
# int enables
51
- _INT_DISABLED = const (0x00 )
52
- _INT_ENABLED = const (0x01 )
58
+ _INT_DISABLED : int = const (0x00 )
59
+ _INT_ENABLED : int = const (0x01 )
53
60
54
61
# int modes
55
- _DIFFERENCE = const (0x00 )
56
- _ABSOLUTE_VALUE = const (0x01 )
62
+ _DIFFERENCE : int = const (0x00 )
63
+ _ABSOLUTE_VALUE : int = const (0x01 )
57
64
58
- _INT_OFFSET = const (0x010 )
59
- _PIXEL_OFFSET = const (0x80 )
65
+ _INT_OFFSET : int = const (0x010 )
66
+ _PIXEL_OFFSET : int = const (0x80 )
60
67
61
- _PIXEL_ARRAY_WIDTH = const (8 )
62
- _PIXEL_ARRAY_HEIGHT = const (8 )
63
- _PIXEL_TEMP_CONVERSION = 0.25
64
- _THERMISTOR_CONVERSION = 0.0625
68
+ _PIXEL_ARRAY_WIDTH : int = const (8 )
69
+ _PIXEL_ARRAY_HEIGHT : int = const (8 )
70
+ _PIXEL_TEMP_CONVERSION : int = 0.25
71
+ _THERMISTOR_CONVERSION : int = 0.0625
65
72
66
73
67
- def _signed_12bit_to_float (val ) :
74
+ def _signed_12bit_to_float (val : int ) -> float :
68
75
# take first 11 bits as absolute val
69
76
abs_val = val & 0x7FF
70
77
if val & 0x800 :
71
78
return 0 - float (abs_val )
72
79
return float (abs_val )
73
80
74
81
75
- def _twos_comp_to_float (val ) :
82
+ def _twos_comp_to_float (val : int ) -> float :
76
83
val &= 0xFFF
77
84
if val & 0x800 :
78
85
val -= 0x1000
@@ -83,34 +90,34 @@ class AMG88XX:
83
90
"""Driver for the AMG88xx GRID-Eye IR 8x8 thermal camera."""
84
91
85
92
# Set up the registers
86
- _pctl = i2c_bits .RWBits (8 , 0x00 , 0 )
87
- _rst = i2c_bits .RWBits (8 , 0x01 , 0 )
88
- _fps = i2c_bit .RWBit (0x02 , 0 )
89
- _inten = i2c_bit .RWBit (0x03 , 0 )
90
- _intmod = i2c_bit .RWBit (0x03 , 1 )
93
+ _pctl : RWBits = i2c_bits .RWBits (8 , 0x00 , 0 )
94
+ _rst : RWBits = i2c_bits .RWBits (8 , 0x01 , 0 )
95
+ _fps : RWBit = i2c_bit .RWBit (0x02 , 0 )
96
+ _inten : RWBit = i2c_bit .RWBit (0x03 , 0 )
97
+ _intmod : RWBit = i2c_bit .RWBit (0x03 , 1 )
91
98
92
- _intf = i2c_bit .RWBit (0x04 , 1 )
93
- _ovf_irs = i2c_bit .RWBit (0x04 , 2 )
94
- _ovf_ths = i2c_bit .RWBit (0x04 , 3 )
99
+ _intf : RWBit = i2c_bit .RWBit (0x04 , 1 )
100
+ _ovf_irs : RWBit = i2c_bit .RWBit (0x04 , 2 )
101
+ _ovf_ths : RWBit = i2c_bit .RWBit (0x04 , 3 )
95
102
96
- _intclr = i2c_bit .RWBit (0x05 , 1 )
97
- _ovs_clr = i2c_bit .RWBit (0x05 , 2 )
98
- _ovt_clr = i2c_bit .RWBit (0x05 , 3 )
103
+ _intclr : RWBit = i2c_bit .RWBit (0x05 , 1 )
104
+ _ovs_clr : RWBit = i2c_bit .RWBit (0x05 , 2 )
105
+ _ovt_clr : RWBit = i2c_bit .RWBit (0x05 , 3 )
99
106
100
- _mamod = i2c_bit .RWBit (0x07 , 5 )
107
+ _mamod : RWBit = i2c_bit .RWBit (0x07 , 5 )
101
108
102
- _inthl = i2c_bits .RWBits (8 , 0x08 , 0 )
103
- _inthh = i2c_bits .RWBits (4 , 0x09 , 0 )
104
- _intll = i2c_bits .RWBits (8 , 0x0A , 0 )
105
- _intlh = i2c_bits .RWBits (4 , 0x0B , 0 )
106
- _ihysl = i2c_bits .RWBits (8 , 0x0C , 0 )
107
- _ihysh = i2c_bits .RWBits (4 , 0x0D , 0 )
109
+ _inthl : RWBits = i2c_bits .RWBits (8 , 0x08 , 0 )
110
+ _inthh : RWBits = i2c_bits .RWBits (4 , 0x09 , 0 )
111
+ _intll : RWBits = i2c_bits .RWBits (8 , 0x0A , 0 )
112
+ _intlh : RWBits = i2c_bits .RWBits (4 , 0x0B , 0 )
113
+ _ihysl : RWBits = i2c_bits .RWBits (8 , 0x0C , 0 )
114
+ _ihysh : RWBits = i2c_bits .RWBits (4 , 0x0D , 0 )
108
115
109
- _tthl = i2c_bits .RWBits (8 , 0x0E , 0 )
116
+ _tthl : RWBits = i2c_bits .RWBits (8 , 0x0E , 0 )
110
117
111
- _tthh = i2c_bits .RWBits (4 , 0x0F , 0 )
118
+ _tthh : RWBits = i2c_bits .RWBits (4 , 0x0F , 0 )
112
119
113
- def __init__ (self , i2c , addr = 0x69 ):
120
+ def __init__ (self , i2c : busio . I2C , addr : int = 0x69 ):
114
121
self .i2c_device = I2CDevice (i2c , addr )
115
122
116
123
# enter normal mode
@@ -126,13 +133,13 @@ def __init__(self, i2c, addr=0x69):
126
133
self ._fps = _FPS_10
127
134
128
135
@property
129
- def temperature (self ):
136
+ def temperature (self ) -> float :
130
137
"""Temperature of the sensor in Celsius"""
131
138
raw = (self ._tthh << 8 ) | self ._tthl
132
139
return _signed_12bit_to_float (raw ) * _THERMISTOR_CONVERSION
133
140
134
141
@property
135
- def pixels (self ):
142
+ def pixels (self ) -> List [ List [ float ]] :
136
143
"""Temperature of each pixel across the sensor in Celsius.
137
144
138
145
Temperatures are stored in a two dimensional list where the first index is the row and
0 commit comments