From 962c75c01b03d95fcecb330973203ed758cea5d2 Mon Sep 17 00:00:00 2001 From: BiffoBear Date: Mon, 20 Mar 2023 08:00:27 +0700 Subject: [PATCH 01/17] Made the typing of the pins more explicit, so it's clear where they come from. --- adafruit_rgbled.py | 64 +++++++++++++++++++++++++++++----------------- 1 file changed, 40 insertions(+), 24 deletions(-) diff --git a/adafruit_rgbled.py b/adafruit_rgbled.py index 3a59ab0..61e95ac 100644 --- a/adafruit_rgbled.py +++ b/adafruit_rgbled.py @@ -20,6 +20,14 @@ * Adafruit's SimpleIO library: https://github.com/adafruit/Adafruit_CircuitPython_SimpleIO """ +try: + from typing import Union + import adafruit_pca9685 as pca9685 + import pwmio + import microcontroller +except ImportError: + pass + from pwmio import PWMOut from simpleio import map_range @@ -31,21 +39,6 @@ class RGBLED: """ Creates a RGBLED object given three physical pins or PWMOut objects. - :param red_pin: The physical pin connected to a red LED anode. - :type ~microcontroller.Pin: Microcontroller's red_pin. - :type pwmio.PWMOut: PWMOut object associated with red_pin. - :type PWMChannel: PCA9685 PWM channel associated with red_pin. - :param green_pin: The physical pin connected to a green LED anode. - :type ~microcontroller.Pin: Microcontroller's green_pin. - :type pwmio.PWMOut: PWMOut object associated with green_pin. - :type PWMChannel: PCA9685 PWM channel associated with green_pin. - :param blue_pin: The physical pin connected to a blue LED anode. - :type ~microcontroller.Pin: Microcontroller's blue_pin. - :type pwmio.PWMOut: PWMOut object associated with blue_pin. - :type PWMChannel: PCA9685 PWM channel associated with blue_pin. - :param bool invert_pwm: False if the RGB LED is common cathode, - true if the RGB LED is common anode. - Example for setting a RGB LED using a RGB Tuple (Red, Green, Blue): .. code-block:: python @@ -96,7 +89,23 @@ class RGBLED: """ - def __init__(self, red_pin, green_pin, blue_pin, invert_pwm=False): + def __init__( + self, + red_pin: Union[microcontroller.Pin, pwmio.PWMOut, pca9685.PWMChannel], + green_pin: Union[microcontroller.Pin, pwmio.PWMOut, pca9685.PWMChannel], + blue_pin: Union[microcontroller.Pin, pwmio.PWMOut, pca9685.PWMChannel], + invert_pwm: bool = False, + ) -> None: + """ + :param Union[microcontroller.Pin, pwmio.PWMOut, pca9685.PWMChannel] red_pin: + The connection to the red LED. + :param Union[microcontroller.Pin, pwmio.PWMOut, pca9685.PWMChannel] green_pin: + The connection to the green LED. + :param Union[microcontroller.Pin, pwmio.PWMOut, pca9685.PWMChannel] blue_pin: + The connection to the blue LED. + :param bool invert_pwm: False if the RGB LED is common cathode, + True if the RGB LED is common anode. + """ self._rgb_led_pins = [red_pin, green_pin, blue_pin] for i in range( # pylint: disable=consider-using-enumerate len(self._rgb_led_pins) @@ -112,27 +121,34 @@ def __init__(self, red_pin, green_pin, blue_pin, invert_pwm=False): self._current_color = (0, 0, 0) self.color = self._current_color - def __enter__(self): + def __enter__(self) -> "RGBLED": return self - def __exit__(self, exception_type, exception_value, traceback): + def __exit__(self, exception_type, exception_value, traceback) -> None: self.deinit() - def deinit(self): + def deinit(self) -> None: """Turn the LEDs off, deinit pwmout and release hardware resources.""" for pin in self._rgb_led_pins: pin.deinit() # pylint: disable=no-member self._current_color = (0, 0, 0) @property - def color(self): - """Returns the RGB LED's current color.""" + def color(self) -> Union[int, tuple]: + """Return the RGB LED's current color. + + :return Union[int, tuple]: The currently set color. + """ return self._current_color @color.setter - def color(self, value): + def color(self, value: Union[int, tuple]): """Sets the RGB LED to a desired color. - :param type value: RGB LED desired value - can be a RGB tuple or a 24-bit integer. + :param Union[int, tuple] value: RGB LED desired value - can be a RGB tuple of values + 0 - 255 or a 24-bit integer. e.g. (255, 64, 35) and 0xff4023 are equivalent. + + :raises ValueError: If the input is an int > 0xffffff. + :raises TypeError: If the input is not an integer or a tuple. """ self._current_color = value if isinstance(value, tuple): @@ -154,4 +170,4 @@ def color(self, value): rgb[color] -= 65535 self._rgb_led_pins[color].duty_cycle = abs(rgb[color]) else: - raise ValueError("Color must be a tuple or 24-bit integer value.") + raise TypeError("Color must be a tuple or 24-bit integer value.") From 0790d550e749c196d6499e4124aaaa58f9633771 Mon Sep 17 00:00:00 2001 From: BiffoBear Date: Mon, 20 Mar 2023 08:09:47 +0700 Subject: [PATCH 02/17] Removed extra copy of doc string from color property. --- adafruit_rgbled.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/adafruit_rgbled.py b/adafruit_rgbled.py index 61e95ac..94ccd42 100644 --- a/adafruit_rgbled.py +++ b/adafruit_rgbled.py @@ -86,7 +86,6 @@ class RGBLED: import adafruit_rgbled with adafruit_rgbled.RGBLED(board.D5, board.D6, board.D7, invert_pwm=True) as rgb_led: rgb_led.color = (0, 255, 0) - """ def __init__( @@ -135,21 +134,18 @@ def deinit(self) -> None: @property def color(self) -> Union[int, tuple]: - """Return the RGB LED's current color. - - :return Union[int, tuple]: The currently set color. """ - return self._current_color - - @color.setter - def color(self, value: Union[int, tuple]): - """Sets the RGB LED to a desired color. + Sets the RGB LED to a desired color. :param Union[int, tuple] value: RGB LED desired value - can be a RGB tuple of values 0 - 255 or a 24-bit integer. e.g. (255, 64, 35) and 0xff4023 are equivalent. :raises ValueError: If the input is an int > 0xffffff. :raises TypeError: If the input is not an integer or a tuple. """ + return self._current_color + + @color.setter + def color(self, value: Union[int, tuple]): self._current_color = value if isinstance(value, tuple): for i in range(0, 3): From ec15648292e6aab4fbf809696a6edea7ad5cd608 Mon Sep 17 00:00:00 2001 From: BiffoBear Date: Tue, 21 Mar 2023 12:20:09 +0700 Subject: [PATCH 03/17] Rolled back changes to Sphinx and moved to types in string quotes. --- adafruit_rgbled.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/adafruit_rgbled.py b/adafruit_rgbled.py index 18fbbca..c7f123a 100644 --- a/adafruit_rgbled.py +++ b/adafruit_rgbled.py @@ -20,9 +20,6 @@ """ try: from typing import Union - import adafruit_pca9685 as pca9685 - import pwmio - import microcontroller except ImportError: pass @@ -87,20 +84,20 @@ class RGBLED: def __init__( self, - red_pin: Union[microcontroller.Pin, pwmio.PWMOut, pca9685.PWMChannel], - green_pin: Union[microcontroller.Pin, pwmio.PWMOut, pca9685.PWMChannel], - blue_pin: Union[microcontroller.Pin, pwmio.PWMOut, pca9685.PWMChannel], + red_pin: Union["microcontroller.Pin", PWMOut, "PWMChannel"], + green_pin: Union["microcontroller.Pin", PWMOut, "PWMChannel"], + blue_pin: Union["microcontroller.Pin", PWMOut, "PWMChannel"], invert_pwm: bool = False, ) -> None: """ - :param Union[microcontroller.Pin, pwmio.PWMOut, pca9685.PWMChannel] red_pin: + :param Union["microcontroller.Pin", PWMOut, "PWMChannel"] red_pin: The connection to the red LED. - :param Union[microcontroller.Pin, pwmio.PWMOut, pca9685.PWMChannel] green_pin: + :param Union["microcontroller.Pin", PWMOut, "PWMChannel"] green_pin: The connection to the green LED. - :param Union[microcontroller.Pin, pwmio.PWMOut, pca9685.PWMChannel] blue_pin: + :param Union["microcontroller.Pin", PWMOut, "PWMChannel"] blue_pin: The connection to the blue LED. :param bool invert_pwm: False if the RGB LED is common cathode, - True if the RGB LED is common anode. + True if the RGB LED is common anode. Defaults to False. """ self._rgb_led_pins = [red_pin, green_pin, blue_pin] for i in range( # pylint: disable=consider-using-enumerate From 61f89d249a4d1e6875f214e97fed03d3d0018218 Mon Sep 17 00:00:00 2001 From: BiffoBear Date: Wed, 12 Apr 2023 07:10:19 +0300 Subject: [PATCH 04/17] Moved doc-string from __init__ to class definition. --- adafruit_rgbled.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/adafruit_rgbled.py b/adafruit_rgbled.py index c7f123a..191a753 100644 --- a/adafruit_rgbled.py +++ b/adafruit_rgbled.py @@ -80,6 +80,15 @@ class RGBLED: import adafruit_rgbled with adafruit_rgbled.RGBLED(board.D5, board.D6, board.D7, invert_pwm=True) as rgb_led: rgb_led.color = (0, 255, 0) + + :param Union["microcontroller.Pin", PWMOut, "PWMChannel"] red_pin: + The connection to the red LED. + :param Union["microcontroller.Pin", PWMOut, "PWMChannel"] green_pin: + The connection to the green LED. + :param Union["microcontroller.Pin", PWMOut, "PWMChannel"] blue_pin: + The connection to the blue LED. + :param bool invert_pwm: False if the RGB LED is common cathode, + True if the RGB LED is common anode. Defaults to False. """ def __init__( @@ -89,16 +98,6 @@ def __init__( blue_pin: Union["microcontroller.Pin", PWMOut, "PWMChannel"], invert_pwm: bool = False, ) -> None: - """ - :param Union["microcontroller.Pin", PWMOut, "PWMChannel"] red_pin: - The connection to the red LED. - :param Union["microcontroller.Pin", PWMOut, "PWMChannel"] green_pin: - The connection to the green LED. - :param Union["microcontroller.Pin", PWMOut, "PWMChannel"] blue_pin: - The connection to the blue LED. - :param bool invert_pwm: False if the RGB LED is common cathode, - True if the RGB LED is common anode. Defaults to False. - """ self._rgb_led_pins = [red_pin, green_pin, blue_pin] for i in range( # pylint: disable=consider-using-enumerate len(self._rgb_led_pins) From 8ffdd7963586fb2754b10c174c909266e06a3756 Mon Sep 17 00:00:00 2001 From: BiffoBear Date: Wed, 12 Apr 2023 10:06:28 +0300 Subject: [PATCH 05/17] Refactored typing to use ColorBasedColorUnion. --- adafruit_rgbled.py | 44 +++++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/adafruit_rgbled.py b/adafruit_rgbled.py index 191a753..2f10cd5 100644 --- a/adafruit_rgbled.py +++ b/adafruit_rgbled.py @@ -19,7 +19,9 @@ https://github.com/adafruit/circuitpython/releases """ try: - from typing import Union + from typing import Union, Optional, Type, TracebackType + from circuitpython_typing.led import ColorBasedColorUnion + from microcontroller import Pin except ImportError: pass @@ -31,9 +33,9 @@ class RGBLED: """ - Creates a RGBLED object given three physical pins or PWMOut objects. + Creates an RGBLED object given three physical pins or PWMOut objects. - Example for setting a RGB LED using a RGB Tuple (Red, Green, Blue): + Example for setting an RGB LED using an RGB Tuple (Red, Green, Blue): .. code-block:: python @@ -48,7 +50,7 @@ class RGBLED: led = adafruit_rgbled.RGBLED(RED_LED, BLUE_LED, GREEN_LED) led.color = (255, 0, 0) - Example for setting a RGB LED using a 24-bit integer (hex syntax): + Example for setting an RGB LED using a 24-bit integer (hex syntax): .. code-block:: python @@ -59,11 +61,11 @@ class RGBLED: GREEN_LED = board.D6 BLUE_LED = board.D7 - # Create a RGB LED object + # Create an RGB LED object led = adafruit_rgbled.RGBLED(RED_LED, BLUE_LED, GREEN_LED) led.color = 0x100000 - Example for setting a RGB LED using a ContextManager: + Example for setting an RGB LED using a ContextManager: .. code-block:: python @@ -81,11 +83,11 @@ class RGBLED: with adafruit_rgbled.RGBLED(board.D5, board.D6, board.D7, invert_pwm=True) as rgb_led: rgb_led.color = (0, 255, 0) - :param Union["microcontroller.Pin", PWMOut, "PWMChannel"] red_pin: + :param Union[Pin, PWMOut, "PWMChannel"] red_pin: The connection to the red LED. - :param Union["microcontroller.Pin", PWMOut, "PWMChannel"] green_pin: + :param Union[Pin, PWMOut, "PWMChannel"] green_pin: The connection to the green LED. - :param Union["microcontroller.Pin", PWMOut, "PWMChannel"] blue_pin: + :param Union[Pin, PWMOut, "PWMChannel"] blue_pin: The connection to the blue LED. :param bool invert_pwm: False if the RGB LED is common cathode, True if the RGB LED is common anode. Defaults to False. @@ -93,9 +95,9 @@ class RGBLED: def __init__( self, - red_pin: Union["microcontroller.Pin", PWMOut, "PWMChannel"], - green_pin: Union["microcontroller.Pin", PWMOut, "PWMChannel"], - blue_pin: Union["microcontroller.Pin", PWMOut, "PWMChannel"], + red_pin: Union[Pin, PWMOut, "PWMChannel"], + green_pin: Union[Pin, PWMOut, "PWMChannel"], + blue_pin: Union[Pin, PWMOut, "PWMChannel"], invert_pwm: bool = False, ) -> None: self._rgb_led_pins = [red_pin, green_pin, blue_pin] @@ -116,7 +118,12 @@ def __init__( def __enter__(self) -> "RGBLED": return self - def __exit__(self, exception_type, exception_value, traceback) -> None: + def __exit__( + self, + exception_type: Optional[Type[type]], + exception_value: Optional[BaseException], + traceback: Optional[TracebackType], + ) -> None: self.deinit() def deinit(self) -> None: @@ -126,11 +133,14 @@ def deinit(self) -> None: self._current_color = (0, 0, 0) @property - def color(self) -> Union[int, tuple]: + def color(self) -> ColorBasedColorUnion: """ Sets the RGB LED to a desired color. - :param Union[int, tuple] value: RGB LED desired value - can be a RGB tuple of values - 0 - 255 or a 24-bit integer. e.g. (255, 64, 35) and 0xff4023 are equivalent. + :param ColorBasedColorUnion value: RGB LED desired value - can be a RGB + tuple of values 0 - 255 or a 24-bit integer. e.g. (255, 64, 35) and 0xff4023 + are equivalent. + + :returns Union[int, Tuple[int, int, int]]: The current LED color setting. :raises ValueError: If the input is an int > 0xffffff. :raises TypeError: If the input is not an integer or a tuple. @@ -138,7 +148,7 @@ def color(self) -> Union[int, tuple]: return self._current_color @color.setter - def color(self, value: Union[int, tuple]): + def color(self, value: ColorBasedColorUnion): self._current_color = value if isinstance(value, tuple): for i in range(0, 3): From 430c6af0214adbc713d3b8d7659c520a466410dc Mon Sep 17 00:00:00 2001 From: BiffoBear Date: Wed, 12 Apr 2023 10:12:47 +0300 Subject: [PATCH 06/17] Refactored Pin to microcontroller.Pin. --- adafruit_rgbled.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/adafruit_rgbled.py b/adafruit_rgbled.py index 2f10cd5..990a1e9 100644 --- a/adafruit_rgbled.py +++ b/adafruit_rgbled.py @@ -21,7 +21,7 @@ try: from typing import Union, Optional, Type, TracebackType from circuitpython_typing.led import ColorBasedColorUnion - from microcontroller import Pin + import microcontroller except ImportError: pass @@ -95,9 +95,9 @@ class RGBLED: def __init__( self, - red_pin: Union[Pin, PWMOut, "PWMChannel"], - green_pin: Union[Pin, PWMOut, "PWMChannel"], - blue_pin: Union[Pin, PWMOut, "PWMChannel"], + red_pin: Union[microcontroller.Pin, PWMOut, "PWMChannel"], + green_pin: Union[microcontroller.Pin, PWMOut, "PWMChannel"], + blue_pin: Union[microcontroller.Pin, PWMOut, "PWMChannel"], invert_pwm: bool = False, ) -> None: self._rgb_led_pins = [red_pin, green_pin, blue_pin] From 89c364353057315d4af82c1f23b5294fff5f54ac Mon Sep 17 00:00:00 2001 From: BiffoBear Date: Wed, 12 Apr 2023 10:31:23 +0300 Subject: [PATCH 07/17] Refactored Pin to "microcontroller.Pin". --- adafruit_rgbled.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/adafruit_rgbled.py b/adafruit_rgbled.py index 990a1e9..e59e393 100644 --- a/adafruit_rgbled.py +++ b/adafruit_rgbled.py @@ -21,7 +21,6 @@ try: from typing import Union, Optional, Type, TracebackType from circuitpython_typing.led import ColorBasedColorUnion - import microcontroller except ImportError: pass @@ -95,9 +94,9 @@ class RGBLED: def __init__( self, - red_pin: Union[microcontroller.Pin, PWMOut, "PWMChannel"], - green_pin: Union[microcontroller.Pin, PWMOut, "PWMChannel"], - blue_pin: Union[microcontroller.Pin, PWMOut, "PWMChannel"], + red_pin: Union["microcontroller.Pin", PWMOut, "PWMChannel"], + green_pin: Union["microcontroller.Pin", PWMOut, "PWMChannel"], + blue_pin: Union["microcontroller.Pin", PWMOut, "PWMChannel"], invert_pwm: bool = False, ) -> None: self._rgb_led_pins = [red_pin, green_pin, blue_pin] From 588a0d11a8a3481f76ce50d953e3a9ffa78fb51a Mon Sep 17 00:00:00 2001 From: BiffoBear Date: Wed, 12 Apr 2023 10:58:45 +0300 Subject: [PATCH 08/17] Changed import of TracebackType from typing to types. --- adafruit_rgbled.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/adafruit_rgbled.py b/adafruit_rgbled.py index e59e393..89c1aa4 100644 --- a/adafruit_rgbled.py +++ b/adafruit_rgbled.py @@ -19,7 +19,8 @@ https://github.com/adafruit/circuitpython/releases """ try: - from typing import Union, Optional, Type, TracebackType + from typing import Union, Optional, Type + from types import TracebackType from circuitpython_typing.led import ColorBasedColorUnion except ImportError: pass From 3b711a1a562fc08c29be9f59a8c1a3a53b885824 Mon Sep 17 00:00:00 2001 From: BiffoBear Date: Wed, 12 Apr 2023 12:55:21 +0300 Subject: [PATCH 09/17] Attempt to fix docstring indent. --- adafruit_rgbled.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/adafruit_rgbled.py b/adafruit_rgbled.py index 89c1aa4..733520f 100644 --- a/adafruit_rgbled.py +++ b/adafruit_rgbled.py @@ -33,7 +33,7 @@ class RGBLED: """ - Creates an RGBLED object given three physical pins or PWMOut objects. + Create an RGBLED object given three physical pins or PWMOut objects. Example for setting an RGB LED using an RGB Tuple (Red, Green, Blue): @@ -83,11 +83,11 @@ class RGBLED: with adafruit_rgbled.RGBLED(board.D5, board.D6, board.D7, invert_pwm=True) as rgb_led: rgb_led.color = (0, 255, 0) - :param Union[Pin, PWMOut, "PWMChannel"] red_pin: + :param Union["microcontroller.Pin", PWMOut, "PWMChannel"] red_pin: The connection to the red LED. - :param Union[Pin, PWMOut, "PWMChannel"] green_pin: + :param Union["microcontroller.Pin", PWMOut, "PWMChannel"] green_pin: The connection to the green LED. - :param Union[Pin, PWMOut, "PWMChannel"] blue_pin: + :param Union["microcontroller.Pin", PWMOut, "PWMChannel"] blue_pin: The connection to the blue LED. :param bool invert_pwm: False if the RGB LED is common cathode, True if the RGB LED is common anode. Defaults to False. @@ -136,6 +136,7 @@ def deinit(self) -> None: def color(self) -> ColorBasedColorUnion: """ Sets the RGB LED to a desired color. + :param ColorBasedColorUnion value: RGB LED desired value - can be a RGB tuple of values 0 - 255 or a 24-bit integer. e.g. (255, 64, 35) and 0xff4023 are equivalent. From 2653b83610b67cf2ec3662a6354e36c36c1ee4ce Mon Sep 17 00:00:00 2001 From: BiffoBear Date: Fri, 14 Apr 2023 05:16:42 +0300 Subject: [PATCH 10/17] Added adafruit_circuitpython_typing~=1.4 to requirements.txt. --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index 7a984a4..1e011e3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,3 +3,4 @@ # SPDX-License-Identifier: Unlicense Adafruit-Blinka +adafruit_circuitpython_typing~=1.4 From af553d3c1da8910299c6c8e33283ab7aa343dd9b Mon Sep 17 00:00:00 2001 From: BiffoBear Date: Fri, 14 Apr 2023 05:28:06 +0300 Subject: [PATCH 11/17] Imported microcontroller.Pin and adafruit_pca9685.PWMChannel --- adafruit_rgbled.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/adafruit_rgbled.py b/adafruit_rgbled.py index 733520f..f223255 100644 --- a/adafruit_rgbled.py +++ b/adafruit_rgbled.py @@ -21,6 +21,8 @@ try: from typing import Union, Optional, Type from types import TracebackType + from microcontroller import Pin + from adafruit_pca9685 import PWMChannel from circuitpython_typing.led import ColorBasedColorUnion except ImportError: pass @@ -83,11 +85,11 @@ class RGBLED: with adafruit_rgbled.RGBLED(board.D5, board.D6, board.D7, invert_pwm=True) as rgb_led: rgb_led.color = (0, 255, 0) - :param Union["microcontroller.Pin", PWMOut, "PWMChannel"] red_pin: + :param Union[Pin, PWMOut, PWMChannel] red_pin: The connection to the red LED. - :param Union["microcontroller.Pin", PWMOut, "PWMChannel"] green_pin: + :param Union[Pin, PWMOut, PWMChannel] green_pin: The connection to the green LED. - :param Union["microcontroller.Pin", PWMOut, "PWMChannel"] blue_pin: + :param Union[Pin, PWMOut, PWMChannel] blue_pin: The connection to the blue LED. :param bool invert_pwm: False if the RGB LED is common cathode, True if the RGB LED is common anode. Defaults to False. @@ -95,9 +97,9 @@ class RGBLED: def __init__( self, - red_pin: Union["microcontroller.Pin", PWMOut, "PWMChannel"], - green_pin: Union["microcontroller.Pin", PWMOut, "PWMChannel"], - blue_pin: Union["microcontroller.Pin", PWMOut, "PWMChannel"], + red_pin: Union[Pin, PWMOut, PWMChannel], + green_pin: Union[Pin, PWMOut, PWMChannel], + blue_pin: Union[Pin, PWMOut, PWMChannel], invert_pwm: bool = False, ) -> None: self._rgb_led_pins = [red_pin, green_pin, blue_pin] From 5d50d929b470410a0a89f027454106a921f642dc Mon Sep 17 00:00:00 2001 From: BiffoBear Date: Fri, 14 Apr 2023 05:54:35 +0300 Subject: [PATCH 12/17] Removed PWMChannel import as it fails CI. --- adafruit_rgbled.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/adafruit_rgbled.py b/adafruit_rgbled.py index f223255..10808c1 100644 --- a/adafruit_rgbled.py +++ b/adafruit_rgbled.py @@ -22,7 +22,6 @@ from typing import Union, Optional, Type from types import TracebackType from microcontroller import Pin - from adafruit_pca9685 import PWMChannel from circuitpython_typing.led import ColorBasedColorUnion except ImportError: pass @@ -85,11 +84,11 @@ class RGBLED: with adafruit_rgbled.RGBLED(board.D5, board.D6, board.D7, invert_pwm=True) as rgb_led: rgb_led.color = (0, 255, 0) - :param Union[Pin, PWMOut, PWMChannel] red_pin: + :param Union[Pin, PWMOut, "PWMChannel"] red_pin: The connection to the red LED. - :param Union[Pin, PWMOut, PWMChannel] green_pin: + :param Union[Pin, PWMOut, "PWMChannel"] green_pin: The connection to the green LED. - :param Union[Pin, PWMOut, PWMChannel] blue_pin: + :param Union[Pin, PWMOut, "PWMChannel"] blue_pin: The connection to the blue LED. :param bool invert_pwm: False if the RGB LED is common cathode, True if the RGB LED is common anode. Defaults to False. @@ -97,9 +96,9 @@ class RGBLED: def __init__( self, - red_pin: Union[Pin, PWMOut, PWMChannel], - green_pin: Union[Pin, PWMOut, PWMChannel], - blue_pin: Union[Pin, PWMOut, PWMChannel], + red_pin: Union[Pin, PWMOut, "PWMChannel"], + green_pin: Union[Pin, PWMOut, "PWMChannel"], + blue_pin: Union[Pin, PWMOut, "PWMChannel"], invert_pwm: bool = False, ) -> None: self._rgb_led_pins = [red_pin, green_pin, blue_pin] From 0ac396880fd02ef436d2fcf41560d57efcd7acda Mon Sep 17 00:00:00 2001 From: BiffoBear Date: Fri, 14 Apr 2023 06:02:09 +0300 Subject: [PATCH 13/17] Added adafruit_pca9685 to requirements.txt and imported for typing. --- adafruit_rgbled.py | 13 +++++++------ requirements.txt | 1 + 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/adafruit_rgbled.py b/adafruit_rgbled.py index 10808c1..f223255 100644 --- a/adafruit_rgbled.py +++ b/adafruit_rgbled.py @@ -22,6 +22,7 @@ from typing import Union, Optional, Type from types import TracebackType from microcontroller import Pin + from adafruit_pca9685 import PWMChannel from circuitpython_typing.led import ColorBasedColorUnion except ImportError: pass @@ -84,11 +85,11 @@ class RGBLED: with adafruit_rgbled.RGBLED(board.D5, board.D6, board.D7, invert_pwm=True) as rgb_led: rgb_led.color = (0, 255, 0) - :param Union[Pin, PWMOut, "PWMChannel"] red_pin: + :param Union[Pin, PWMOut, PWMChannel] red_pin: The connection to the red LED. - :param Union[Pin, PWMOut, "PWMChannel"] green_pin: + :param Union[Pin, PWMOut, PWMChannel] green_pin: The connection to the green LED. - :param Union[Pin, PWMOut, "PWMChannel"] blue_pin: + :param Union[Pin, PWMOut, PWMChannel] blue_pin: The connection to the blue LED. :param bool invert_pwm: False if the RGB LED is common cathode, True if the RGB LED is common anode. Defaults to False. @@ -96,9 +97,9 @@ class RGBLED: def __init__( self, - red_pin: Union[Pin, PWMOut, "PWMChannel"], - green_pin: Union[Pin, PWMOut, "PWMChannel"], - blue_pin: Union[Pin, PWMOut, "PWMChannel"], + red_pin: Union[Pin, PWMOut, PWMChannel], + green_pin: Union[Pin, PWMOut, PWMChannel], + blue_pin: Union[Pin, PWMOut, PWMChannel], invert_pwm: bool = False, ) -> None: self._rgb_led_pins = [red_pin, green_pin, blue_pin] diff --git a/requirements.txt b/requirements.txt index 1e011e3..0bb4bb1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,3 +4,4 @@ Adafruit-Blinka adafruit_circuitpython_typing~=1.4 +adafruit_pca9685 From 9fe37bbbf805f3542ffac6228767651ed20bba2a Mon Sep 17 00:00:00 2001 From: BiffoBear Date: Fri, 14 Apr 2023 07:10:45 +0300 Subject: [PATCH 14/17] Removed adafruit_pca9685 from requirements.txt and wrapped quotes around PWMChannel in doc-string. --- adafruit_rgbled.py | 6 +++--- requirements.txt | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/adafruit_rgbled.py b/adafruit_rgbled.py index f223255..c5c7386 100644 --- a/adafruit_rgbled.py +++ b/adafruit_rgbled.py @@ -85,11 +85,11 @@ class RGBLED: with adafruit_rgbled.RGBLED(board.D5, board.D6, board.D7, invert_pwm=True) as rgb_led: rgb_led.color = (0, 255, 0) - :param Union[Pin, PWMOut, PWMChannel] red_pin: + :param Union[Pin, PWMOut, "PWMChannel"] red_pin: The connection to the red LED. - :param Union[Pin, PWMOut, PWMChannel] green_pin: + :param Union[Pin, PWMOut, "PWMChannel"] green_pin: The connection to the green LED. - :param Union[Pin, PWMOut, PWMChannel] blue_pin: + :param Union[Pin, PWMOut, "PWMChannel"] blue_pin: The connection to the blue LED. :param bool invert_pwm: False if the RGB LED is common cathode, True if the RGB LED is common anode. Defaults to False. diff --git a/requirements.txt b/requirements.txt index 0bb4bb1..1e011e3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,4 +4,3 @@ Adafruit-Blinka adafruit_circuitpython_typing~=1.4 -adafruit_pca9685 From 5996fd2effde0a19ea7ac1e37b57c68acce01f4c Mon Sep 17 00:00:00 2001 From: BiffoBear Date: Fri, 14 Apr 2023 07:27:26 +0300 Subject: [PATCH 15/17] Added adafruit_pca9685 back to requirements.txt. --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index 1e011e3..0bb4bb1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,3 +4,4 @@ Adafruit-Blinka adafruit_circuitpython_typing~=1.4 +adafruit_pca9685 From 2a17b3cbe04059f946657aed04fe7b645db20685 Mon Sep 17 00:00:00 2001 From: BiffoBear Date: Fri, 14 Apr 2023 07:40:28 +0300 Subject: [PATCH 16/17] Renamed adafruit_pca9685 to Adafruit-PCA9685, adafruit-circuitpython-typing. --- requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 0bb4bb1..a1319b9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,5 +3,5 @@ # SPDX-License-Identifier: Unlicense Adafruit-Blinka -adafruit_circuitpython_typing~=1.4 -adafruit_pca9685 +adafruit-circuitpython-typing~=1.4 +Adafruit-PCA9685 From f5d9e062b7e3ed74268b7833ca480188c37689e9 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 31 Jul 2023 15:32:55 -0500 Subject: [PATCH 17/17] fix requirement pip name --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index a1319b9..47d8df5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,4 +4,4 @@ Adafruit-Blinka adafruit-circuitpython-typing~=1.4 -Adafruit-PCA9685 +adafruit-circuitpython-pca9685