Created
January 28, 2020 09:56
-
-
Save anthonyeden/b040e4f8037fa1169dcc10667aac91e6 to your computer and use it in GitHub Desktop.
LWRP Example: Silence Detection & GPIO
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
# Requires https://github.com/anthonyeden/Livewire-Routing-Protocol-Client | |
import time | |
from LWRPClient import LWRPClient | |
# Connect to audio node | |
LWRP_Audio = LWRPClient("192.168.1.5", 93) | |
LWRP_Audio.login() | |
# Connect to GPIO node | |
LWRP_Logic = LWRPClient("192.168.1.5", 93) | |
LWRP_Logic.login() | |
def silence(data): | |
# TODO: Add some logic here to work out which channel is silent | |
print(data) | |
# Set the new GPO state | |
# 1 = Channel | |
# 2 = Pin | |
# 3 = State | |
LWRP_Logic.setGPO("1", "2", "low") | |
if __name__ == "__main__": | |
# Create a subscription for silence events | |
LWRP_Audio.levelAlertSub(silence) | |
# Loop forever while the callbacks execute in another thread | |
while True: | |
time.sleep(10) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment