@@ -100,16 +100,15 @@ 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 i in range ( # pylint: disable=consider-using-enumerate
104
- len (self ._rgb_led_pins )
105
- ):
106
- if hasattr (self ._rgb_led_pins [i ], "frequency" ):
107
- self ._rgb_led_pins [i ].duty_cycle = 0
108
- elif str (type (self ._rgb_led_pins [i ])) == "<class 'Pin'>" :
109
- self ._rgb_led_pins [i ] = PWMOut (self ._rgb_led_pins [i ])
110
- self ._rgb_led_pins [i ].duty_cycle = 0
111
- else :
112
- raise TypeError ("Must provide a pin, PWMOut, or PWMChannel." )
103
+ for pin in self ._rgb_led_pins :
104
+ try :
105
+ if str (type (pin )) == "<class 'Pin'>" :
106
+ pin = PWMOut (pin )
107
+ pin .duty_cycle = 0
108
+ except AttributeError as exc :
109
+ raise TypeError (
110
+ "Pins must be of type Pin, PWMOut or PWMChannel"
111
+ ) from exc
113
112
self ._invert_pwm = invert_pwm
114
113
self ._current_color = (0 , 0 , 0 )
115
114
self .color = self ._current_color
@@ -149,7 +148,7 @@ def color(self, value: Union[int, tuple]):
149
148
raise ValueError ("Only bits 0->23 valid for integer input" ) from exc
150
149
elif isinstance (value , tuple ):
151
150
try :
152
- rgb = bytes (value ) # Check that tuple has 3 integers of 0 - 255.
151
+ rgb = bytes (value ) # Check that tuple has integers of 0 - 255.
153
152
if len (rgb ) != 3 :
154
153
raise ValueError
155
154
except (ValueError , TypeError ) as exc :
0 commit comments