33
33
import math
34
34
from micropython import const
35
35
36
+ try :
37
+ # Used only for type annotations.
38
+ from busio import I2C
39
+ except ImportError :
40
+ pass
41
+
36
42
__version__ = "0.0.0-auto.0"
37
43
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_BME680.git"
38
44
@@ -437,7 +443,14 @@ class Adafruit_BME680_I2C(Adafruit_BME680):
437
443
438
444
"""
439
445
440
- def __init__ (self , i2c , address = 0x77 , debug = False , * , refresh_rate = 10 ):
446
+ def __init__ (
447
+ self ,
448
+ i2c : I2C ,
449
+ address : int = 0x77 ,
450
+ debug : bool = False ,
451
+ * ,
452
+ refresh_rate : int = 10
453
+ ) -> None :
441
454
"""Initialize the I2C device at the 'address' given"""
442
455
from adafruit_bus_device import ( # pylint: disable=import-outside-toplevel
443
456
i2c_device ,
@@ -447,7 +460,7 @@ def __init__(self, i2c, address=0x77, debug=False, *, refresh_rate=10):
447
460
self ._debug = debug
448
461
super ().__init__ (refresh_rate = refresh_rate )
449
462
450
- def _read (self , register , length ) :
463
+ def _read (self , register : int , length : int ) -> bytearray :
451
464
"""Returns an array of 'length' bytes from the 'register'"""
452
465
with self ._i2c as i2c :
453
466
i2c .write (bytes ([register & 0xFF ]))
@@ -457,7 +470,7 @@ def _read(self, register, length):
457
470
print ("\t $%02X => %s" % (register , [hex (i ) for i in result ]))
458
471
return result
459
472
460
- def _write (self , register , values ) :
473
+ def _write (self , register : int , values : int ) -> None :
461
474
"""Writes an array of 'length' bytes to the 'register'"""
462
475
with self ._i2c as i2c :
463
476
buffer = bytearray (2 * len (values ))
0 commit comments