Merge pull request #373 from lurch/gpio0_fixes

Allow TrafficLights, RGBLED and Motor to be constructed using GPIO 0
This commit is contained in:
Ben Nuttall
2016-06-10 12:31:10 +01:00
committed by GitHub
2 changed files with 3 additions and 3 deletions

View File

@@ -569,7 +569,7 @@ class TrafficLights(LEDBoard):
""" """
def __init__(self, red=None, amber=None, green=None, def __init__(self, red=None, amber=None, green=None,
pwm=False, initial_value=False): pwm=False, initial_value=False):
if not all([red, amber, green]): if not all(p is not None for p in [red, amber, green]):
raise GPIOPinMissing( raise GPIOPinMissing(
'red, amber and green pins must be provided' 'red, amber and green pins must be provided'
) )

View File

@@ -558,7 +558,7 @@ class RGBLED(SourceMixin, Device):
initial_value=(0, 0, 0), pwm=True): initial_value=(0, 0, 0), pwm=True):
self._leds = () self._leds = ()
self._blink_thread = None self._blink_thread = None
if not all([red, green, blue]): if not all(p is not None for p in [red, green, blue]):
raise GPIOPinMissing('red, green, and blue pins must be provided') raise GPIOPinMissing('red, green, and blue pins must be provided')
LEDClass = PWMLED if pwm else LED LEDClass = PWMLED if pwm else LED
super(RGBLED, self).__init__() super(RGBLED, self).__init__()
@@ -805,7 +805,7 @@ class Motor(SourceMixin, CompositeDevice):
control. control.
""" """
def __init__(self, forward=None, backward=None, pwm=True): def __init__(self, forward=None, backward=None, pwm=True):
if not all([forward, backward]): if not all(p is not None for p in [forward, backward]):
raise GPIOPinMissing( raise GPIOPinMissing(
'forward and backward pins must be provided' 'forward and backward pins must be provided'
) )