# π Berliner U-Bahn Anzeige fΓΌr Raspberry Pi Eine authentische Berliner U-Bahn Bahnsteiganzeige fΓΌr den **Raspberry Pi 3B** mit **joy-it RB-TFT3.2V2** Display (480x360). Zeigt Echtzeit-Abfahrten der **U9** an der Station **Amrumer StraΓe**.    --- ## πΈ Screenshot ``` βββββββββββββββββββββββββββββββββββββββββββββββββββββββ β π΅ U Amrumer StraΓe 14:23 β β Gelber Header βββββββββββββββββββββββββββββββββββββββββββββββββββββββ€ β β β β Osloer StraΓe β β π§ U9 5 min β β Orange U9-Badge β 8 min β β β β βββββββββββββββββββββββββββββββββββββββββββββββββββ β β β β β Rathaus Steglitz β β π§ U9 3 min β β 12 min β β β βββββββββββββββββββββββββββββββββββββββββββββββββββββββ ``` --- ## β¨ Features - β **Echtzeit-Daten** ΓΌber VBB REST API - β **U9-spezifisch** fΓΌr Amrumer StraΓe - β **Beide Richtungen**: Osloer StraΓe β Rathaus Steglitz - β **Authentisches BVG-Design** mit U-Bahn Symbol - β **Autostart** via systemd Service - β **Dynamische Display-Konfiguration** mit `display_config.json` - β **480x360 AuflΓΆsung** optimiert fΓΌr joy-it TFT Display - β **Node.js basiert** - schnell und ressourcenschonend --- ## π§ Hardware-Anforderungen | Komponente | Beschreibung | |------------|--------------| | **Raspberry Pi** | Raspberry Pi 3B (oder neuer) | | **Display** | joy-it RB-TFT3.2V2 (480x360, BGRA8888) | | **OS** | Raspberry Pi OS (Lite oder Desktop) | | **Internet** | WLAN/Ethernet fΓΌr API-Zugriff | --- ## π¦ Installation ### 1οΈβ£ System vorbereiten ```bash # System aktualisieren sudo apt update && sudo apt upgrade -y # Node.js und npm installieren curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - sudo apt install -y nodejs # Git installieren sudo apt install -y git # Projekt klonen git clone https://github.com/Serverlele30/rpi-ubahn.git cd rpi-ubahn ``` ### 2οΈβ£ Dependencies installieren ```bash npm install ``` **Wichtig:** Falls `canvas` Build-Fehler auftreten: ```bash sudo apt install -y build-essential libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev npm install canvas --build-from-source ``` ### 3οΈβ£ Display konfigurieren Das Projekt enthΓ€lt bereits eine `display_config.json`: ```json { "device": "/dev/fb0", "format": "BGRA8888", "width": 480, "height": 360 } ``` **Display-Berechtigungen setzen:** ```bash sudo chmod 666 /dev/fb0 ``` --- ## π Verwendung ### Manueller Start (Test) ```bash node ubahn_anzeige.js ``` **Erwartete Ausgabe:** ``` βββββββββββββββββββββββββββββββββββββββββββββ β U-BAHN ANZEIGE AMRUMER STR. β βββββββββββββββββββββββββββββββββββββββββββββ Device: /dev/fb0 Format: BGRA8888 AuflΓΆsung: 480x360 β Display-Konfiguration geladen 2024-11-10T... INFO: Display init gestartet 2024-11-10T... INFO: Font geladen 2024-11-10T... INFO: Framebuffer geΓΆffnet: /dev/fb0 2024-11-10T... INFO: Display bereit 2024-11-10T... INFO: API-Update: 12 U9-Bahnen ``` ### API testen (ohne Display) ```bash node test_api.js ``` Zeigt die nΓ€chsten U9-Abfahrten in der Konsole an. --- ## π Autostart einrichten ### systemd Service installieren ```bash # Service-Datei kopieren sudo cp ubahn-anzeige.service /etc/systemd/system/ # Service aktivieren sudo systemctl daemon-reload sudo systemctl enable ubahn-anzeige.service sudo systemctl start ubahn-anzeige.service ``` ### Service verwalten ```bash # Status prΓΌfen sudo systemctl status ubahn-anzeige # Logs anzeigen sudo journalctl -u ubahn-anzeige -f # Neustarten sudo systemctl restart ubahn-anzeige # Stoppen sudo systemctl stop ubahn-anzeige ``` --- ## π Projektstruktur ``` rpi-ubahn/ βββ ubahn_anzeige.js # Hauptprogramm βββ test_api.js # API-Test-Script βββ package.json # npm Dependencies βββ display_config.json # Display-Konfiguration βββ ubahn-anzeige.service # systemd Service-Datei βββ README.md # Diese Datei ``` ### Datei-Beschreibungen | Datei | Beschreibung | |-------|--------------| | `ubahn_anzeige.js` | Hauptprogramm - holt API-Daten und zeichnet Display | | `test_api.js` | Test-Tool fΓΌr VBB API ohne Display | | `display_config.json` | Display-Einstellungen (AuflΓΆsung, Format, Device) | | `ubahn-anzeige.service` | Systemd Service fΓΌr Autostart | | `package.json` | Node.js AbhΓ€ngigkeiten (axios, canvas) | --- ## βοΈ Konfiguration ### Station Γ€ndern Im Code `ubahn_anzeige.js` die `STATION_ID` Γ€ndern: ```javascript const STATION_ID = "900009101"; // Amrumer StraΓe ``` **Andere Stationen finden:** ```bash # Beispiel: Alexanderplatz suchen curl "https://v6.vbb.transport.rest/locations?query=Alexanderplatz&results=5" ``` ### Display-AuflΓΆsung anpassen In `display_config.json`: ```json { "device": "/dev/fb0", "format": "BGRA8888", "width": 320, β Anpassen "height": 240 β Anpassen } ``` ### Update-Intervall Γ€ndern In `ubahn_anzeige.js` Zeile ~107: ```javascript setInterval(fetchData, 20000); // 20 Sekunden (20000ms) ``` --- ## π¨ Design-Details ### Farben (BVG-konform) | Element | Farbe | RGB | |---------|-------|-----| | Hintergrund | Dunkelblau-Grau | `rgb(45, 55, 70)` | | Header | BVG Gelb | `rgb(255, 220, 0)` | | U9 Badge | Orange | `rgb(255, 110, 0)` | | U-Symbol | Blau | `rgb(0, 80, 160)` | | Text | WeiΓ | `rgb(255, 255, 255)` | ### Layout - **Header (70px)**: U-Bahn Symbol + Stationsname + Uhrzeit - **Richtung 1**: β Osloer StraΓe (2 Abfahrten) - **Trennlinie**: Gelbe Linie - **Richtung 2**: β Rathaus Steglitz (2 Abfahrten) --- ## π API-Details ### VBB REST API - **Base URL**: `https://v6.vbb.transport.rest/` - **Dokumentation**: [v6.vbb.transport.rest](https://v6.vbb.transport.rest/) - **Endpoint**: `/stops/{id}/departures` - **Parameter**: - `duration=60` - Abfahrten in nΓ€chsten 60 Minuten - `results=50` - Max. 50 Ergebnisse **Beispiel-Request:** ```bash curl "https://v6.vbb.transport.rest/stops/900009101/departures?duration=60" ``` --- ## π Troubleshooting ### Problem: Display bleibt schwarz **LΓΆsung:** ```bash # Framebuffer-Berechtigungen prΓΌfen ls -l /dev/fb0 # Berechtigungen setzen sudo chmod 666 /dev/fb0 # Oder dauerhaft mit udev-Regel: echo 'SUBSYSTEM=="graphics", KERNEL=="fb0", MODE="0666"' | sudo tee /etc/udev/rules.d/99-fbdev.rules sudo udevadm control --reload-rules ``` ### Problem: Canvas Build-Fehler **LΓΆsung:** ```bash # Build-Tools installieren sudo apt install -y build-essential libcairo2-dev libpango1.0-dev \ libjpeg-dev libgif-dev librsvg2-dev # Canvas neu kompilieren npm rebuild canvas --build-from-source ``` ### Problem: "Font nicht gefunden" **LΓΆsung:** ```bash # DejaVu Fonts installieren sudo apt install -y fonts-dejavu-core # Font-Cache aktualisieren fc-cache -fv ``` ### Problem: API liefert keine Daten **PrΓΌfen:** ```bash # Test-Script ausfΓΌhren node test_api.js # Netzwerk prΓΌfen ping -c 4 v6.vbb.transport.rest # API manuell testen curl "https://v6.vbb.transport.rest/stops/900009101/departures?duration=60" ``` --- ## π Logs analysieren ```bash # Service-Logs (Live) sudo journalctl -u ubahn-anzeige -f # Letzte 50 Zeilen sudo journalctl -u ubahn-anzeige -n 50 # Fehler filtern sudo journalctl -u ubahn-anzeige -p err ``` --- ## π Performance - **CPU-Nutzung**: ~5-10% (Raspberry Pi 3B) - **RAM**: ~50-80 MB - **API-Requests**: Alle 20 Sekunden - **Display-Refresh**: Jede Sekunde --- ## π€ Beitragen BeitrΓ€ge sind herzlich willkommen! π 1. **Fork** das Repository 2. **Clone** deinen Fork: `git clone https://github.com/DEIN-NAME/rpi-ubahn.git` 3. **Branch** erstellen: `git checkout -b feature/neue-funktion` 4. **Commit** Γnderungen: `git commit -m "Neue Funktion hinzugefΓΌgt"` 5. **Push**: `git push origin feature/neue-funktion` 6. **Pull Request** ΓΆffnen --- ## π TODO / Roadmap - [ ] **Mehrere Linien** unterstΓΌtzen (U1, U2, U3, etc.) - [ ] **Stationswechsel** per GPIO-Button - [ ] **Web-Interface** fΓΌr Konfiguration - [ ] **StΓΆrungsmeldungen** anzeigen - [ ] **Nacht-Modus** (Display aus 23:00-05:00) - [ ] **Warnung** bei VerspΓ€tungen - [ ] **Historische Daten** / Statistiken - [ ] **Docker-Support** --- ## π Features in Arbeit ### Geplante Updates - **Multi-Station Support**: Wechsel zwischen mehreren Stationen - **Touch-Support**: Touch-Bedienung auf dem Display - **API-Caching**: Offline-Fallback bei API-Ausfall - **Custom Themes**: Verschiedene Farbschemata --- ## π Lizenz **MIT License** ``` Copyright (c) 2024 Serverlele30 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ``` --- ## π Credits & Danksagungen - **VBB API**: [v6.vbb.transport.rest](https://v6.vbb.transport.rest/) - Γffentliche Verkehrsdaten Berlin - **Node Canvas**: [node-canvas](https://github.com/Automattic/node-canvas) - HTML5 Canvas fΓΌr Node.js - **joy-it**: [RB-TFT3.2V2](https://joy-it.net/en/products/RB-TFT3.2V2) - TFT Display Hardware - **BVG**: Design inspiriert von echten Berliner U-Bahn Anzeigen --- ## π Support & Kontakt - **GitHub Issues**: [github.com/Serverlele30/rpi-ubahn/issues](https://github.com/Serverlele30/rpi-ubahn/issues) - **Diskussionen**: [github.com/Serverlele30/rpi-ubahn/discussions](https://github.com/Serverlele30/rpi-ubahn/discussions) --- ## π NΓΌtzliche Links | Link | Beschreibung | |------|--------------| | [VBB API Docs](https://v6.vbb.transport.rest/) | API-Dokumentation | | [joy-it Display](https://joy-it.net/en/products/RB-TFT3.2V2) | Display-Dokumentation | | [Raspberry Pi](https://www.raspberrypi.com/) | Offizielle Raspberry Pi Seite | | [BVG](https://www.bvg.de/) | Berliner Verkehrsbetriebe | --- ## π Star History Wenn dir dieses Projekt gefΓ€llt, gib ihm einen β auf GitHub! --- ## πΈ Galerie ### Real-Life Setup *FΓΌge hier Fotos von deinem Setup hinzu!* ### Display-Ansicht ``` ββββββββββββββββββββββββββββββββββββββββββββββββββ β π΅ U Amrumer StraΓe 14:23 β β βββββββββββββββββββββββββββββββββββββββββββββββββ£ β β β β Osloer StraΓe β β π§ U9 5 min β β 8 min β β β β ββββββββββββββββββββββββββββββββββββββββββββ β β β β β Rathaus Steglitz β β π§ U9 3 min β β 12 min β β β ββββββββββββββββββββββββββββββββββββββββββββββββββ ``` ---