From 848d030ac9d1611c915965f0f77bd72199b64b0f Mon Sep 17 00:00:00 2001 From: Ben Nuttall Date: Thu, 21 Apr 2016 23:55:04 +0100 Subject: [PATCH] Remove with blocks for consistency, re: #239 --- docs/recipes.rst | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/docs/recipes.rst b/docs/recipes.rst index 7b26bc2..ef6482b 100644 --- a/docs/recipes.rst +++ b/docs/recipes.rst @@ -221,14 +221,14 @@ Capture a picture with the camera module every time a button is pressed:: from picamera import PiCamera button = Button(2) + camera = PiCamera() - with PiCamera() as camera: - camera.start_preview() - frame = 1 - while True: - button.wait_for_press() - camera.capture('/home/pi/frame%03d.jpg' % frame) - frame += 1 + camera.start_preview() + frame = 1 + while True: + button.wait_for_press() + camera.capture('/home/pi/frame%03d.jpg' % frame) + frame += 1 See `Push Button Stop Motion`_ for a full resource. @@ -676,9 +676,10 @@ connected to a :class:`MCP3008` analog to digital converter:: from gpiozero import MCP3008 - with MCP3008(channel=0) as pot: - while True: - print(pot.value) + pot = MCP3008(channel=0) + + while True: + print(pot.value) Present the value of a potentiometer on an LED bar graph using PWM to represent states that won't "fill" an LED::