mirror of
https://github.com/home-assistant/core.git
synced 2025-04-27 02:37:50 +00:00
Move imports in bbb_gpio component (#27813)
This commit is contained in:
parent
d95b4a6a0b
commit
21754fd7cc
@ -1,6 +1,8 @@
|
|||||||
"""Support for controlling GPIO pins of a Beaglebone Black."""
|
"""Support for controlling GPIO pins of a Beaglebone Black."""
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from Adafruit_BBIO import GPIO # pylint: disable=import-error
|
||||||
|
|
||||||
from homeassistant.const import EVENT_HOMEASSISTANT_START, EVENT_HOMEASSISTANT_STOP
|
from homeassistant.const import EVENT_HOMEASSISTANT_START, EVENT_HOMEASSISTANT_STOP
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
@ -11,7 +13,6 @@ DOMAIN = "bbb_gpio"
|
|||||||
def setup(hass, config):
|
def setup(hass, config):
|
||||||
"""Set up the BeagleBone Black GPIO component."""
|
"""Set up the BeagleBone Black GPIO component."""
|
||||||
# pylint: disable=import-error
|
# pylint: disable=import-error
|
||||||
from Adafruit_BBIO import GPIO
|
|
||||||
|
|
||||||
def cleanup_gpio(event):
|
def cleanup_gpio(event):
|
||||||
"""Stuff to do before stopping."""
|
"""Stuff to do before stopping."""
|
||||||
@ -27,39 +28,29 @@ def setup(hass, config):
|
|||||||
|
|
||||||
def setup_output(pin):
|
def setup_output(pin):
|
||||||
"""Set up a GPIO as output."""
|
"""Set up a GPIO as output."""
|
||||||
# pylint: disable=import-error
|
|
||||||
from Adafruit_BBIO import GPIO
|
|
||||||
|
|
||||||
GPIO.setup(pin, GPIO.OUT)
|
GPIO.setup(pin, GPIO.OUT)
|
||||||
|
|
||||||
|
|
||||||
def setup_input(pin, pull_mode):
|
def setup_input(pin, pull_mode):
|
||||||
"""Set up a GPIO as input."""
|
"""Set up a GPIO as input."""
|
||||||
# pylint: disable=import-error
|
|
||||||
from Adafruit_BBIO import GPIO
|
|
||||||
|
|
||||||
GPIO.setup(pin, GPIO.IN, GPIO.PUD_DOWN if pull_mode == "DOWN" else GPIO.PUD_UP)
|
GPIO.setup(pin, GPIO.IN, GPIO.PUD_DOWN if pull_mode == "DOWN" else GPIO.PUD_UP)
|
||||||
|
|
||||||
|
|
||||||
def write_output(pin, value):
|
def write_output(pin, value):
|
||||||
"""Write a value to a GPIO."""
|
"""Write a value to a GPIO."""
|
||||||
# pylint: disable=import-error
|
|
||||||
from Adafruit_BBIO import GPIO
|
|
||||||
|
|
||||||
GPIO.output(pin, value)
|
GPIO.output(pin, value)
|
||||||
|
|
||||||
|
|
||||||
def read_input(pin):
|
def read_input(pin):
|
||||||
"""Read a value from a GPIO."""
|
"""Read a value from a GPIO."""
|
||||||
# pylint: disable=import-error
|
|
||||||
from Adafruit_BBIO import GPIO
|
|
||||||
|
|
||||||
return GPIO.input(pin) is GPIO.HIGH
|
return GPIO.input(pin) is GPIO.HIGH
|
||||||
|
|
||||||
|
|
||||||
def edge_detect(pin, event_callback, bounce):
|
def edge_detect(pin, event_callback, bounce):
|
||||||
"""Add detection for RISING and FALLING events."""
|
"""Add detection for RISING and FALLING events."""
|
||||||
# pylint: disable=import-error
|
|
||||||
from Adafruit_BBIO import GPIO
|
|
||||||
|
|
||||||
GPIO.add_event_detect(pin, GPIO.BOTH, callback=event_callback, bouncetime=bounce)
|
GPIO.add_event_detect(pin, GPIO.BOTH, callback=event_callback, bouncetime=bounce)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user