Skip to content

Commit b66abb3

Browse files
author
BiffoBear
committed
Added logic for Raspberry Pi pins
1 parent 34bff7a commit b66abb3

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

adafruit_rgbled.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,18 +100,18 @@ def __init__(
100100
True if the RGB LED is common anode. Defaults to False.
101101
"""
102102
self._rgb_led_pins = [red_pin, green_pin, blue_pin]
103-
for pin in self._rgb_led_pins:
103+
for pin, _ in enumerate(self._rgb_led_pins):
104104
try:
105-
if str(type(pin)) == "<class 'Pin'>":
106-
pin = PWMOut(pin)
107-
pin.duty_cycle = 0
105+
pin_type = str(type(self._rgb_led_pins[pin]))
106+
if pin_type.startswith("<class '") and pin_type.endswith("Pin'>"):
107+
self._rgb_led_pins[pin] = PWMOut(self._rgb_led_pins[pin])
108+
self._rgb_led_pins[pin].duty_cycle = 0
108109
except AttributeError as exc:
109110
raise TypeError(
110111
"Pins must be of type Pin, PWMOut or PWMChannel"
111112
) from exc
112113
self._invert_pwm = invert_pwm
113114
self._current_color = (0, 0, 0)
114-
self.color = self._current_color
115115

116116
def __enter__(self) -> "RGBLED":
117117
return self

0 commit comments

Comments
 (0)