-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:CarlFK/voctomix-outcasts
- Loading branch information
Showing
10 changed files
with
106 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from abc import ABC, abstractmethod | ||
|
||
__all__ = ['BasePlugin'] | ||
|
||
|
||
class BasePlugin(ABC): | ||
"""An abstract plugin class, that all other plugins inherit from.""" | ||
|
||
def __init__(self, config): | ||
... | ||
|
||
@abstractmethod | ||
def tally_on(self) -> None: | ||
"""Called when the tally light should be turned on.""" | ||
... | ||
|
||
@abstractmethod | ||
def tally_off(self) -> None: | ||
"""Called when the tally light should be turned off.""" | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,32 @@ | ||
# Plugin to provide a tally light interface for a Raspberry Pi's GPIO | ||
DO_GPIO = True | ||
""" | ||
Plugin to provide a tally light interface for a Raspberry Pi's GPIO. | ||
It requires RPi.GPIO. | ||
""" | ||
|
||
from .base_plugin import BasePlugin | ||
|
||
try: | ||
import RPi.GPIO as GPIO | ||
GPIO.setmode(GPIO.BOARD) | ||
except ImportError: | ||
DO_GPIO = False | ||
# We are probably not running on a Raspberry Pi. | ||
GPIO = None | ||
|
||
__all__ = ['RpiGpio'] | ||
|
||
class RpiGpio: | ||
class RpiGpio(BasePlugin): | ||
def __init__(self, config): | ||
if not DO_GPIO: | ||
raise ValueError('RpiGpio will not work on this platform. Is RPi.GPIO installed?') | ||
if not GPIO: | ||
raise NotImplementedError('RpiGpio will not work on this platform. Is RPi.GPIO installed?') | ||
|
||
all_gpios = [int(i) for i in config.getlist('rpi', 'gpios')] | ||
self.gpio_port = int(config.get('rpi', 'gpio_red')) | ||
self.gpio_port = int(config.get('rpi', 'gpio')) | ||
|
||
GPIO.setup(all_gpios, GPIO.OUT) | ||
GPIO.output(all_gpios, GPIO.HIGH) | ||
GPIO.setup(self.gpio_port, GPIO.OUT) | ||
GPIO.output(self.gpio_port, GPIO.HIGH) | ||
|
||
def tally_on(self): | ||
GPIO.output(self.gpio_port, GPIO.LOW) | ||
|
||
def tally_off(self): | ||
GPIO.output(self.gpio_port, GPIO.HIGH) | ||
|
||
def __del__(self): | ||
GPIO.cleanup() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters