File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments