From 336721a061edb72b2bb3aad30c9cb9323d991cae Mon Sep 17 00:00:00 2001 From: Sebastien Fauque Date: Tue, 25 Apr 2023 12:22:11 -0600 Subject: [PATCH 1/6] Add typing to I2C bus --- adafruit_monsterm4sk.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/adafruit_monsterm4sk.py b/adafruit_monsterm4sk.py index bb044bb..bd7dc9a 100644 --- a/adafruit_monsterm4sk.py +++ b/adafruit_monsterm4sk.py @@ -39,6 +39,11 @@ from adafruit_st7789 import ST7789 import adafruit_lis3dh +try: + from circuitpython_typing.device_drivers import I2CDeviceDriver +except ImportError: + pass + __version__ = "0.0.0+auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_MONSTERM4SK.git" From 98785423ec99588dbc33da47f700b760cc3bc5ac Mon Sep 17 00:00:00 2001 From: Sebastien Fauque Date: Tue, 25 Apr 2023 12:36:54 -0600 Subject: [PATCH 2/6] add typing to I2C bus --- adafruit_monsterm4sk.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_monsterm4sk.py b/adafruit_monsterm4sk.py index bd7dc9a..7923b7c 100644 --- a/adafruit_monsterm4sk.py +++ b/adafruit_monsterm4sk.py @@ -67,7 +67,7 @@ class MonsterM4sk: The right screen is the one USB port directly above it. """ - def __init__(self, i2c=None): + def __init__(self, i2c: I2CDeviceDriver=None): """ :param i2c: The I2C bus to use, will try board.I2C() if not supplied From 5a59d9b777b9f08591d74d4043d18676b0fd961c Mon Sep 17 00:00:00 2001 From: Sebastien Fauque Date: Tue, 25 Apr 2023 12:40:17 -0600 Subject: [PATCH 3/6] ran black on I2C bus changes --- adafruit_monsterm4sk.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_monsterm4sk.py b/adafruit_monsterm4sk.py index 7923b7c..63be31f 100644 --- a/adafruit_monsterm4sk.py +++ b/adafruit_monsterm4sk.py @@ -67,7 +67,7 @@ class MonsterM4sk: The right screen is the one USB port directly above it. """ - def __init__(self, i2c: I2CDeviceDriver=None): + def __init__(self, i2c: I2CDeviceDriver = None): """ :param i2c: The I2C bus to use, will try board.I2C() if not supplied From e72e6ecb84052253016e5aee3dfa1064d82fd8b5 Mon Sep 17 00:00:00 2001 From: Sebastien Fauque Date: Tue, 25 Apr 2023 16:11:16 -0600 Subject: [PATCH 4/6] adding optional tag b/c of default type --- adafruit_monsterm4sk.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/adafruit_monsterm4sk.py b/adafruit_monsterm4sk.py index 63be31f..d0d3fc5 100644 --- a/adafruit_monsterm4sk.py +++ b/adafruit_monsterm4sk.py @@ -41,6 +41,7 @@ try: from circuitpython_typing.device_drivers import I2CDeviceDriver + from typing import Optional except ImportError: pass @@ -67,7 +68,7 @@ class MonsterM4sk: The right screen is the one USB port directly above it. """ - def __init__(self, i2c: I2CDeviceDriver = None): + def __init__(self, i2c: Optional[I2CDeviceDriver] = None): """ :param i2c: The I2C bus to use, will try board.I2C() if not supplied From e57910635fb8570fdd054c28fd530ed1ffe565c5 Mon Sep 17 00:00:00 2001 From: Sebastien Fauque Date: Wed, 26 Apr 2023 21:44:44 -0700 Subject: [PATCH 5/6] changed to I2C type and added acceleration, light, buttons, and boop type. --- adafruit_monsterm4sk.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/adafruit_monsterm4sk.py b/adafruit_monsterm4sk.py index d0d3fc5..944a5bd 100644 --- a/adafruit_monsterm4sk.py +++ b/adafruit_monsterm4sk.py @@ -40,8 +40,8 @@ import adafruit_lis3dh try: - from circuitpython_typing.device_drivers import I2CDeviceDriver - from typing import Optional + from busio import I2C + from typing import Optional, Dict, Union except ImportError: pass @@ -68,7 +68,7 @@ class MonsterM4sk: The right screen is the one USB port directly above it. """ - def __init__(self, i2c: Optional[I2CDeviceDriver] = None): + def __init__(self, i2c: Optional[I2C] = None): """ :param i2c: The I2C bus to use, will try board.I2C() if not supplied @@ -156,7 +156,7 @@ def __init__(self, i2c: Optional[I2CDeviceDriver] = 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. @@ -175,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. @@ -190,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 @@ -214,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 From 4260b1db1668384fa4e0dd190a4220595b830a50 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Thu, 27 Apr 2023 19:48:11 -0500 Subject: [PATCH 6/6] typing import first --- adafruit_monsterm4sk.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_monsterm4sk.py b/adafruit_monsterm4sk.py index 944a5bd..b4ca026 100644 --- a/adafruit_monsterm4sk.py +++ b/adafruit_monsterm4sk.py @@ -40,8 +40,8 @@ import adafruit_lis3dh try: - from busio import I2C from typing import Optional, Dict, Union + from busio import I2C except ImportError: pass