seriel VFD Display an TX-Output vom Arduino Uno.
Status: Funktioniert nur bei getsratetem Seriellen Monitor!
falls abgestürzt in der Konsole unter root Port freigeben
sudo bash
rm /var/lock/LCK..ttyACM1
To Do: Interpret, Song trennen auf zwei zeilen ausgeben ggf. scrollen
Arduino Sketch:
/*
Sketch um Rhythmbox Infos auf VFD auzusgeben.
rb-lcd.py Skript starten!!
*/
const int numCols = 20;
const int numRows = 2;
int i;
int empty;
////////////
void setup()
{
Serial.begin(9600);
Serial.write(0x04); //DIM
//Serial.write(0x09); //HT
//Serial.write(0x11); //DC1
}
void loop()
{
if (Serial.available()) {
delay(100);
Serial.write(0x1B); //ESC
Serial.write((byte)0x00); //Cursor 0,0
while (Serial.available() > 0) {
Serial.write(Serial.read());
delay(100);
i++;
if (i == (numCols * numRows)) {
i = 0;
// this to clear the rest of the serial I/O
while (Serial.available() > 0) {
empty = Serial.read();
}
}
}
}
}
Phyton Skript:
#!/usr/bin/python
#Created By Patrick van der Leer a.k.a. Junke
#
#
### CONFIG ###
dev = "/dev/ttyACM0" # path to the arduino
rows = 2 # number of rows of your LCD
cols = 20 # number of cols of your LCD
###
import os, time
#from subprocess import Popen, PIPE
message = " "
song = " "
def display():
error = os.system('echo "%s" >> %s' %(message,dev,))
if error == 0:
print "Song '%s'" %(message,)
else:
print "Failed to display '%s'" %(message,)
### loop ###
while True:
p = os.popen('rhythmbox-client --print-playing')
song = p.readline()
p.close()
song = song[:-1]
while len(song) < (rows * cols): # to make sure the arduino doesnt
song += " " # fill the rest up with black
if song != message:
message = song
display()
time.sleep(5)
Keine Kommentare:
Kommentar veröffentlichen