Fix Notes

Notes now works with embedded code sections, but the spacing is still
wrong as is the language selection. Oh well, come back to it later...
This commit is contained in:
Dave Jones
2015-10-12 22:17:45 +01:00
parent d7e5ae218b
commit f0eefdb8f2
2 changed files with 63 additions and 72 deletions

View File

@@ -15,13 +15,15 @@ The latest release is **v0.7.0 beta 2** released on 9th October 2015.
With very little code, you can quickly get going connecting your physical With very little code, you can quickly get going connecting your physical
components together: components together:
from gpiozero import LED, Button ```python
from gpiozero import LED, Button
led = LED(2) led = LED(2)
button = Button(3) button = Button(3)
button.when_pressed = led.on button.when_pressed = led.on
button.when_released = led.off button.when_released = led.off
```
The library includes interfaces to many simple everyday components, as well as The library includes interfaces to many simple everyday components, as well as
some more complex things like sensors, analogue-to-digital converters, full some more complex things like sensors, analogue-to-digital converters, full

View File

@@ -2,88 +2,77 @@
1. **BCM pin numbering** 1. **BCM pin numbering**
This library uses Broadcom (BCM) pin numbering for the GPIO pins, as This library uses Broadcom (BCM) pin numbering for the GPIO pins, as
opposed to BOARD. Unlike the `RPi.GPIO` library, this is not configurable. opposed to BOARD. Unlike the `RPi.GPIO` library, this is not configurable.
Any pin marked `GPIO` can be used for generic components. Any pin marked `GPIO` can be used for generic components.
The BCM pin layout is as follows: The BCM pin layout is as follows:
| | | | | |
|-----------:|:-----------| |-----------:|:-----------|
| 3V3 | 5V | | 3V3 | 5V |
| **GPIO2** | 5V | | **GPIO2** | 5V |
| **GPIO3** | GND | | **GPIO3** | GND |
| **GPIO4** | **GPIO14** | | **GPIO4** | **GPIO14** |
| GND | **GPIO15** | | GND | **GPIO15** |
| **GPIO17** | **GPIO18** | | **GPIO17** | **GPIO18** |
| **GPIO27** | GND | | **GPIO27** | GND |
| **GPIO22** | **GPIO23** | | **GPIO22** | **GPIO23** |
| 3V3 | **GPIO24** | | 3V3 | **GPIO24** |
| **GPIO10** | GND | | **GPIO10** | GND |
| **GPIO9** | **GPIO25** | | **GPIO9** | **GPIO25** |
| **GPIO11** | **GPIO8** | | **GPIO11** | **GPIO8** |
| GND | **GPIO7** | | GND | **GPIO7** |
| DNC | DNC | | DNC | DNC |
| **GPIO5** | GND | | **GPIO5** | GND |
| **GPIO6** | **GPIO12** | | **GPIO6** | **GPIO12** |
| **GPIO13** | GND | | **GPIO13** | GND |
| **GPIO19** | **GPIO16** | | **GPIO19** | **GPIO16** |
| **GPIO26** | **GPIO20** | | **GPIO26** | **GPIO20** |
| GND | **GPIO21** | | GND | **GPIO21** |
- *GND = Ground* - *GND = Ground*
- *3V3 = 3.3 Volts* - *3V3 = 3.3 Volts*
- *5V = 5 Volts* - *5V = 5 Volts*
- *DNC = Do not connect (special use pins)* - *DNC = Do not connect (special use pins)*
2. **Wiring** 2. **Wiring**
All components must be wired up correctly before using with this library. All components must be wired up correctly before using with this library.
3. **Keep your program alive with `signal.pause`** 3. **Keep your program alive with `signal.pause`**
The following program looks like it should turn an LED on: The following program looks like it should turn an LED on:
```python from gpiozero import led
from gpiozero import led
led = LED(2) led = LED(2)
led.on()
led.on() And it does, if you're using the Python shell, IPython shell or IDLE shell,
``` but if you saved this program as a Python file and ran it, it would flash
on for a moment then the program would end and it would turn off.
And it does, if you're using the Python shell, IPython shell or IDLE shell, The following file includes an intentional `pause` to keep the program
but if you saved this program as a Python file and ran it, it would flash alive:
on for a moment then the program would end and it would turn off.
The following file includes an intentional `pause` to keep the program from gpiozero import LED
alive: from signal import pause
```python led = LED(2)
from gpiozero import LED led.on()
from signal import pause pause()
led = LED(2) Now running the program will stay running, leaving the LED on, until it is
forced to quit.
led.on() Similarly, when setting up callbacks on button presses or other input
devices, the program needs to be running for the events to be detected:
pause() from gpiozero import Button
``` from signal import pause
Now running the program will stay running, leaving the LED on, until it is button = Button(2)
forced to quit. button.when_pressed = lambda: print("Button was pressed!")
pause()
Similarly, when setting up callbacks on button presses or other input
devices, the program needs to be running for the events to be detected:
```python
from gpiozero import Button
from signal import pause
button = Button(2)
button.when_pressed = lambda: print("Button was pressed!")
pause()
```