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__(
100
100
True if the RGB LED is common anode. Defaults to False.
101
101
"""
102
102
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 ) :
104
104
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
108
109
except AttributeError as exc :
109
110
raise TypeError (
110
111
"Pins must be of type Pin, PWMOut or PWMChannel"
111
112
) from exc
112
113
self ._invert_pwm = invert_pwm
113
114
self ._current_color = (0 , 0 , 0 )
114
- self .color = self ._current_color
115
115
116
116
def __enter__ (self ) -> "RGBLED" :
117
117
return self
You can’t perform that action at this time.
0 commit comments