46 lines
905 B
Python
Executable File
46 lines
905 B
Python
Executable File
#!/usr/bin/env python
|
|
tty = '/dev/ttyACM1'
|
|
baud = 9600
|
|
|
|
import serial
|
|
import time
|
|
|
|
ser = serial.Serial(tty, baud)
|
|
|
|
# Setup
|
|
print("Setup")
|
|
print(ser)
|
|
print("------")
|
|
|
|
ser.write("!Booya\n")
|
|
ser.readline()
|
|
|
|
# Final Loop
|
|
volume = 0
|
|
title = "Blub"
|
|
artist = "ee"
|
|
album = "dd"
|
|
repeat = True
|
|
shuffle = True
|
|
|
|
|
|
def output(string):
|
|
ser.write(string+"\n")
|
|
time.sleep(0.4)
|
|
|
|
def check_serial():
|
|
if (ser.inWaiting()>0): #if incoming bytes are waiting to be read from the serial input buffer
|
|
data_str = ser.read(ser.inWaiting()).decode('ascii') #read the bytes and convert from binary array to ASCII
|
|
print(data_str)
|
|
while True:
|
|
volume = (volume + 1)
|
|
output("V" + str(volume))
|
|
output("T" + title)
|
|
output("A" + artist)
|
|
output("a" + album)
|
|
output("r" + str(repeat))
|
|
output("z" + str(shuffle))
|
|
print("--- output ---")
|
|
check_serial()
|
|
print("--- output ---")
|