File tree Expand file tree Collapse file tree 1 file changed +33
-1
lines changed
Expand file tree Collapse file tree 1 file changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -212,6 +212,38 @@ Using :class:`LED` components::
212212 red.off()
213213
214214
215+ Travis build LED indicator
216+ ==========================
217+
218+ Use LEDs to indicate the status of a Travis build. A green light means the
219+ tests are passing, a red light means the build is broken::
220+
221+ from travispy import TravisPy
222+ from gpiozero import LED
223+ from time import sleep
224+ from signal import pause
225+
226+ def build_passed(repo='RPi-Distro/python-gpiozero', delay=3600):
227+ t = TravisPy()
228+ r = t.repo(repo)
229+ while True:
230+ yield r.last_build_state == 'passed'
231+ sleep(delay) # Sleep an hour before hitting travis again
232+
233+ def invert(values):
234+ for value in values:
235+ yield not value
236+
237+ red = LED(12)
238+ green = LED(16)
239+
240+ red.source = invert(green.values)
241+ green.source = build_passed()
242+ pause()
243+
244+
245+ Note this recipe requires travispy. Install with ``sudo pip3 install travispy ``.
246+
215247Push button stop motion
216248=======================
217249
@@ -611,7 +643,7 @@ Use up/down/left/right keys to control a robot::
611643 *not * work in environments like IDLE.
612644
613645If you prefer a version that works under IDLE, the following recipe should
614- suffice, but will require that you install the evdev library with ``sudo pip
646+ suffice, but will require that you install the evdev library with ``sudo pip3
615647install evdev `` first::
616648
617649 from gpiozero import RyanteckRobot
You can’t perform that action at this time.
0 commit comments