Skip to content

Commit 0312d97

Browse files
authored
Merge pull request #15 from SebastienFauque/main
Add typing to I2C bus
2 parents 10bda58 + 4260b1d commit 0312d97

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

adafruit_monsterm4sk.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@
3939
from adafruit_st7789 import ST7789
4040
import adafruit_lis3dh
4141

42+
try:
43+
from typing import Optional, Dict, Union
44+
from busio import I2C
45+
except ImportError:
46+
pass
47+
4248
__version__ = "0.0.0+auto.0"
4349
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_MONSTERM4SK.git"
4450

@@ -62,7 +68,7 @@ class MonsterM4sk:
6268
The right screen is the one USB port directly above it.
6369
"""
6470

65-
def __init__(self, i2c=None):
71+
def __init__(self, i2c: Optional[I2C] = None):
6672
"""
6773
:param i2c: The I2C bus to use, will try board.I2C()
6874
if not supplied
@@ -150,7 +156,7 @@ def __init__(self, i2c=None):
150156
self.nose.threshold = 180
151157

152158
@property
153-
def acceleration(self):
159+
def acceleration(self) -> Union[float, None]:
154160
"""Accelerometer data, +/- 2G sensitivity.
155161
156162
This example initializes the mask and prints the accelerometer data.
@@ -169,7 +175,7 @@ def acceleration(self):
169175
)
170176

171177
@property
172-
def light(self):
178+
def light(self) -> int:
173179
"""Light sensor data.
174180
175181
This example initializes the mask and prints the light sensor data.
@@ -184,7 +190,7 @@ def light(self):
184190
return self._ss.analog_read(SS_LIGHTSENSOR_PIN)
185191

186192
@property
187-
def buttons(self):
193+
def buttons(self) -> Dict[str, bool]:
188194
"""Buttons dictionary.
189195
190196
This example initializes the mask and prints when the S9 button
@@ -208,7 +214,7 @@ def buttons(self):
208214
}
209215

210216
@property
211-
def boop(self):
217+
def boop(self) -> bool:
212218
"""Nose touch sense.
213219
214220
This example initializes the mask and prints when the nose touch pad

0 commit comments

Comments
 (0)