Skip to content

Add typing to I2C bus #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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