|
41 | 41 |
|
42 | 42 | from adafruit_bus_device import i2c_device
|
43 | 43 |
|
| 44 | +try: |
| 45 | + import typing # pylint: disable=unused-import |
| 46 | + from busio import I2C |
| 47 | +except ImportError: |
| 48 | + pass |
44 | 49 |
|
45 | 50 | # imports
|
46 | 51 |
|
@@ -104,28 +109,28 @@ class MLX90614:
|
104 | 109 |
|
105 | 110 | """
|
106 | 111 |
|
107 |
| - def __init__(self, i2c_bus, address=_MLX90614_I2CADDR): |
| 112 | + def __init__(self, i2c_bus: I2C, address: int = _MLX90614_I2CADDR) -> None: |
108 | 113 | self._device = i2c_device.I2CDevice(i2c_bus, address)
|
109 | 114 | self.buf = bytearray(2)
|
110 | 115 | self.buf[0] = _MLX90614_CONFIG
|
111 | 116 |
|
112 | 117 | @property
|
113 |
| - def ambient_temperature(self): |
| 118 | + def ambient_temperature(self) -> float: |
114 | 119 | """Ambient Temperature in Celsius."""
|
115 | 120 | return self._read_temp(_MLX90614_TA)
|
116 | 121 |
|
117 | 122 | @property
|
118 |
| - def object_temperature(self): |
| 123 | + def object_temperature(self) -> float: |
119 | 124 | """Object Temperature in Celsius."""
|
120 | 125 | return self._read_temp(_MLX90614_TOBJ1)
|
121 | 126 |
|
122 |
| - def _read_temp(self, register): |
| 127 | + def _read_temp(self, register: int) -> float: |
123 | 128 | temp = self._read_16(register)
|
124 | 129 | temp *= 0.02
|
125 | 130 | temp -= 273.15
|
126 | 131 | return temp
|
127 | 132 |
|
128 |
| - def _read_16(self, register): |
| 133 | + def _read_16(self, register: int) -> int: |
129 | 134 | # Read and return a 16-bit unsigned big endian value read from the
|
130 | 135 | # specified 16-bit register address.
|
131 | 136 | with self._device as i2c:
|
|
0 commit comments