Hallo, ich habe eine PhonieBox nach dieser Anleitung gebaut und würde gerne noch ein Display daran anschließen. Ich habe mich schon im Ordner Python Scripts umgesehen aber verstehe nicht ganz, wie ich auf die Informationen wie das Abgespielte Lied, die aktuelle Position im Song, ... zugreifen kann. Über Hilfe wäre ich sehr dankbar.
Display an Phoniebox anschließen
-
lordofweed -
6. Januar 2019 um 14:36 -
Unerledigt
Heute ist Stammtischzeit:
Jeden Donnerstag 20:30 Uhr hier im Chat.
Wer Lust hat, kann sich gerne beteiligen. ;)
Jeden Donnerstag 20:30 Uhr hier im Chat.
Wer Lust hat, kann sich gerne beteiligen. ;)
-
-
Display an Phoniebox anschließen? Schau mal ob du hier fündig wirst!
-
- Offizieller Beitrag
Hallo lordofweed,
willkommen im Forum!
Unser User splitti79 hat das hier OLED Display für die Phoniebox bereits umgesetzt.
-
Was interessiert Dich genau?
-
Erstmal danke für die Hilfe, damit ( OLED Display für die Phoniebox ) bin ich weitergekommen.
Was interessiert Dich genau?
Der Anschluss eines Displays über einen LCM 1602 controller. Ich habe bereits das Display auf einem Arduino zum laufen bekommen, jedoch kann ich beim RPi die Adresse des Displays nicht finden (siehe unterer Screenshot), obwohl ich alles nach dieser Anleitung installiert habe.
-
Mit dem Controller hab ich keinerlei Erfahrung, ich gehe direkt auf den Pi, sorry.
-
Hy lordofweed,
ich habe das gleiche Problem.
Ich habe mir ein 2 Zeilen 8 Zeichen Display von Joy-it gekauft und nach deren Anleitung angeschlossen.
Alles funzte super.Mit 'sudo i2cdetect -y 1' konnte ich die Adresse des i2C Bus auslesen.
Aber nachdem ich, wie du, von MiczFlor die Classic-Version aufgespielt habe, kann ich die Adresse nicht mehr auslesen.
Wenn ich dann über ein Script Sachen an das Display sende, bekomme ich Fehlermeldungen angezeigt.Ich nutze Raspberry Zero mit Raspbian Stretch Lite
Vielleicht liegt es daran. Welche Config hast du?.
Grüße
-
Alles klar, der gpio Buttons Service blockiert einen PIN. Ihr müsst die Datei editieren. Sucht mal per
ps -ef | grep gpio | grep -v grep
Da steht dann die Datei, den shut Button deaktivieren.
Hoffe das passt, sitze gerade im Restaurant...
-
Hallo splitti79,
Danke für den Tip.
Jetzt läuft es.Ich bin echt happy.
Danke Danke.
Grüße
-
Life can und be simple
-
Hallo liebes Forum,
ich habe alles nach folgender Anleitung ausgeführt. Ich habe die Phoniebox software mit dem Webinterface am laufen Jetzt habe ich schon eine Ausgabe auf dem Display. Jedoch weiß ich jetzt nicht wie ich z.B den Track oder irgendwas anderes auf dem Display ausgegeben bekomme. Nachdem ja hier schon viele eine Display eingebaut haben gibt es ja das ein oder andere Skript das ich irgendwie als Vorlage nehmen kann. Mit dem Oled Skript bzw. der Installation bin ich leider gar nicht weiter gekommen.
-
Du vermischst hier gerade auch zwei völlig verschiedene Displays. Ein Benziner fährt auch nicht mit Diesel, auch wenn er die selbe Straße (GPIOs) nutzt.
Das OLED Script ist für ein solches Display:
Schau Dir mal dieses Script hier an, das ist für Dein Display: [Projekt] jukebox4kids (Jukebox für Kinder)
-
Hallo splitti vielen dank für den Hinweis. Mit einem Teil von deinem Skript und noch etwas das ich im Internet gefunden hatte, hat es den Track schon auf dem Display irgendwie angezeigt. Die hälfte war dennoch abgeschnitten.
Naja jetzt kommt im Display nur
"Hallo Sohnemann,
Phoniebox zickt.
Papa macht das schon"
Leider bin ich der Programmiersprache nicht so mächtig. Immerhin scheint es gleich beim Booten die Datei zum starten, das hat es beim letzten mal nicht gemacht.
-
Kann mir vielleicht jemand sagen warum bei mir immer folgendes angezeigt wird?
Anbei kurz das Skript. Vielleicht kann da einer kurz einen Augenblick rein schauen.
"Hallo Sohnemann,
Phoniebox zickt.
Papa macht das schon"
Wann wird das angezeigt?
Vielen Dank schon mal für eire Hilfe
-
- Offizieller Beitrag
arum bei mir immer folgendes angezeigt wird?
Weil es so im Script steht ;). Wenn ein Fehler auftritt, zeige diesen Text an.
Wann wird das angezeigt?
Wenn ein Fehler ab Zeile 169 auftritt. Leider unterdrückst du dir durch das Try/Except auch die helfende Fehlermeldung. also Zeile 169 löschen/ auskommentieren, Einrückungen danach anpassen, Zeilen 220-225 löschen auskommentieren. Mal sehen was er dann sagt
-
Danke dbv
Also wenn man vor die Zeile 169 ein # und vor Zeile 220 ein # setzt dann bleibt das Display einfach aus
-
- Offizieller Beitrag
Kann durchaus sein, es ist ja auch nicht das, was ich geschrieben habe . Ersatz mal main() durch das.
Python
Alles anzeigendef main(): lcd_init() while True: mpcstatus = GetMPC("mpc status") playing = mpcstatus.split("\n")[1].split(" ")[0] #Split to see if mpc is playing at the moment file = GetMPC("mpc -f %file% current") # Get the current title if playing == "[playing]": # If it is currently playing if file.startswith("http"): # if it is a http stream! name = GetMPC("mpc -f %name% current") titel = GetMPC("mpc -f %title% current") if len(name) > LCD_WIDTH: lcd_string(name[0:LCD_WIDTH],LCD_LINE_1) lcd_string(name[LCD_WIDTH:],LCD_LINE_2) else: lcd_string(name,LCD_LINE_1) lcd_string(titel,LCD_LINE_3) lcd_string("Playing",LCD_LINE_4) else: # if it is not a stream album = GetMPC("mpc -f %album% current" ) titel = GetMPC("mpc -f %title% current") track = GetMPC("mpc -f %track% current") time = GetMPC("mpc -f %time% current") artist = GetMPC("mpc -f %artist% current") lcd_string(""+titel,LCD_LINE_1) lcd_string(""+artist,LCD_LINE_2) lcd_string(""+album,LCD_LINE_3) lcd_string("Playing Track "+track,LCD_LINE_4) elif playing == "[paused]": # If is is paused if file.startswith("http"): # stream name = GetMPC("mpc -f %name% current") titel = GetMPC("mpc -f %title% current") if len(name) > LCD_WIDTH: lcd_string(name[0:LCD_WIDTH],LCD_LINE_1) lcd_string(name[LCD_WIDTH:],LCD_LINE_2) else: lcd_string(name,LCD_LINE_1) lcd_string(titel,LCD_LINE_3) lcd_string("Paused",LCD_LINE_4) else: #Not stream album = GetMPC("mpc -f %album% current") titel = GetMPC("mpc -f %title% current") track = GetMPC("mpc -f %track% current") time = GetMPC("mpc -f %time% current") artist = GetMPC("mpc -f %artist% current") lcd_string(""+titel,LCD_LINE_1) lcd_string(""+artist,LCD_LINE_2) lcd_string(""+album,LCD_LINE_3) lcd_string("Paused Track "+track,LCD_LINE_4) else: lcd_string("Hallo Sohnemann,",LCD_LINE_1) lcd_string("PhonieBox bereit! ",LCD_LINE_2) lcd_string(" ",LCD_LINE_3) lcd_string(date.today().strftime("%A %d. %B"),LCD_LINE_4)
-
Also jetzt habe ich es so: Das Display ist immernoch aus
Python
Alles anzeigen#!/usr/bin/python # -*- coding: latin-1 -*- #-------------------------------------- # ___ ___ _ ____ # / _ \/ _ \(_) __/__ __ __ # / , _/ ___/ /\ \/ _ \/ // / # /_/|_/_/ /_/___/ .__/\_, / # /_/ /___/ # # lcd_i2c.py # LCD test script using I2C backpack. # Supports 16x2 and 20x4 screens. # # Author : Matt Hawkins # Date : 20/09/2015 # # http://www.raspberrypi-spy.co.uk/ # # Copyright 2015 Matt Hawkins # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # #-------------------------------------- import smbus import time from datetime import date import atexit # Define some device parameters I2C_ADDR = 0x27 # I2C device address LCD_WIDTH = 20 # Maximum characters per line # Define some device constants LCD_CHR = 1 # Mode - Sending data LCD_CMD = 0 # Mode - Sending command LCD_LINE_1 = 0x80 # LCD RAM address for the 1st line LCD_LINE_2 = 0xC0 # LCD RAM address for the 2nd line LCD_LINE_3 = 0x94 # LCD RAM address for the 3rd line LCD_LINE_4 = 0xD4 # LCD RAM address for the 4th line LCD_BACKLIGHT = 0x08 # On #LCD_BACKLIGHT = 0x00 # Off ENABLE = 0b00000100 # Enable bit lastMSG = [] lastMSG.append("nix") lastMSG.append("nix") lastMSG.append("nix") lastMSG.append("nix") lastMSG.append("nix") lstMSGi = [] lstMSGi.append(1) lstMSGi.append(1) lstMSGi.append(1) lstMSGi.append(1) lstMSGi.append(1) # Timing constants E_PULSE = 0.0005 E_DELAY = 0.0005 #Open I2C interface #bus = smbus.SMBus(0) # Rev 1 Pi uses 0 bus = smbus.SMBus(1) # Rev 2 Pi uses 1 def lcd_init(): # Initialise display lcd_byte(0x33,LCD_CMD) # 110011 Initialise lcd_byte(0x32,LCD_CMD) # 110010 Initialise lcd_byte(0x06,LCD_CMD) # 000110 Cursor move direction lcd_byte(0x0C,LCD_CMD) # 001100 Display On,Cursor Off, Blink Off lcd_byte(0x28,LCD_CMD) # 101000 Data length, number of lines, font size lcd_byte(0x01,LCD_CMD) # 000001 Clear display time.sleep(E_DELAY) def lcd_byte(bits, mode): # Send byte to data pins # bits = the data # mode = 1 for data # 0 for command bits_high = mode | (bits & 0xF0) | LCD_BACKLIGHT bits_low = mode | ((bits<<4) & 0xF0) | LCD_BACKLIGHT # High bits bus.write_byte(I2C_ADDR, bits_high) lcd_toggle_enable(bits_high) # Low bits bus.write_byte(I2C_ADDR, bits_low) lcd_toggle_enable(bits_low) def lcd_toggle_enable(bits): # Toggle enable time.sleep(E_DELAY) bus.write_byte(I2C_ADDR, (bits | ENABLE)) time.sleep(E_PULSE) bus.write_byte(I2C_ADDR,(bits & ~ENABLE)) time.sleep(E_DELAY) def lcd_string(message,line): # Send string to display # If a message is longer than LCD_WIDTH (20) it will be cutted and then moves message = message.replace("\n"," ") if line == 0x80: li = 1 if line == 0xC0: li = 2 if line == 0x94: li = 3 if line == 0xD4: li = 4 global lastMSG global lstMSGi lcd_byte(line, LCD_CMD) if lastMSG[li] == message: if len(message) > LCD_WIDTH: for i in range(LCD_WIDTH): i2 = i + lstMSGi[li] lcd_byte(ord(message[i2]),LCD_CHR) test = lstMSGi[li] + LCD_WIDTH if test < len(message): lstMSGi[li] += 1 else: lstMSGi[li] = 0 else: message = message.ljust(LCD_WIDTH," ") for i in range(LCD_WIDTH): lcd_byte(ord(message[i]),LCD_CHR) else: lastMSG[li] = message lstMSGi[li] = 0 def GetMPC(command): from subprocess import check_output process = check_output(command.split()) return process def exit_handler(): global LCD_BACKLIGHT LCD_BACKLIGHT = 0x00 # Off lcd_byte(0x01, LCD_CMD) def main(): lcd_init() while True: mpcstatus = GetMPC("mpc status") playing = mpcstatus.split("\n")[1].split(" ")[0] #Split to see if mpc is playing at the moment file = GetMPC("mpc -f %file% current") # Get the current title if playing == "[playing]": # If it is currently playing if file.startswith("http"): # if it is a http stream! name = GetMPC("mpc -f %name% current") titel = GetMPC("mpc -f %title% current") if len(name) > LCD_WIDTH: lcd_string(name[0:LCD_WIDTH],LCD_LINE_1) lcd_string(name[LCD_WIDTH:],LCD_LINE_2) else: lcd_string(name,LCD_LINE_1) lcd_string(titel,LCD_LINE_3) lcd_string("Playing",LCD_LINE_4) else: # if it is not a stream album = GetMPC("mpc -f %album% current" ) titel = GetMPC("mpc -f %title% current") track = GetMPC("mpc -f %track% current") time = GetMPC("mpc -f %time% current") artist = GetMPC("mpc -f %artist% current") lcd_string(""+titel,LCD_LINE_1) lcd_string(""+artist,LCD_LINE_2) lcd_string(""+album,LCD_LINE_3) lcd_string("Playing Track "+track,LCD_LINE_4) elif playing == "[paused]": # If is is paused if file.startswith("http"): # stream name = GetMPC("mpc -f %name% current") titel = GetMPC("mpc -f %title% current") if len(name) > LCD_WIDTH: lcd_string(name[0:LCD_WIDTH],LCD_LINE_1) lcd_string(name[LCD_WIDTH:],LCD_LINE_2) else: lcd_string(name,LCD_LINE_1) lcd_string(titel,LCD_LINE_3) lcd_string("Paused",LCD_LINE_4) else: #Not stream album = GetMPC("mpc -f %album% current") titel = GetMPC("mpc -f %title% current") track = GetMPC("mpc -f %track% current") time = GetMPC("mpc -f %time% current") artist = GetMPC("mpc -f %artist% current") lcd_string(""+titel,LCD_LINE_1) lcd_string(""+artist,LCD_LINE_2) lcd_string(""+album,LCD_LINE_3) lcd_string("Paused Track "+track,LCD_LINE_4) else: lcd_string("Hallo Sohnemann,",LCD_LINE_1) lcd_string("PhonieBox bereit! ",LCD_LINE_2) lcd_string(" ",LCD_LINE_3) lcd_string(date.today().strftime("%A %d. %B"),LCD_LINE_4) atexit.register(exit_handler) if __name__ == '__main__': try: main() except KeyboardInterrupt: LCD_BACKLIGHT = 0x00 # Off lcd_byte(0x01, LCD_CMD) pass finally: LCD_BACKLIGHT = 0x00 # Off lcd_byte(0x01, LCD_CMD)
Folgende Fehlermeldung kommt
Traceback (most recent call last):
File "/home/pi/oled_phoniebox/oled_phoniebox.py", line 221, in <module>
main()
File "/home/pi/oled_phoniebox/oled_phoniebox.py", line 166, in main
playing = mpcstatus.split("\n")[1].split(" ")[0] #Split to see if mpc is playing at the moment
TypeError: a bytes-like object is required, not 'str'
-
Hallo,
Python Skripte zeigst Du besser im Code-Block. Klicke dazu auf das </>-Symbol im schwarzen Balken über der Eingabe.
Sonst gehen die führenden Leerzeichen verloren.
Dazu mußt Du keinen neuen Beitrag zu verfassen, sondern klickst unter Beitrag #17 auf Beitrag bearbeiten
Schönen Gruß, kle
Edit: super, sieht doch besser aus? Schiebe bitte auch die Fehlermeldungen in einen Code-Block - Danke.
-
dbv egal was ich mache er spuckt mir immer in dieser Zeile immer das aus
Codeplaying = mpcstatus.split("\n")[1]#.split(" ")[0] #Split to see if mpc is playing at the moment
IndexError: list index out of range
Hast du vielleicht eine Idee ich denke das ist der größte Knackpunkt im Moment.
-
- Offizieller Beitrag
Also jetzt habe ich es so: Das Display ist immernoch aus
Aber das ist genau das, was wir erreichen wollten. Deswegen kommt nur deine Meldung von oben. Nun geht daran rauszufinden warum er das macht.
Hau mal ein print mit in GetMPC funktion und lass das script dann laufen. Dann poste alles was er ausgibt
-
Jetzt mitmachen!
Du hast noch kein Benutzerkonto auf unserer Seite? Registriere dich kostenlos und nimm an unserer Community teil!