37
37
from adafruit_register .i2c_bits import RWBits
38
38
from adafruit_register .i2c_bit import RWBit , ROBit
39
39
40
+ try :
41
+ import typing # pylint: disable=unused-import
42
+ from busio import I2C
43
+ except ImportError :
44
+ pass
45
+
40
46
__version__ = "0.0.0+auto.0"
41
47
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_VEML7700.git"
42
48
@@ -185,7 +191,7 @@ class VEML7700:
185
191
light_interrupt_low = ROBit (0x06 , 15 , register_width = 2 )
186
192
"""Ambient light low threshold interrupt flag. Triggered when low threshold exceeded."""
187
193
188
- def __init__ (self , i2c_bus , address = 0x10 ):
194
+ def __init__ (self , i2c_bus : I2C , address : int = 0x10 ) -> None :
189
195
self .i2c_device = i2cdevice .I2CDevice (i2c_bus , address )
190
196
for _ in range (3 ):
191
197
try :
@@ -196,17 +202,17 @@ def __init__(self, i2c_bus, address=0x10):
196
202
else :
197
203
raise RuntimeError ("Unable to enable VEML7700 device" )
198
204
199
- def integration_time_value (self ):
205
+ def integration_time_value (self ) -> int :
200
206
"""Integration time value in integer form. Used for calculating :meth:`resolution`."""
201
207
integration_time = self .light_integration_time
202
208
return self .integration_time_values [integration_time ]
203
209
204
- def gain_value (self ):
210
+ def gain_value (self ) -> float :
205
211
"""Gain value in integer form. Used for calculating :meth:`resolution`."""
206
212
gain = self .light_gain
207
213
return self .gain_values [gain ]
208
214
209
- def resolution (self ):
215
+ def resolution (self ) -> float :
210
216
"""Calculate the :meth:`resolution`` necessary to calculate lux. Based on
211
217
integration time and gain settings."""
212
218
resolution_at_max = 0.0036
@@ -225,7 +231,7 @@ def resolution(self):
225
231
)
226
232
227
233
@property
228
- def lux (self ):
234
+ def lux (self ) -> float :
229
235
"""Light value in lux.
230
236
231
237
This example prints the light data in lux. Cover the sensor to see the values change.
0 commit comments