Skip to content
Snippets Groups Projects
Commit f97cd01c authored by Jevgeni Kiski's avatar Jevgeni Kiski
Browse files
parent cd87cccb
Branches
Tags
No related merge requests found
...@@ -9,6 +9,7 @@ GPIO Modules ...@@ -9,6 +9,7 @@ GPIO Modules
------------ ------------
- Raspberry Pi GPIO (`raspberrypi`) - Raspberry Pi GPIO (`raspberrypi`)
- Orange Pi GPIO (`orangepi`)
- PCF8574 IO chip (`pcf8574`) - PCF8574 IO chip (`pcf8574`)
- PiFaceDigital 2 IO board (`piface2`) - PiFaceDigital 2 IO board (`piface2`)
- Beaglebone GPIO (`beaglebone`) - Beaglebone GPIO (`beaglebone`)
...@@ -151,6 +152,17 @@ sensor_inputs: ...@@ -151,6 +152,17 @@ sensor_inputs:
``` ```
### OrangePi boards
You need to specify what OrangePi board you use
```yaml
gpio_modules:
- name: orangepi
module: orangepi
board: zero # Supported: ZERO, R1, ZEROPLUS, ZEROPLUS2H5, ZEROPLUS2H3, PCPCPLUS, ONE, LITE, PLUS2E, PC2, PRIME
```
#### SSL/TLS #### SSL/TLS
You may want to connect to a remote server, in which case it's a good idea to use an encrypted connection. If the server supports this, then you can supply the relevant config values for the [tls_set()](https://github.com/eclipse/paho.mqtt.python#tls_set) command. You may want to connect to a remote server, in which case it's a good idea to use an encrypted connection. If the server supports this, then you can supply the relevant config values for the [tls_set()](https://github.com/eclipse/paho.mqtt.python#tls_set) command.
...@@ -215,6 +227,10 @@ gpio_modules: ...@@ -215,6 +227,10 @@ gpio_modules:
i2c_bus_num: 1 i2c_bus_num: 1
chip_addr: 0x20 chip_addr: 0x20
- name: orangepi
module: orangepi
board: r1
digital_inputs: digital_inputs:
- name: button - name: button
module: raspberrypi module: raspberrypi
......
from pi_mqtt_gpio.modules import GenericGPIO, PinDirection, PinPullup
REQUIREMENTS = ("OrangePi.GPIO",)
DIRECTIONS = None
PULLUPS = None
class GPIO(GenericGPIO):
"""
Implementation of GPIO class for Raspberry Pi native GPIO.
"""
def __init__(self, config):
global DIRECTIONS, PULLUPS
import OPi.GPIO as gpio
self.io = gpio
DIRECTIONS = {PinDirection.INPUT: gpio.IN, PinDirection.OUTPUT: gpio.OUT}
PULLUPS = {
PinPullup.OFF: gpio.PUD_OFF,
PinPullup.UP: gpio.PUD_UP,
PinPullup.DOWN: gpio.PUD_DOWN,
}
board = config["board"].upper()
if not hasattr(gpio, board):
raise AssertionError("%s board not found" % board)
gpio.setboard(getattr(gpio, board))
gpio.setmode(gpio.BCM)
def setup_pin(self, pin, direction, pullup, pin_config):
direction = DIRECTIONS[direction]
if pullup is None:
pullup = PULLUPS[PinPullup.OFF]
else:
pullup = PULLUPS[pullup]
initial = {None: -1, "low": 0, "high": 1}[pin_config.get("initial")]
self.io.setup(pin, direction, pull_up_down=pullup, initial=initial)
def set_pin(self, pin, value):
self.io.output(pin, value)
def get_pin(self, pin):
return self.io.input(pin)
def cleanup(self):
self.io.cleanup()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment