diff --git a/docs/examples/led_board_2.py b/docs/examples/led_board_2.py index 0bb4f8a..aa7efbc 100644 --- a/docs/examples/led_board_2.py +++ b/docs/examples/led_board_2.py @@ -1,9 +1,8 @@ from gpiozero import LEDBoard -from time import sleep +from signal import pause -leds = LEDBoard(5, 6, 13, 19, 26) +leds = LEDBoard(5, 6, 13, 19, 26, pwm=True) -for led in leds: - led.on() - sleep(1) - led.off() +leds.value = (0.2, 0.4, 0.6, 0.8, 1.0) + +pause() diff --git a/docs/examples/led_board_3.py b/docs/examples/led_board_3.py index aa7efbc..0bb4f8a 100644 --- a/docs/examples/led_board_3.py +++ b/docs/examples/led_board_3.py @@ -1,8 +1,9 @@ from gpiozero import LEDBoard -from signal import pause +from time import sleep -leds = LEDBoard(5, 6, 13, 19, 26, pwm=True) +leds = LEDBoard(5, 6, 13, 19, 26) -leds.value = (0.2, 0.4, 0.6, 0.8, 1.0) - -pause() +for led in leds: + led.on() + sleep(1) + led.off() diff --git a/docs/recipes.rst b/docs/recipes.rst index 36a77db..7b3b25d 100644 --- a/docs/recipes.rst +++ b/docs/recipes.rst @@ -162,34 +162,12 @@ A collection of LEDs can be accessed using :class:`LEDBoard`: .. literalinclude:: examples/led_board_1.py -You can also iterate over the LEDs one-by-one: - -.. literalinclude:: examples/led_board_2.py - Using :class:`LEDBoard` with ``pwm=True`` allows each LED's brightness to be controlled: -.. literalinclude:: examples/led_board_3.py +.. literalinclude:: examples/led_board_2.py -:class:`LEDBoard` also supports indexing. This means you can access the -individual :class:`LED` objects using ``leds[i]`` where ``i`` is an integer -from 0 up to (not including) the number of LEDs: - -.. literalinclude:: examples/led_board_4.py - -This also means you can use slicing to access a subset of the LEDs: - -.. literalinclude:: examples/led_board_5.py - -:class:`LEDBoard` objects can have their `LED` objects named upon construction. -This means the individual LEDs can be accessed by their name: - -.. literalinclude:: examples/led_board_6.py - -:class:`LEDBoard` objects can also be nested to contain other :class:`LEDBoard` -objects: - -.. literalinclude:: examples/led_board_7.py +See more :class:`LEDBoard` examples in :doc:`recipes_advanced`. LEDBarGraph =========== diff --git a/docs/recipes_advanced.rst b/docs/recipes_advanced.rst index 8f770d6..10e97f4 100644 --- a/docs/recipes_advanced.rst +++ b/docs/recipes_advanced.rst @@ -8,6 +8,46 @@ The following recipes demonstrate some of the capabilities of the GPIO Zero library. Please note that all recipes are written assuming Python 3. Recipes *may* work under Python 2, but no guarantees! +LEDBoard +======== + +You can iterate over the LEDs in a :class:`LEDBoard` object one-by-one: + +.. literalinclude:: examples/led_board_3.py + +:class:`LEDBoard` also supports indexing. This means you can access the +individual :class:`LED` objects using ``leds[i]`` where ``i`` is an integer +from 0 up to (not including) the number of LEDs: + +.. literalinclude:: examples/led_board_4.py + +This also means you can use slicing to access a subset of the LEDs: + +.. literalinclude:: examples/led_board_5.py + +:class:`LEDBoard` objects can have their `LED` objects named upon construction. +This means the individual LEDs can be accessed by their name: + +.. literalinclude:: examples/led_board_6.py + +:class:`LEDBoard` objects can also be nested within other :class:`LEDBoard` +objects: + +.. literalinclude:: examples/led_board_7.py + +Who's home indicator +==================== + +Using a number of green-red LED pairs, you can show the status of who's home, +according to which IP addresses you can ping successfully. Note that this +assumes each person's mobile phone has a reserved IP address on the home router. + +.. literalinclude:: examples/whos_home_leds.py + +Alternatively, using the `STATUS Zero`_ board: + +.. literalinclude:: examples/whos_home_status.py + Travis build LED indicator ========================== @@ -28,19 +68,6 @@ a Bee-Bot or Turtle robot. .. literalinclude:: examples/robot_buttons_2.py -Who's home indicator -==================== - -Using a number of green-red LED pairs, you can show the status of who's home, -according to which IP addresses you can ping successfully. Note that this -assumes each person's mobile phone has a reserved IP address on the home router. - -.. literalinclude:: examples/whos_home_leds.py - -Alternatively, using the `STATUS Zero`_ board: - -.. literalinclude:: examples/whos_home_status.py - Robot controlled by 2 potentiometers ====================================