mirror of
https://github.com/KevinMidboe/python-gpiozero.git
synced 2025-10-29 17:50:37 +00:00
Fix Travis-build Recipe
Swap tabs to spaces, and use gpiozero.tools.negated
This commit is contained in:
@@ -196,7 +196,7 @@ Button controlled camera
|
|||||||
========================
|
========================
|
||||||
|
|
||||||
Using the button press to trigger picamera to take a pitcure using
|
Using the button press to trigger picamera to take a pitcure using
|
||||||
``button.when_pressed = camera.capture`` would not work because it requires an
|
``button/when_pressed = camera.capture`` would not work because it requires an
|
||||||
``output`` parameter. However, this can be achieved using a custom function
|
``output`` parameter. However, this can be achieved using a custom function
|
||||||
which requires no parameters::
|
which requires no parameters::
|
||||||
|
|
||||||
@@ -326,28 +326,25 @@ Travis build LED indicator
|
|||||||
Use LEDs to indicate the status of a Travis build. A green light means the
|
Use LEDs to indicate the status of a Travis build. A green light means the
|
||||||
tests are passing, a red light means the build is broken::
|
tests are passing, a red light means the build is broken::
|
||||||
|
|
||||||
from travispy import TravisPy
|
from travispy import TravisPy
|
||||||
from gpiozero import LED
|
from gpiozero import LED
|
||||||
from time import sleep
|
from gpiozero.tools import negated
|
||||||
from signal import pause
|
from time import sleep
|
||||||
|
from signal import pause
|
||||||
|
|
||||||
def build_passed(repo='RPi-Distro/python-gpiozero', delay=3600):
|
def build_passed(repo='RPi-Distro/python-gpiozero', delay=3600):
|
||||||
t = TravisPy()
|
t = TravisPy()
|
||||||
r = t.repo(repo)
|
r = t.repo(repo)
|
||||||
while True:
|
while True:
|
||||||
yield r.last_build_state == 'passed'
|
yield r.last_build_state == 'passed'
|
||||||
sleep(delay) # Sleep an hour before hitting travis again
|
sleep(delay) # Sleep an hour before hitting travis again
|
||||||
|
|
||||||
def invert(values):
|
red = LED(12)
|
||||||
for value in values:
|
green = LED(16)
|
||||||
yield not value
|
|
||||||
|
|
||||||
red = LED(12)
|
red.source = negated(green.values)
|
||||||
green = LED(16)
|
green.source = build_passed()
|
||||||
|
pause()
|
||||||
red.source = invert(green.values)
|
|
||||||
green.source = build_passed()
|
|
||||||
pause()
|
|
||||||
|
|
||||||
|
|
||||||
Note this recipe requires travispy. Install with ``sudo pip3 install travispy``.
|
Note this recipe requires travispy. Install with ``sudo pip3 install travispy``.
|
||||||
|
|||||||
Reference in New Issue
Block a user