Skip to content

Commit

Permalink
Merge pull request #15 from SebastienFauque/main
Browse files Browse the repository at this point in the history
Add typing to I2C bus
  • Loading branch information
FoamyGuy authored Apr 28, 2023
2 parents 10bda58 + 4260b1d commit 0312d97
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions adafruit_monsterm4sk.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@
from adafruit_st7789 import ST7789
import adafruit_lis3dh

try:
from typing import Optional, Dict, Union
from busio import I2C
except ImportError:
pass

__version__ = "0.0.0+auto.0"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_MONSTERM4SK.git"

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

def __init__(self, i2c=None):
def __init__(self, i2c: Optional[I2C] = None):
"""
:param i2c: The I2C bus to use, will try board.I2C()
if not supplied
Expand Down Expand Up @@ -150,7 +156,7 @@ def __init__(self, i2c=None):
self.nose.threshold = 180

@property
def acceleration(self):
def acceleration(self) -> Union[float, None]:
"""Accelerometer data, +/- 2G sensitivity.
This example initializes the mask and prints the accelerometer data.
Expand All @@ -169,7 +175,7 @@ def acceleration(self):
)

@property
def light(self):
def light(self) -> int:
"""Light sensor data.
This example initializes the mask and prints the light sensor data.
Expand All @@ -184,7 +190,7 @@ def light(self):
return self._ss.analog_read(SS_LIGHTSENSOR_PIN)

@property
def buttons(self):
def buttons(self) -> Dict[str, bool]:
"""Buttons dictionary.
This example initializes the mask and prints when the S9 button
Expand All @@ -208,7 +214,7 @@ def buttons(self):
}

@property
def boop(self):
def boop(self) -> bool:
"""Nose touch sense.
This example initializes the mask and prints when the nose touch pad
Expand Down

0 comments on commit 0312d97

Please sign in to comment.