-
-
Save tvass/a9191149a69855f5f3c676af9135ee3a to your computer and use it in GitHub Desktop.
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
#!/usr/bin/python3 | |
# -*- coding: utf-8 -*- | |
""" | |
My version of the Internet Radio project. | |
""" | |
import serial | |
import subprocess, os | |
from time import sleep | |
print("starting radio ...") | |
my_env = os.environ | |
#my_env["MPD_HOST"] = "192.168.1.30" | |
ser = serial.Serial('/dev/ttyS0', 9600) | |
while True: | |
line = ser.readline().decode().strip('\r\n') | |
print(line) | |
if line.startswith('mpc next') or line.startswith('mpc prev'): | |
proc = subprocess.Popen(line, shell=True) | |
proc.wait() | |
proc = subprocess.Popen('mpc current -f %file% -h 192.168.1.30|cut -d"#" -f4', stdout=subprocess.PIPE, shell=True) | |
result = proc.communicate()[0] | |
ser.write("lcd %s".encode() % result) | |
if line.startswith('mpc vol'): | |
proc = subprocess.Popen(line, shell=True) | |
proc.wait() | |
proc = subprocess.Popen("mpc volume -h 192.168.1.30 |tr -dc '0-9'", stdout=subprocess.PIPE, shell=True) | |
volume = proc.communicate()[0] | |
ser.write("vol %s".encode() % volume) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment