### Install All Dependencies (Shell Script Example) Source: https://github.com/chuckbuilds/ledmatrix/wiki/INSTALLATION_GUIDE This is a consolidated example of how one might install all dependencies. It calls the Python script for apt/pip installation and potentially other steps. Run with sudo. ```shell #!/bin/bash echo "Starting comprehensive dependency installation..." # Execute the Python script for apt and pip installations echo "Running Python dependency installer..." if [ -f "scripts/install_dependencies_apt.py" ]; then sudo python3 scripts/install_dependencies_apt.py if [ $? -ne 0 ]; then echo "Python dependency installation failed. Please check the output above." exit 1 fi else echo "Error: scripts/install_dependencies_apt.py not found. Cannot install Python dependencies." exit 1 fi # Add any other system-level dependency installations here if not covered by the Python script # Example: # echo "Installing additional system packages..." # sudo apt update && sudo apt install -y git vim echo "All dependencies installed successfully." ``` -------------------------------- ### Run All-in-One Installer (Bash) Source: https://github.com/chuckbuilds/ledmatrix/wiki/WIKI_QUICK_START Execute the provided shell script for a streamlined, first-time installation of the LEDMatrix system. This script automates several setup steps. Ensure the script has execute permissions before running. ```bash chmod +x first_time_install.sh sudo ./first_time_install.sh ``` -------------------------------- ### Start Web V2 (Python Script) Source: https://github.com/chuckbuilds/ledmatrix/wiki/INSTALLATION_GUIDE This script manually starts the web interface after ensuring dependencies are installed. It includes comprehensive logging for debugging. Run with python3. ```python import subprocess import sys import logging logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') def install_dependencies(): logging.info("Ensuring dependencies are installed...") # Placeholder for dependency installation logic # In a real scenario, you might call install_dependencies_apt.py or similar try: subprocess.run(["python3", "scripts/install_dependencies_apt.py"], check=True) logging.info("Dependencies checked/installed.") except FileNotFoundError: logging.warning("scripts/install_dependencies_apt.py not found. Skipping dependency check.") except subprocess.CalledProcessError as e: logging.error(f"Error during dependency installation: {e}") sys.exit(1) def start_web_interface(): logging.info("Starting the web interface...") try: # Replace with the actual command to start your web interface # Example: using a Gunicorn command or a Flask development server # For demonstration, we'll simulate starting a web server process process = subprocess.Popen(["python3", "-m", "http.server", "5001"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) logging.info(f"Web interface started on port 5001. PID: {process.pid}") stdout, stderr = process.communicate() if process.returncode != 0: logging.error(f"Web interface failed to start. Error: {stderr.decode()}") sys.exit(1) except FileNotFoundError: logging.error("Could not find the command to start the web interface. Ensure it's in your PATH.") sys.exit(1) except Exception as e: logging.error(f"An unexpected error occurred: {e}") sys.exit(1) if __name__ == "__main__": install_dependencies() start_web_interface() logging.info("Web interface has finished execution (if it exited).") ``` -------------------------------- ### First Time Installation (Shell Script) Source: https://github.com/chuckbuilds/ledmatrix/wiki/INSTALLATION_GUIDE This script automates the entire installation process for a brand new setup. It's designed to be a single command that handles all necessary steps, including dependency installation, permission fixes, and configuration. Run with sudo. ```shell #!/bin/bash # This is a placeholder script. A real 'first_time_install.sh' would orchestrate # calls to other scripts and commands based on the project's needs. set -e # Exit immediately if a command exits with a non-zero status. echo "Starting the first-time installation process..." # 1. Install system and Python dependencies # Assumes scripts/install_dependencies_apt.py exists and handles both apt and pip echo "Installing dependencies..." if [ -f "scripts/install_dependencies_apt.py" ]; then sudo python3 scripts/install_dependencies_apt.py else echo "Warning: scripts/install_dependencies_apt.py not found. Manual dependency installation might be required." fi # 2. Fix web interface permissions echo "Fixing web interface permissions..." if [ -f "fix_web_permissions.sh" ]; then ./fix_web_permissions.sh else echo "Warning: fix_web_permissions.sh not found." fi # 3. Configure web interface sudo access echo "Configuring web interface sudo access..." if [ -f "configure_web_sudo.sh" ]; then ./configure_web_sudo.sh else echo "Warning: configure_web_sudo.sh not found." fi # 4. Install services (if applicable) echo "Installing system services..." if [ -f "install_service.sh" ]; then sudo ./install_service.sh else echo "Warning: install_service.sh not found. Manual service installation might be required." fi # 5. Apply group changes (optional immediate effect) # This is often done by logging out and back in, but newgrp can apply immediately echo "Applying group changes immediately (optional)..." if groups | grep -q 'systemd-journal' && groups | grep -q 'adm'; then echo "User is already in required groups or changes will take effect on next login." else # Attempt to add user to groups, might require user interaction or specific implementation echo "Attempting to add user to systemd-journal and adm groups..." # Example: sudo usermod -aG systemd-journal $USER && sudo usermod -aG adm $USER echo "Please log out and log back in for group changes to take effect." fi # 6. Set configuration for autostart (example) CONFIG_DIR="config" CONFIG_FILE="${CONFIG_DIR}/config.json" echo "Setting web_display_autostart to true in ${CONFIG_FILE}..." if [ ! -d "${CONFIG_DIR}" ]; then mkdir -p "${CONFIG_DIR}" fi if [ ! -f "${CONFIG_FILE}" ]; then echo "{}" > "${CONFIG_FILE}" # Create empty JSON if file doesn't exist fi # Use jq to update the JSON, or a simpler sed/awk if jq is not guaranteed # Assuming jq is installed for robust JSON manipulation if command -v jq &> /dev/null then jq '.web_display_autostart = true' "${CONFIG_FILE}" > "${CONFIG_FILE}.tmp" && mv "${CONFIG_FILE}.tmp" "${CONFIG_FILE}" else echo "jq not found. Manually editing config.json or using simpler tools might be needed." # Example using sed (less robust for complex JSON): # sed -i 's/"web_display_autostart": false/"web_display_autostart": true/' "${CONFIG_FILE}" # If 'web_display_autostart' doesn't exist, add it: # if ! grep -q '"web_display_autostart":' "${CONFIG_FILE}"; then # sed -i '$ i "web_display_autostart": true # fi' "${CONFIG_FILE}" fi echo "First-time installation process completed." echo "Please ensure you log out and log back in for all group changes to take effect." ``` -------------------------------- ### Install Python Bindings for LED Matrix Source: https://github.com/chuckbuilds/ledmatrix/wiki/WIKI_QUICK_START This bash command sequence navigates to the Python bindings directory of the rpi-rgb-led-matrix library and installs them using `setup.py`. This is necessary to fix import errors. ```bash cd rpi-rgb-led-matrix-master/bindings/python sudo python3 setup.py install ``` -------------------------------- ### Run First-Time Installation Script (Bash) Source: https://github.com/chuckbuilds/ledmatrix/blob/main/README.md Executes a script that automates the initial setup of the LEDMatrix project. This script installs services, dependencies, configures permissions, and validates the system setup. ```bash chmod +x first_time_install.sh sudo bash ./first_time_install.sh ``` -------------------------------- ### Installing LED Matrix System Services Source: https://github.com/chuckbuilds/ledmatrix/wiki/INSTALLATION_GUIDE Sets up systemd services for the main LED Matrix display and the web interface, ensuring they start automatically on boot. This script consolidates service installation. ```bash sudo ./install_service.sh ``` -------------------------------- ### Automated LED Matrix Installation Script Source: https://github.com/chuckbuilds/ledmatrix/wiki/INSTALLATION_GUIDE Executes all necessary steps for a fresh LEDMatrix installation, including system updates, dependency installation, repository cloning, and configuration. This script is recommended for new users for a streamlined setup. ```bash ssh ledpi@ledpi # (replace with your actual username@hostname) sudo apt update && sudo apt upgrade -y sudo apt install -y git python3-pip cython3 build-essential python3-dev python3-pillow scons git clone https://github.com/ChuckBuilds/LEDMatrix.git cd LEDMatrix chmod +x first_time_install.sh sudo ./first_time_install.sh ``` -------------------------------- ### Test RGB Matrix Library Installation (Python) Source: https://github.com/chuckbuilds/ledmatrix/wiki/WIKI_QUICK_START Verify the successful installation of the RGB Matrix library by running a simple Python command. This command attempts to import the necessary classes and prints 'Success!' if the import is successful. ```python python3 -c 'from rgbmatrix import RGBMatrix, RGBMatrixOptions; print("Success!")' ``` -------------------------------- ### Run Web V2 (Shell Script) Source: https://github.com/chuckbuilds/ledmatrix/wiki/INSTALLATION_GUIDE This shell script provides a manual way to start the web interface, mirroring the functionality of 'start_web_v2.py'. It ensures dependencies are handled and then launches the web application. Execute directly. ```shell #!/bin/bash echo "Starting web interface setup and run..." # Ensure Python 3 is available if ! command -v python3 &> /dev/null then echo "Python 3 could not be found. Please install it." exit 1 fi # Attempt to install dependencies using the Python script # This assumes install_dependencies_apt.py is in the same directory or accessible path if [ -f "scripts/install_dependencies_apt.py" ]; then echo "Running dependency installation script..." sudo python3 scripts/install_dependencies_apt.py if [ $? -ne 0 ]; then echo "Dependency installation failed. Please check the logs." exit 1 fi else echo "Dependency installation script not found. Proceeding without it." fi # Start the web interface using the Python script # This assumes start_web_v2.py is in the same directory or accessible path if [ -f "start_web_v2.py" ]; then echo "Starting the web interface using start_web_v2.py..." python3 start_web_v2.py if [ $? -ne 0 ]; then echo "Failed to start the web interface." exit 1 fi else echo "start_web_v2.py not found. Cannot start the web interface." exit 1 fi echo "Web interface script finished execution." ``` -------------------------------- ### View Web Interface Logs (Shell Command Example) Source: https://github.com/chuckbuilds/ledmatrix/wiki/INSTALLATION_GUIDE Provides real-time output from the web interface service, crucial for diagnosing errors related to web requests, rendering, or backend interactions. ```shell journalctl -u ledmatrix-web.service -f ``` -------------------------------- ### Manual Installation of Python Dependencies and rpi-rgb-led-matrix Source: https://github.com/chuckbuilds/ledmatrix/wiki/INSTALLATION_GUIDE Installs project dependencies from requirements.txt and compiles the rpi-rgb-led-matrix library with Python bindings. Includes a test command to verify successful installation. ```bash sudo pip3 install --break-system-packages -r requirements.txt cd rpi-rgb-led-matrix-master sudo make build-python PYTHON=$(which python3) cd bindings/python sudo python3 setup.py install python3 -c 'from rgbmatrix import RGBMatrix, RGBMatrixOptions; print("Success!")' ``` -------------------------------- ### Setup Cache Script (Bash) Source: https://github.com/chuckbuilds/ledmatrix/wiki/WIKI_QUICK_START Execute a shell script named 'setup_cache.sh' to prepare or update any necessary cache files for the LEDMatrix system. This script should have execute permissions before running. ```bash chmod +x setup_cache.sh ./setup_cache.sh ``` -------------------------------- ### Build and Install RGB Matrix Library (Bash) Source: https://github.com/chuckbuilds/ledmatrix/wiki/WIKI_QUICK_START Compile and install the 'rpi-rgb-led-matrix' library for Python. This involves navigating to the library's directory, building it with specific Python version support, and then installing the Python bindings. ```bash cd rpi-rgb-led-matrix-master sudo make build-python PYTHON=$(which python3) cd bindings/python sudo python3 setup.py install ``` -------------------------------- ### Start Web Conditionally (Python Script) Source: https://github.com/chuckbuilds/ledmatrix/wiki/INSTALLATION_GUIDE This script is designed to be called by a systemd service. It checks a configuration setting ('web_display_autostart') to determine whether to start the web interface. It should not be run manually. ```python import json import subprocess import sys import logging logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') CONFIG_FILE = "config/config.json" def load_config(): try: with open(CONFIG_FILE, 'r') as f: return json.load(f) except FileNotFoundError: logging.error(f"Configuration file not found at {CONFIG_FILE}") return None except json.JSONDecodeError: logging.error(f"Error decoding JSON from {CONFIG_FILE}") return None def start_web_interface(): logging.info("Attempting to start web interface...") try: # Placeholder for the actual command to start the web interface # This could be a call to another script or a direct execution command subprocess.run(["python3", "start_web_v2.py"], check=True) logging.info("Web interface started successfully.") except FileNotFoundError: logging.error("Could not find the script to start the web interface (e.g., start_web_v2.py).") sys.exit(1) except subprocess.CalledProcessError as e: logging.error(f"Failed to start web interface: {e}") sys.exit(1) except Exception as e: logging.error(f"An unexpected error occurred while starting the web interface: {e}") sys.exit(1) if __name__ == "__main__": config = load_config() if config is None: sys.exit(1) if config.get("web_display_autostart", False): logging.info("web_display_autostart is enabled. Starting web interface.") start_web_interface() else: logging.info("web_display_autostart is disabled. Web interface will not start automatically.") logging.info("Conditional web interface start check complete.") ``` -------------------------------- ### Install LEDMatrix System Service (Bash) Source: https://github.com/chuckbuilds/ledmatrix/wiki/WIKI_QUICK_START Execute a shell script to install the LEDMatrix application as a system service. This allows the display to run automatically on boot and be managed using systemd commands. Ensure the script has execute permissions. ```bash chmod +x install_service.sh sudo ./install_service.sh ``` -------------------------------- ### Run Display Controller (Python) Source: https://github.com/chuckbuilds/ledmatrix/wiki/WIKI_QUICK_START Start the main display controller script for the LEDMatrix system using Python 3. This script initializes the display and shows the clock and weather information if configured. Requires root privileges. ```python sudo python3 display_controller.py ``` -------------------------------- ### Install Python Dependencies (Bash) Source: https://github.com/chuckbuilds/ledmatrix/wiki/WIKI_QUICK_START Install the Python project dependencies listed in the 'requirements.txt' file using pip3. The '--break-system-packages' flag is used to allow installation of packages that might conflict with system-managed ones. ```bash sudo pip3 install --break-system-packages -r requirements.txt ``` -------------------------------- ### Install LEDMatrix Web Service Source: https://github.com/chuckbuilds/ledmatrix/wiki/WEB_INTERFACE_INSTALLATION Commands to install the web service for the LEDMatrix system. This involves navigating to the directory, making the script executable, and running the installation script with sudo. The script handles systemd service file creation, systemd reload, service enablement, immediate start, and dependency installation. ```bash cd /home/ledpi/LEDMatrix chmod +x install_web_service.sh sudo ./install_web_service.sh ``` -------------------------------- ### Update and Install System Packages (Bash) Source: https://github.com/chuckbuilds/ledmatrix/wiki/WIKI_QUICK_START Update the package list and upgrade existing packages on the Raspberry Pi. It then installs essential development tools, libraries, and Python packages required for the LEDMatrix project. The '-y' flag automatically confirms installations. ```bash sudo apt update && sudo apt upgrade -y sudo apt install -y git python3-pip cython3 build-essential python3-dev python3-pillow scons ``` -------------------------------- ### Perform Fresh Installation of LEDMatrix Source: https://github.com/chuckbuilds/ledmatrix/wiki/WIKI_TROUBLESHOOTING Removes the existing LEDMatrix directory, clones a fresh copy from the GitHub repository, and navigates into the new directory to follow the installation steps again. ```bash cd ~ rm -rf LEDMatrix git clone https://github.com/ChuckBuilds/LEDMatrix.git cd LEDMatrix # Follow installation steps again ``` -------------------------------- ### View Service Logs (Shell Command Example) Source: https://github.com/chuckbuilds/ledmatrix/wiki/INSTALLATION_GUIDE This command allows you to view the logs generated by the LedMatrix service in real-time. It's essential for diagnosing issues by observing the application's output and errors. Use -f to follow the logs. ```shell journalctl -u ledmatrix.service -f ``` -------------------------------- ### Enable Web UI Auto-Start Configuration Source: https://github.com/chuckbuilds/ledmatrix/wiki/WEB_UI_COMPLETE_GUIDE Configure the LEDMatrix system to automatically start the web interface on boot by setting 'web_display_autostart' to true in the configuration JSON. ```json { "web_display_autostart": true } ``` -------------------------------- ### C++ Minimal Example for LED Matrix API Source: https://github.com/chuckbuilds/ledmatrix/blob/main/rpi-rgb-led-matrix-master/examples-api-use/README.md A C++ code snippet representing a 'minimal-example.cc' file. This example is designed to be a starting point for developers to integrate with the LED matrix API. ```cpp // minimal-example.cc // Good to get started with the API // ... (actual code would be here) ``` -------------------------------- ### Manage LEDMatrix Web Service (systemctl) Source: https://github.com/chuckbuilds/ledmatrix/wiki/WEB_INTERFACE_INSTALLATION Commands to manage the 'ledmatrix-web.service' using systemctl. This includes checking status, viewing logs, starting, stopping, restarting, enabling, and disabling the service from starting on boot. ```bash sudo systemctl status ledmatrix-web.service journalctl -u ledmatrix-web.service -f sudo systemctl start ledmatrix-web.service sudo systemctl stop ledmatrix-web.service sudo systemctl restart ledmatrix-web.service sudo systemctl enable ledmatrix-web.service sudo systemctl disable ledmatrix-web.service ``` -------------------------------- ### Enable and Start Systemd Service Source: https://github.com/chuckbuilds/ledmatrix/wiki/WEB_INTERFACE_INSTALLATION Configures a systemd service to start automatically on boot and starts the service immediately. Essential for deploying services. ```bash sudo systemctl enable ledmatrix-web.service sudo systemctl start ledmatrix-web.service ``` -------------------------------- ### Clone LEDMatrix Repository (Bash) Source: https://github.com/chuckbuilds/ledmatrix/wiki/WIKI_QUICK_START Download the LEDMatrix project source code from GitHub to your Raspberry Pi. After cloning, navigate into the newly created project directory. ```bash git clone https://github.com/ChuckBuilds/LEDMatrix.git cd LEDMatrix ``` -------------------------------- ### Install Dependencies with Apt and Pip (Python Script) Source: https://github.com/chuckbuilds/ledmatrix/wiki/INSTALLATION_GUIDE Installs system packages using apt and then Python packages using pip, with a fallback to '--break-system-packages'. This script is useful for environments where system packages need to be installed first, handling externally managed Python environments. Run with sudo. ```python import subprocess import sys def install_packages(): # List of system packages to install via apt apt_packages = [ "build-essential", "python3-dev", "python3-pip", # Add other system dependencies here ] # List of Python packages to install via pip pip_packages = [ "numpy", "flask", "requests", # Add other Python dependencies here ] print("Attempting to install system packages via apt...") try: subprocess.run(["sudo", "apt", "update"], check=True) subprocess.run(["sudo", "apt", "install", "-y"] + apt_packages, check=True) print("System packages installed successfully.") except subprocess.CalledProcessError as e: print(f"Error installing system packages: {e}. Trying to continue...") print("Attempting to install Python packages via pip...") try: # Use --break-system-packages for environments where pip is managed externally subprocess.run([sys.executable, "-m", "pip", "install", "--upgrade", "pip"], check=True) subprocess.run([sys.executable, "-m", "pip", "install", "--break-system-packages"] + pip_packages, check=True) print("Python packages installed successfully.") except subprocess.CalledProcessError as e: print(f"Error installing Python packages: {e}") sys.exit(1) if __name__ == "__main__": if subprocess.run(["id", "-u"], capture_output=True).stdout.decode().strip() != "0": print("This script must be run as root (sudo).") sys.exit(1) install_packages() print("Dependency installation complete.") ``` -------------------------------- ### Use Convenience Scripts (Bash) Source: https://github.com/chuckbuilds/ledmatrix/wiki/WIKI_QUICK_START Execute custom shell scripts to easily start and stop the LEDMatrix display. These scripts likely wrap the systemctl commands or other necessary actions for convenient control. ```bash chmod +x start_display.sh stop_display.sh # Start display sudo ./start_display.sh # Stop display sudo ./stop_display.sh ``` -------------------------------- ### Install Service Script (Shell Script) Source: https://github.com/chuckbuilds/ledmatrix/wiki/INSTALLATION_GUIDE This script handles the installation of system services, likely by copying service unit files to the systemd directory and enabling them. It ensures the web interface or other components can be managed by systemd. Run with sudo. ```shell #!/bin/bash # This script installs systemd service files for the ledmatrix application. SERVICE_FILES=( "systemd/ledmatrix.service" "systemd/ledmatrix-web.service" # Add any other service files here ) SYSTEMD_DIR="/etc/systemd/system/" echo "Installing systemd service files..." for service_file in "${SERVICE_FILES[@]}"; do if [ -f "$service_file" ]; then echo "Copying $service_file to $SYSTEMD_DIR..." sudo cp "$service_file" "$SYSTEMD_DIR" # Reload systemd daemon after copying new files sudo systemctl daemon-reload # Try to enable the service (optional, might be done manually later) SERVICE_NAME=$(basename "$service_file") echo "Enabling service: $SERVICE_NAME" sudo systemctl enable "$SERVICE_NAME" else echo "Warning: Service file $service_file not found. Skipping." fi done echo "System service installation complete. Use 'sudo systemctl start ' and 'sudo systemctl status ' to manage services." ``` -------------------------------- ### Control LEDMatrix System Service (Bash) Source: https://github.com/chuckbuilds/ledmatrix/wiki/WIKI_QUICK_START Manage the LEDMatrix system service using systemctl commands. This includes starting, stopping, checking the status, and enabling the service to automatically start on system boot. ```bash # Start display sudo systemctl start ledmatrix.service # Stop display sudo systemctl stop ledmatrix.service # Check status sudo systemctl status ledmatrix.service # Enable autostart sudo systemctl enable ledmatrix.service ``` -------------------------------- ### Configure Web Interface Autostart (JSON) Source: https://github.com/chuckbuilds/ledmatrix/wiki/WEB_INTERFACE_INSTALLATION Configuration snippet for enabling the web interface to automatically start on boot. This involves editing the 'config.json' file and setting the 'web_display_autostart' parameter to 'true'. ```json { "web_display_autostart": true } ``` -------------------------------- ### C++ Image Display Example for LED Matrix Source: https://github.com/chuckbuilds/ledmatrix/blob/main/rpi-rgb-led-matrix-master/examples-api-use/README.md A C++ code snippet for 'image-example.cc'. This example illustrates how to display an image on the LED matrix, noting that it requires the 'graphics magic' library to be installed. ```cpp // image-example.cc // How to show an image (requires to install the graphics magic library, see in the header of that demo) // ... (actual code would be here) ``` -------------------------------- ### Manage LEDMatrix Systemd Service Source: https://github.com/chuckbuilds/ledmatrix/wiki/WIKI_QUICK_START A collection of bash commands to manage the `ledmatrix.service` systemd service, including starting, stopping, and checking its status. These commands are essential for controlling the background operation of the LED matrix. ```bash sudo systemctl start ledmatrix.service sudo systemctl stop ledmatrix.service sudo systemctl status ledmatrix.service ``` -------------------------------- ### Install and Manage LED Matrix as Systemd Service Source: https://context7.com/chuckbuilds/ledmatrix/llms.txt Facilitates running the LED matrix display as a system service for automatic startup, management, and logging via systemd. Includes scripts for initial setup, manual service installation, and service control commands. ```bash # First-time installation (recommended) chmod +x first_time_install.sh sudo bash ./first_time_install.sh # This script: # - Installs all dependencies # - Builds rpi-rgb-led-matrix library # - Creates config from template # - Installs systemd services # - Configures permissions # - Validates setup # Manual service installation chmod +x install_service.sh sudo ./install_service.sh # Service management commands sudo systemctl start ledmatrix.service # Start display sudo systemctl stop ledmatrix.service # Stop display sudo systemctl restart ledmatrix.service # Restart display sudo systemctl status ledmatrix.service # Check status sudo systemctl enable ledmatrix.service # Enable autostart sudo systemctl disable ledmatrix.service # Disable autostart # View logs journalctl -u ledmatrix.service -f # Follow logs in real-time journalctl -u ledmatrix.service -n 100 # Last 100 lines # Convenience scripts chmod +x start_display.sh stop_display.sh sudo ./start_display.sh # Quick start sudo ./stop_display.sh # Quick stop # Web interface service sudo systemctl start ledmatrix-web.service sudo systemctl status ledmatrix-web.service journalctl -u ledmatrix-web.service -f # The service file specifies: # - User: root (required for hardware access) # - Working directory: /home/ledpi/LEDMatrix # - Environment: PYTHONUNBUFFERED=1 # - Restart: always (automatic recovery) ``` -------------------------------- ### Enable Music Feature in Configuration Source: https://github.com/chuckbuilds/ledmatrix/wiki/WIKI_QUICK_START This JSON configuration enables the music feature and specifies the preferred music source, such as YouTube Music. Update `config/config.json` to use this setting. ```json { "music": { "enabled": true, "preferred_source": "ytm" } } ``` -------------------------------- ### Prepare for System Reinstallation Source: https://github.com/chuckbuilds/ledmatrix/wiki/WIKI_TROUBLESHOOTING Stops the LEDMatrix service, disables it from starting automatically, and removes its cache directories to prepare for a clean reinstallation. Requires 'sudo' privileges. ```bash sudo systemctl stop ledmatrix.service sudo systemctl disable ledmatrix.service sudo rm -rf /var/cache/ledmatrix sudo rm -rf /tmp/ledmatrix_cache ``` -------------------------------- ### Configuration File Management Source: https://github.com/chuckbuilds/ledmatrix/wiki/INSTALLATION_GUIDE Demonstrates how to edit the main configuration file (`config/config.json`) and how to set up and edit the secrets file (`config/config_secrets.json`) for sensitive information like API keys. ```bash # Edit main configuration sudo nano config/config.json # Copy secrets template cp config/config_secrets.template.json config/config_secrets.json # Edit secrets file sudo nano config/config_secrets.json ``` -------------------------------- ### Configure Music Source and API URL Source: https://github.com/chuckbuilds/ledmatrix/wiki/WIKI_TROUBLESHOOTING An example JSON configuration object for music integration, specifying whether music is enabled, the preferred source ('ytm'), and the URL for the YouTube Music companion server. ```json { "music": { "enabled": true, "preferred_source": "ytm", "YTM_COMPANION_URL": "http://192.168.1.100:9863" } } ``` -------------------------------- ### Compile and Run Demo Utility Source: https://github.com/chuckbuilds/ledmatrix/blob/main/rpi-rgb-led-matrix-master/README.md Compiles and runs a demo program from the examples-api-use directory. This is a common first step to test the LED matrix setup. ```bash make -C examples-api-use sudo examples-api-use/demo -D0 ``` -------------------------------- ### Example Programs Source: https://github.com/chuckbuilds/ledmatrix/blob/main/rpi-rgb-led-matrix-master/examples-api-use/README.md Additional example programs are provided for users to explore the API and build their own applications. These examples cover basic usage, image display, and text rendering. ```APIDOC ## Example Programs ### Description Beyond the main demos, several example programs are included to serve as starting points for custom LED matrix applications. These examples demonstrate different functionalities and may have specific dependencies. ### Method Compile and Run (using `make` in the project directory) ### Endpoint Various executable files generated by `make` in the project directory. ### Examples - **minimal-example**: A basic starting point for API interaction. - **image-example**: Demonstrates how to display images. Requires the 'graphics magic' library. - **text-example**: Reads text from standard input and displays it on the matrix. - **scrolling-text-example**: Implements scrolling text display. ### Request Example ```bash make ./minimal-example ``` ### Response These programs interact with the LED matrix to produce visual output. Success is indicated by the expected visual results on the matrix. #### Success Response Visual output on the LED matrix corresponding to the example program's function. #### Response Example (Visual output on LED matrix, no text-based response) ``` -------------------------------- ### Install LEDMatrix Web Interface Service Source: https://github.com/chuckbuilds/ledmatrix/blob/main/README.md Installs the LEDMatrix web interface service. This involves making the installation script executable and then running it with sudo. The script handles copying service files, enabling auto-start on boot, and initiating the service. ```bash chmod +x install_web_service.sh sudo ./install_web_service.sh ``` -------------------------------- ### YouTube Music Companion Server Setup (Instructions) Source: https://github.com/chuckbuilds/ledmatrix/blob/main/README.md Steps to configure the YouTube Music Desktop App's companion server. This requires installing and running the app on a computer on the same network as the Raspberry Pi. The companion server must be enabled in the app's settings, and its URL noted. ```text 1. Install and run the [YouTube Music Desktop App](https://ytmdesktop.app/) on a computer on the *same network* as the Raspberry Pi. 2. In YTMD settings, enable the "Companion Server" under Integration options. 3. Note the URL it provides (usually `http://localhost:9863` if running on the same machine, or `http://:9863` if running on a different computer). ``` -------------------------------- ### Complete F1 and MotoGP Feed Setup Example Source: https://github.com/chuckbuilds/ledmatrix/wiki/CUSTOM_FEEDS_GUIDE A comprehensive example demonstrating the setup of multiple RSS feeds for Formula 1 and MotoGP. It includes listing current feeds, adding new ones, testing the feeds, and verifying the final configuration. Recommended for ensuring good sport coverage. ```bash # 1. List current setup python3 add_custom_feed_example.py list # 2. Add multiple F1 sources for better coverage python3 add_custom_feed_example.py add "BBC F1" "http://feeds.bbci.co.uk/sport/formula1/rss.xml" python3 add_custom_feed_example.py add "Motorsport F1" "https://www.motorsport.com/rss/f1/news/" # 3. Add other racing series python3 add_custom_feed_example.py add "MotoGP" "https://www.motogp.com/en/rss/news" # 4. Verify all feeds work simple_news_test.py # 5. Check final configuration python3 add_custom_feed_example.py list ``` -------------------------------- ### Check Web Interface Service Status (Shell Command Example) Source: https://github.com/chuckbuilds/ledmatrix/wiki/INSTALLATION_GUIDE Used to verify if the web interface's systemd service is active and running. Essential for troubleshooting accessibility issues. ```shell sudo systemctl status ledmatrix-web.service ``` -------------------------------- ### Spotify API Credential Setup (Instructions) Source: https://github.com/chuckbuilds/ledmatrix/blob/main/README.md Instructions for setting up Spotify API credentials. This involves registering an application on the Spotify Developer Dashboard to obtain a Client ID and Client Secret. A specific Redirect URI is required and must be added to the application settings. ```text 1. Register an application on the [Spotify Developer Dashboard](https://developer.spotify.com/dashboard/). 2. Give it a name (e.g., "LEDMatrix Display") and description. 3. For the "Redirect URI", enter `http://127.0.0.1:8888/callback` (or another unused port if 8888 is taken). You **must** add this exact URI in your app settings on the Spotify dashboard. 4. Note down the `Client ID` and `Client Secret`. ``` -------------------------------- ### Start Enhanced Web Interface (Bash) Source: https://github.com/chuckbuilds/ledmatrix/wiki/WEB_INTERFACE_V2_ENHANCED_SUMMARY This command initiates the enhanced web interface for the LED Matrix. It requires Python 3 to be installed. Ensure the script 'start_web_v2.py' is in the current directory. Access the interface via a web browser at the specified IP address and port. ```bash python3 start_web_v2.py ``` -------------------------------- ### Check Service Status (Shell Command Example) Source: https://github.com/chuckbuilds/ledmatrix/wiki/INSTALLATION_GUIDE These commands are used to check the status of systemd services related to the LedMatrix project. They are crucial for troubleshooting whether the main application and the web interface are running correctly. ```shell sudo systemctl status ledmatrix.service sudo systemctl status ledmatrix-web.service ``` -------------------------------- ### Build and Run LED Matrix Demo Source: https://github.com/chuckbuilds/ledmatrix/blob/main/rpi-rgb-led-matrix-master/examples-api-use/README.md This snippet shows the basic commands to build the demo application using 'make' and then run it with root privileges. The execution requires root to access GPIO pins, but the program drops privileges after initialization. ```bash $ make $ sudo ./demo ``` -------------------------------- ### Running Demos Source: https://github.com/chuckbuilds/ledmatrix/blob/main/rpi-rgb-led-matrix-master/examples-api-use/README.md The primary way to run demos is via the `./demo` executable. This requires root privileges to access GPIO pins, but the program will drop privileges after initialization. Demos are selected using the `-D` flag, and various other options can configure the LED matrix and display. ```APIDOC ## Running Demos ### Description To run demos, execute the `./demo` command. It requires root privileges initially for GPIO access. You must specify a demo number using the `-D` flag. Numerous optional flags allow customization of the LED matrix setup and demo behavior. ### Method Command Line Execution ### Endpoint `./demo` ### Parameters #### Command Line Flags - **-D <demo-nr>** (integer) - Required - The number of the demo to run. - **--led-gpio-mapping=<name>** (string) - Optional - Name of the GPIO mapping. Default: "regular". - **--led-rows=<rows>** (integer) - Optional - Number of rows per panel. Default: 32. - **--led-cols=<cols>** (integer) - Optional - Number of columns per panel. Default: 32. - **--led-chain=<chained>** (integer) - Optional - Number of daisy-chained panels. Default: 1. - **--led-parallel=<parallel>** (integer) - Optional - Number of parallel chains. Range: 1-3. Default: 1. - **--led-multiplexing=<0..17>** (integer) - Optional - Mux type for the panels. Default: 0. - **--led-pixel-mapper=<mappers>** (string) - Optional - Semicolon-separated list of pixel-mappers. Default: "". - **--led-pwm-bits=<1..11>** (integer) - Optional - PWM bits. Default: 11. - **--led-brightness=<percent>** (integer) - Optional - Brightness percentage. Default: 100. - **--led-scan-mode=<0..1>** (integer) - Optional - Scan mode: 0 = progressive, 1 = interlaced. Default: 0. - **--led-row-addr-type=<0..4>** (integer) - Optional - Row address type. Default: 0. - **--led-show-refresh** - Optional - Show refresh rate. - **--led-limit-refresh=<Hz>** (integer) - Optional - Limit refresh rate to a specific frequency in Hz. 0 means no limit. Default: 0. - **--led-inverse** - Optional - Enable if matrix has inverse colors. - **--led-rgb-sequence=<sequence>** (string) - Optional - Color sequence if LEDs are swapped. Default: "RGB". - **--led-pwm-lsb-nanoseconds=<ns>** (integer) - Optional - PWM Nanoseconds for LSB. Default: 130. - **--led-pwm-dither-bits=<0..2>** (integer) - Optional - Time dithering of lower bits. Default: 0. - **--led-no-hardware-pulse** - Optional - Do not use hardware pin-pulse generation. - **--led-panel-type=<name>** (string) - Optional - Panel type identifier (e.g., 'FM6126A'). - **--led-slowdown-gpio=<0..4>** (integer) - Optional - Slowdown GPIO. Default: 1. - **--led-daemon** - Optional - Run the process in the background as a daemon. - **--led-no-drop-privs** - Optional - Do not drop privileges from 'root' after initialization. ### Request Example ```bash sudo ./demo -D 1 runtext.ppm ``` ### Response This command executes a demo and displays output on the LED matrix. There is no direct JSON response. Success is indicated by the demo running as expected on the matrix. #### Success Response Output is displayed on the LED matrix. #### Response Example (Visual output on LED matrix, no text-based response) ``` -------------------------------- ### Run LEDMatrix in Emergency Mode Source: https://github.com/chuckbuilds/ledmatrix/wiki/WIKI_TROUBLESHOOTING Starts the LEDMatrix display controller with minimal configuration using an emergency flag, useful when the system fails to start normally. Requires 'sudo' privileges. ```bash sudo python3 display_controller.py --emergency ``` -------------------------------- ### Spotify Authentication Setup (Python) Source: https://context7.com/chuckbuilds/ledmatrix/llms.txt Provides instructions and code snippets for setting up Spotify authentication. This involves creating an app on the Spotify Developer Dashboard to obtain Client ID and Client Secret, adding these to a secrets configuration file, and running a provided authentication script. ```python # For Spotify, first authenticate: # 1. Create app at https://developer.spotify.com/dashboard/ # 2. Get Client ID and Client Secret # 3. Add to config/config_secrets.json: secrets = { "music": { "SPOTIFY_CLIENT_ID": "your_client_id", "SPOTIFY_CLIENT_SECRET": "your_client_secret", "SPOTIFY_REDIRECT_URI": "http://127.0.0.1:8888/callback" } } # Run authentication script: # sudo python3 src/authenticate_spotify.py # sudo chmod 644 config/spotify_auth.json ``` -------------------------------- ### LED Matrix Demo Command Line Options Source: https://github.com/chuckbuilds/ledmatrix/blob/main/rpi-rgb-led-matrix-master/examples-api-use/README.md Provides a comprehensive list of command-line flags for configuring the LED matrix demo. Options control display dimensions, chaining, parallelization, multiplexing, pixel mapping, brightness, refresh rate, and color sequencing. ```bash ./demo -D [optional parameter] Options: -D : Always needs to be set --led-gpio-mapping= : Name of GPIO mapping used. Default "regular" --led-rows= : Panel rows. Typically 8, 16, 32 or 64. (Default: 32). --led-cols= : Panel columns. Typically 32 or 64. (Default: 32). --led-chain= : Number of daisy-chained panels. (Default: 1). --led-parallel= : Parallel chains. range=1..3 (Default: 1). --led-multiplexing=<0..17> : Mux type: 0=direct; 1=Stripe; 2=Checkered; 3=Spiral; 4=ZStripe; 5=ZnMirrorZStripe; 6=coreman; 7=Kaler2Scan; 8=ZStripeUneven; 9=P10-128x4-Z; 10=QiangLiQ8; 11=InversedZStripe; 12=P10Outdoor1R1G1-1; 13=P10Outdoor1R1G1-2; 14=P10Outdoor1R1G1-3; 15=P10CoremanMapper; 16=P8Outdoor1R1G1; 17=FlippedStripe (Default: 0) --led-pixel-mapper : Semicolon-separated list of pixel-mappers to arrange pixels. Optional params after a colon e.g. "U-mapper;Rotate:90" Available: "Mirror", "Rotate", "U-mapper", "V-mapper". Default: "" --led-pwm-bits=<1..11> : PWM bits (Default: 11). --led-brightness=: Brightness in percent (Default: 100). --led-scan-mode=<0..1> : 0 = progressive; 1 = interlaced (Default: 0). --led-row-addr-type=<0..4>: 0 = default; 1 = AB-addressed panels; 2 = direct row select; 3 = ABC-addressed panels; 4 = ABC Shift + DE direct (Default: 0). --led-show-refresh : Show refresh rate. --led-limit-refresh= : Limit refresh rate to this frequency in Hz. Useful to keep a constant refresh rate on loaded system. 0=no limit. Default: 0 --led-inverse : Switch if your matrix has inverse colors on. --led-rgb-sequence : Switch if your matrix has led colors swapped (Default: "RGB") --led-pwm-lsb-nanoseconds : PWM Nanoseconds for LSB (Default: 130) --led-pwm-dither-bits=<0..2> : Time dithering of lower bits (Default: 0) --led-no-hardware-pulse : Don't use hardware pin-pulse generation. --led-panel-type= : Needed to initialize special panels. Supported: 'FM6126A', 'FM6127' --led-slowdown-gpio=<0..4>: Slowdown GPIO. Needed for faster Pis/slower panels (Default: 1). --led-daemon : Make the process run in the background as daemon. --led-no-drop-privs : Don't drop privileges from 'root' after initializing the hardware. ``` -------------------------------- ### Run RGB Matrix Example Script Source: https://github.com/chuckbuilds/ledmatrix/blob/main/rpi-rgb-led-matrix-master/bindings/python/README.md Executes an example script for the RGB Matrix library, allowing configuration via command-line arguments such as `--led-chain` and `--led-gpio-mapping`. Requires root privileges. ```bash cd samples sudo ./runtext.py --led-chain=4 ``` ```bash sudo ./runtext.py --led-gpio-mapping=adafruit-hat ``` -------------------------------- ### Run Text Scrolling Demo Example Source: https://github.com/chuckbuilds/ledmatrix/blob/main/rpi-rgb-led-matrix-master/examples-api-use/README.md Example demonstrating how to run demo number 1, which scrolls an image. It requires a 'runtext.ppm' file as input and can be configured with scroll timing via '-m'. The demo needs to be run with 'sudo'. ```bash $ sudo ./demo -D 1 runtext.ppm ``` -------------------------------- ### Reinstall LEDMatrix Service Source: https://github.com/chuckbuilds/ledmatrix/wiki/WIKI_TROUBLESHOOTING Stops, disables, and then reinstalls the 'ledmatrix.service'. It makes the installation script executable and then runs it. Requires 'sudo' privileges. ```bash sudo systemctl stop ledmatrix.service sudo systemctl disable ledmatrix.service chmod +x install_service.sh sudo ./install_service.sh ``` -------------------------------- ### Command-Line for U-mapper with Parallel Chains Source: https://github.com/chuckbuilds/ledmatrix/blob/main/rpi-rgb-led-matrix-master/examples-api-use/README.md This command-line example demonstrates using the 'U-mapper' with multiple parallel chains of LED panels. It configures the number of panels per chain and the number of parallel chains. This setup allows for larger, more complex logical display configurations by combining multiple physical arrangements. ```bash ./demo --led-chain=8 --led-parallel=2 --led-pixel-mapper="U-mapper" ``` -------------------------------- ### Test Internet Connection and API Accessibility Source: https://github.com/chuckbuilds/ledmatrix/wiki/WIKI_TROUBLESHOOTING Verifies internet connectivity by pinging Google and checks if the OpenWeatherMap API endpoint is accessible. Requires 'curl' to be installed. ```bash ping -c 3 google.com curl -I https://api.openweathermap.org ``` -------------------------------- ### View LEDMatrix Service Logs Source: https://github.com/chuckbuilds/ledmatrix/wiki/WIKI_QUICK_START This bash command retrieves and displays the logs for the `ledmatrix.service` using `journalctl`. It is crucial for troubleshooting issues with the background service. ```bash journalctl -u ledmatrix.service ``` -------------------------------- ### Add Custom Feed Example (Bash) Source: https://github.com/chuckbuilds/ledmatrix/wiki/DYNAMIC_DURATION_GUIDE This bash command shows how to add a new custom news feed using a Python script. It is an example of how configuration changes, like adding more feeds, can impact the dynamic duration calculation by increasing the total content to be displayed. ```bash # Add more feeds (increases duration) python3 add_custom_feed_example.py add "Tennis" "https://www.atptour.com/en/rss/news" ```