Update docs for v0.8.0

This commit is contained in:
Ben Nuttall
2015-10-17 12:36:41 +01:00
parent fcc7c47fe3
commit b7cce51497
7 changed files with 256 additions and 54 deletions

View File

@@ -48,18 +48,18 @@ button = Button(pin=2, pull_up=False)
| Method | Description | Arguments |
| ------ | ----------- | --------- |
| `wait_for_press()` | Halt the program until the button is pressed. | `timeout` - The number of seconds to wait before proceeding if no event is detected. Default: `None` |
| `wait_for_press()` | Halt the program until the button is pressed. | `timeout` - The number of seconds to wait before proceeding if no event is detected. Default: `None` |
| `wait_for_release()` | Halt the program until the button is released. | `timeout` - The number of seconds to wait before proceeding if no event is detected. Default: `None` |
### Properties
| Property | Description | Type |
| -------- | ----------- | ---- |
| `pin` | The GPIO pin number the button is connected to. | Integer |
| `is_pressed` | The current state of the pin (`True` if pressed; otherwise `False`). | Boolean |
| `pull_up` | The pull state of the pin (`True` if pulled up; `False` if pulled down). | Boolean |
| `when_pressed` | A reference to the function to be called when the button is pressed. | None or Function |
| `when_released` | A reference to the function to be called when the button is released. | None or Function |
| `pin` | The GPIO pin number the button is connected to. | Integer |
| `is_pressed` | The current state of the pin (`True` if pressed; otherwise `False`). | Boolean |
| `pull_up` | The pull state of the pin (`True` if pulled up; `False` if pulled down). | Boolean |
| `when_pressed` | A reference to the function to be called when the button is pressed. | None or Function |
| `when_released` | A reference to the function to be called when the button is released. | None or Function |
## Motion Sensor
@@ -89,11 +89,19 @@ pir = MotionSensor(4)
### Methods
...
| Method | Description | Arguments |
| ------ | ----------- | --------- |
| `wait_for_motion()` | Halt the program until motion is detected. | `timeout` - The number of seconds to wait before proceeding if no motion is detected. Default: `None` |
| `wait_for_no_motion()` | Halt the program until no motion is detected. | `timeout` - The number of seconds to wait before proceeding if motion is still detected. Default: `None` |
### Properties
...
| Property | Description | Type |
| -------- | ----------- | ---- |
| `pin` | The GPIO pin number the sensor is connected to. | Integer |
| `motion_detected` | The current state of the sensor (`True` if motion is detected; otherwise `False`). | Boolean |
| `when_motion` | A reference to the function to be called when motion is detected. | None or Function |
| `when_no_motion` | A reference to the function to be called when no motion is detected. | None or Function |
## Light Sensor
@@ -120,15 +128,23 @@ light = LightSensor(4)
### Methods
...
| Method | Description | Arguments |
| ------ | ----------- | --------- |
| `wait_for_light()` | Halt the program until light is detected. | `timeout` - The number of seconds to wait before proceeding if light is not detected. Default: `None` |
| `wait_for_dark()` | Halt the program until darkness is detected. | `timeout` - The number of seconds to wait before proceeding if darkness is not detected. Default: `None` |
### Properties
...
| Property | Description | Type |
| -------- | ----------- | ---- |
| `pin` | The GPIO pin number the sensor is connected to. | Integer |
| `light_detected` | The current state of the sensor (`True` if light; otherwise `False`). | Boolean |
| `when_light` | A reference to the function to be called when light is detected. | None or Function |
| `when_dark` | A reference to the function to be called when darkness is detected. | None or Function |
## Temperature Sensor
Digital Temperature Sensor.
One-wire Digital Temperature Sensor.
### Wiring
@@ -148,14 +164,16 @@ Create a `TemperatureSensor` object:
temp = TemperatureSensor()
```
### Properties
...
### Methods
...
### Properties
| Property | Description | Type |
| -------- | ----------- | ---- |
| `value` | The current temperature reading in degrees Celsius. | Float |
## MCP3008 Analogue-to-Digital Converter
MCP3008 ADC (Analogue-to-Digital converter).
@@ -175,18 +193,38 @@ Ensure the `MCP3008` class is imported at the top of the file:
from gpiozero import MCP3008
```
Access an input value with the `MCP3008`'s context manager:
Create an `MCP3008` object:
```python
pot = MCP3008()
```
Read the value of the device:
```python
print(pot.value)
```
Alternatively, access an input value with the `MCP3008`'s context manager:
```python
with MCP3008() as pot:
print(pot.read())
print(pot.value)
```
It is possible to specify the `bus`, the `device` and the `channel` you wish to
access. The previous example used the default value of `0` for each of these.
To specify them, pass them in as arguments:
It is possible to specify the `device` and the `channel` you wish to access.
The previous example used the default value of `0` for each of these. To
specify them, pass them in as arguments:
```python
with MCP3008(bus=1, device=1, channel=4) as pot:
print(pot.read())
pot = MCP3008(device=1, channel=7)
```
## MCP3004 Analogue-to-Digital Converter
MCP3004 ADC (Analogue-to-Digital converter).
The MCP3004 chip provides access to up to 4 analogue inputs, such as
potentiometers, and read their values in digital form.
The interface is identical to `MCP3008`.