Skip to content

Commit 38abddb

Browse files
author
brentru
committed
detect PWMChannel, PWMOut, or Pin
1 parent 2fe47a2 commit 38abddb

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

adafruit_rgbled.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,12 @@ def __init__(self, red_pin, green_pin, blue_pin, invert_pwm=False):
108108
pin_type = str(type(self._rgb_led_pins[i]))
109109
if pin_type == "<class 'Pin'>":
110110
self._rgb_led_pins[i] = PWMOut(self._rgb_led_pins[i])
111+
self._rgb_led_pins[i].duty_cycle = 0
112+
elif pin_type == "<class 'PWMChannel'>" or pin_type == "<class 'PWMOut'>":
113+
# PWMChannel/PWMOut do not require extra setup
114+
self._rgb_led_pins[i].duty_cycle = 0
115+
else:
116+
raise TypeError('Must provide a pin, PWMOut, or PWMChannel.')
111117
self._invert_pwm = invert_pwm
112118
self._current_color = (0, 0, 0)
113119
self.color = self._current_color

0 commit comments

Comments
 (0)