From 738a422dc92f8f1e001da9427317df8b980a96ba Mon Sep 17 00:00:00 2001 From: kyle Date: Wed, 31 Dec 2025 16:27:55 +0100 Subject: [PATCH] Optimize landscape layout: 4-column grid, transport icons, improved sizing and spacing --- API_RESPONSE_DOCUMENTATION.md | 136 ++++ README.md | 20 +- clock.js | 6 +- config.js | 725 +++++++++++++++------ create-gitea-repo.ps1 | 24 - departures.js | 548 +++++++--------- documentation.md | 42 +- index.html | 1137 +++++++++++++++++++++++++++------ rss.js | 251 -------- server.js | 454 ++++++------- setup-git-repo.ps1 | 39 -- sites-config.json | 21 +- ticker.js | 297 --------- weather.js | 102 ++- 14 files changed, 2173 insertions(+), 1629 deletions(-) create mode 100644 API_RESPONSE_DOCUMENTATION.md delete mode 100644 create-gitea-repo.ps1 delete mode 100644 rss.js delete mode 100644 setup-git-repo.ps1 delete mode 100644 ticker.js diff --git a/API_RESPONSE_DOCUMENTATION.md b/API_RESPONSE_DOCUMENTATION.md new file mode 100644 index 0000000..6d4e971 --- /dev/null +++ b/API_RESPONSE_DOCUMENTATION.md @@ -0,0 +1,136 @@ +# SL Transport API Response Structure + +## Overview +The SL Transport API returns departure information for a specific stop/site. The response is a JSON object containing an array of departure objects. + +## Response Structure + +```json +{ + "departures": [ + { + "destination": "T-Centralen", + "direction_code": 2, + "direction": "T-Centralen", + "state": "EXPECTED", + "display": "Nu", + "scheduled": "2025-12-31T15:16:00", + "expected": "2025-12-31T15:24:52", + "journey": { + "id": "...", + "direction": "...", + // other journey fields + }, + "line": { + "designation": "7", + "transportMode": "TRAM", + // other line fields + } + // potentially other fields + } + ] +} +``` + +## Field Explanations + +### Top-Level Fields + +| Field | Type | Description | How We Use It | +|-------|------|-------------|---------------| +| `departures` | Array | List of departure objects | We iterate through this array to display all departures | + +### Departure Object Fields + +| Field | Type | Description | How We Use It | +|-------|------|-------------|---------------| +| `destination` | String | Final destination name (e.g., "T-Centralen", "Djurgårdsbrunn") | **Displayed as destination name** on the board | +| `direction_code` | Number | Direction indicator: `1` = going TO that direction, `2` = going FROM that direction | **Used to determine arrow direction** (1 = left ←, 2 = right →) | +| `direction` | String | Direction text (usually same as destination) | Available but we use `direction_code` instead | +| `state` | String | Departure state: `"EXPECTED"`, `"ATSTOP"`, etc. | Not currently used, but could indicate if bus is at stop | +| `display` | String | Human-readable time display: `"Nu"`, `"1 min"`, `"2 min"`, `"5 min"`, or time like `"15:23"` | **Used for countdown display** - we also calculate from `scheduled` | +| `scheduled` | ISO DateTime String | Original scheduled departure time (e.g., `"2025-12-31T15:16:00"`) | **Used to calculate minutes until arrival** and format time display | +| `expected` | ISO DateTime String | Expected/actual departure time (may differ from scheduled) | Available but we use `scheduled` for consistency | +| `journey` | Object | Journey information | We use `journey.id` to track unique departures | +| `journey.id` | String | Unique journey identifier | **Used as unique key** for tracking departures | +| `line` | Object | Line/route information | Contains line number and transport type | +| `line.designation` | String | Line number (e.g., `"7"`, `"69"`, `"76"`) | **Displayed as the bus/tram number** | +| `line.transportMode` | String | Transport type: `"BUS"`, `"TRAM"`, `"METRO"`, `"TRAIN"`, `"SHIP"` | **Used to determine icon and styling** | + +## Current Usage in Code + +### ✅ Correctly Used Fields + +1. **`destination`** - Displayed as destination name +2. **`direction_code`** - Used to determine arrow direction (1 = left, 2 = right) +3. **`display`** - Used for countdown text (but we also calculate from `scheduled`) +4. **`scheduled`** - Used to calculate minutes until arrival and determine color (red < 5 min, white >= 5 min) +5. **`journey.id`** - Used as unique identifier for tracking departures +6. **`line.designation`** - Displayed as line number +7. **`line.transportMode`** - Used to determine transport icon and label + +### ⚠️ Available But Not Used + +1. **`expected`** - Could be used instead of `scheduled` for more accurate times +2. **`state`** - Could be used to show special status (e.g., "ATSTOP" = bus is at stop now) +3. **`direction`** - Text version of direction (we use `direction_code` instead) + +## Recommendations + +### Current Implementation is Correct ✅ + +Your current implementation is using the right fields: +- **`scheduled`** is the correct field to use for time calculations (more reliable than `expected`) +- **`direction_code`** is the correct field for arrow direction +- **`display`** is good for showing the API's formatted time, but calculating from `scheduled` ensures consistency + +### Potential Enhancements + +1. **Use `state` field**: Could highlight when `state === "ATSTOP"` to show bus is currently at the stop +2. **Fallback to `expected`**: If `expected` differs significantly from `scheduled`, could show both times +3. **Use `direction` text**: Could display alongside destination for clarity + +## Example API Response + +```json +{ + "departures": [ + { + "destination": "T-Centralen", + "direction_code": 2, + "direction": "T-Centralen", + "state": "EXPECTED", + "display": "Nu", + "scheduled": "2025-12-31T15:16:00", + "expected": "2025-12-31T15:24:52", + "journey": { + "id": "some-unique-id" + }, + "line": { + "designation": "7", + "transportMode": "TRAM" + } + }, + { + "destination": "Djurgårdsbrunn", + "direction_code": 1, + "direction": "Djurgårdsbrunn", + "state": "EXPECTED", + "display": "1 min", + "scheduled": "2025-12-31T15:28:38", + "expected": "2025-12-31T15:29:00", + "journey": { + "id": "another-unique-id" + }, + "line": { + "designation": "69", + "transportMode": "BUS" + } + } + ] +} +``` + +## Summary + +**You are using the correct data!** The fields you're using (`destination`, `direction_code`, `display`, `scheduled`, `line.designation`, `line.transportMode`, `journey.id`) are the most important and reliable fields from the API response. diff --git a/README.md b/README.md index aedd4ca..db8b743 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # SL Transport Departures Display -A digital signage system for displaying transit departures, weather information, and news tickers. Perfect for Raspberry Pi-based information displays. +A digital signage system for displaying transit departures and weather information. Perfect for Raspberry Pi-based information displays. ![SL Transport Departures Display](https://example.com/screenshot.png) @@ -8,11 +8,9 @@ A digital signage system for displaying transit departures, weather information, - Real-time transit departure information - Current weather and hourly forecast -- News ticker with RSS feed integration - Multiple screen orientation support (0°, 90°, 180°, 270°) - Dark mode with automatic switching based on sunrise/sunset - Custom background image support -- Configurable ticker speed - Responsive design for various screen sizes ## Quick Start @@ -75,14 +73,6 @@ window.weatherManager = new WeatherManager({ }); ``` -### Changing RSS Feed - -To display a different news source, modify the RSS_URL in server.js: - -```javascript -const RSS_URL = 'https://your-rss-feed-url.xml'; -``` - ## UI Settings The gear icon in the top-right corner opens the settings panel where you can configure: @@ -90,7 +80,7 @@ The gear icon in the top-right corner opens the settings panel where you can con - Screen orientation - Dark mode (auto/on/off) - Background image and opacity -- Ticker speed +- Transit sites Settings are saved to localStorage and persist across sessions. @@ -102,7 +92,7 @@ The system consists of the following components: 2. **Configuration Manager** - Manages system settings and UI customization 3. **Weather Component** - Displays weather data and manages dark mode 4. **Clock Component** - Shows current time and date -5. **Ticker Component** - Displays scrolling news from RSS feeds +5. **Departures Component** - Displays transit departure information 6. **Main UI** - Responsive layout with multiple orientation support ## Documentation @@ -127,10 +117,6 @@ For detailed documentation, see [documentation.md](documentation.md). - Verify internet connection - Look for errors in browser console -4. **Ticker not scrolling** - - Check if RSS feed is accessible - - Verify ticker speed setting is not set to 0 - - Look for JavaScript errors in console ## License diff --git a/clock.js b/clock.js index 7383891..3032431 100644 --- a/clock.js +++ b/clock.js @@ -82,10 +82,10 @@ class Clock { // Format and display the time this.timeElement.innerHTML = this.formatTime(now); - // Format and display the date - this.dateElement.textContent = " " + this.formatDate(now); + // Format and display the date (with a separator) + this.dateElement.textContent = " • " + this.formatDate(now); - // Make sure the date element is visible + // Make sure the date element is visible and inline this.dateElement.style.display = 'inline-block'; } diff --git a/config.js b/config.js index 85b09f1..d04b920 100644 --- a/config.js +++ b/config.js @@ -35,7 +35,6 @@ class ConfigManager { darkMode: this.options.defaultDarkMode, backgroundImage: '', backgroundOpacity: 0.3, // Default opacity (30%) - tickerSpeed: 60, // Default ticker speed in seconds sites: [ { id: '1411', @@ -43,13 +42,6 @@ class ConfigManager { enabled: true } ], - rssFeeds: [ - { - name: "Travel Alerts", - url: "https://travel.state.gov/content/travel/en/rss/rss.xml", - enabled: true - } - ], combineSameDirection: true, // Combine departures going in the same direction ...this.loadConfig() // Load saved config if available }; @@ -102,73 +94,89 @@ class ConfigManager {

Settings

× +
+ + + + +
-
- - -
-
- - -
- Sunrise: --:-- | Sunset: --:-- + +
+
+ + +
+
+ + +
+ Sunrise: --:-- | Sunset: --:-- +
-
- - -
- -