ChuckBuilds 48c1eed8a9 fix(stock_news): Refactor headline scrolling logic for proper spacing
Previously, the calculation for the wide scrolling image used fixed estimates, leading to insufficient gaps between headlines and causing text to appear cut off.

This change refactors the image generation:

- Calculates the position for each headline based on the actual width of the previous headline's rendered text.

- Adds a gap equal to the full screen width between each headline.

- Simplifies the overall width calculation and adds cropping for efficiency.

- Improves the scrolling logic to handle wrap-around pasting correctly.
2025-04-17 13:57:19 -05:00
2025-04-07 16:44:16 -05:00
2025-04-15 10:01:27 -05:00

LEDMatrix

A modular LED matrix display system for sports information using Raspberry Pi and RGB LED matrices.

Hardware Requirements

  • Raspberry Pi 3 or newer
  • Adafruit RGB Matrix Bonnet/HAT
  • LED Matrix panels (64x32)

Installation

  1. Clone this repository:
git clone https://github.com/ChuckBuilds/LEDMatrix.git
cd LEDMatrix
  1. Install dependencies:
pip3 install --break-system-packages -r requirements.txt

--break-system-packages allows us to install without a virtual environment

Configuration

  1. Copy the example configuration:
cp config/config.example.json config/config.json
  1. Edit config/config.json with your preferences

API Keys

For sensitive settings like API keys:

  1. Copy the template: cp config/config_secrets.template.json config/config_secrets.json

  2. Edit config/config_secrets.json with your API keys via sudo nano config/config_secrets.json

  3. Ctrl + X to exit, Y to overwrite, Enter to save

Important: Sound Module Configuration

  1. Remove unnecessary services that might interfere with the LED matrix:
sudo apt-get remove bluez bluez-firmware pi-bluetooth triggerhappy pigpio
  1. Blacklist the sound module:
cat <<EOF | sudo tee /etc/modprobe.d/blacklist-rgb-matrix.conf
blacklist snd_bcm2835
EOF

sudo update-initramfs -u
  1. Reboot:
sudo reboot

Performance Optimization

To reduce flickering and improve display quality:

  1. Edit /boot/firmware/cmdline.txt:
sudo nano /boot/firmware/cmdline.txt
  1. Add isolcpus=3 at the end of the line

  2. Add dtparam=audio=off at the end of the line

  3. Ctrl + X to exit, Y to save

  4. Save and reboot:

sudo reboot

Running without Sudo (Optional)

To run the display script without sudo, the user executing the script needs access to GPIO pins. Add the user to the gpio group:

This is required to download the Stock Symbol icons into assets/stocks.

sudo usermod -a -G gpio <your_username>
# Example for user 'ledpi':
# sudo usermod -a -G gpio ledpi

Important: You must reboot the Raspberry Pi after adding the user to the group for the change to take effect.

You also need to disable hardware pulsing in the code (see src/display_manager.py, set options.disable_hardware_pulsing = True). This has already been done in the repository if you are up-to-date.

If configured correctly, you can then run:

python3 display_controller.py

Running the Display

(This is how I used to run the command, I may remove this in the future)

From the project root directory:

sudo python3 display_controller.py

The display will alternate between showing:

  • Current time
  • Weather information (requires API key configuration)

Development

The project structure is organized as follows:

LEDMatrix/
├── config/                 # Configuration files
│   ├── config.json         # Main configuration
│   └── config_secrets.json # API keys and sensitive data
├── src/                    # Source code
│   ├── config_manager.py   # Configuration loading
│   ├── display_manager.py  # LED matrix display handling
│   ├── clock.py            # Clock display module
│   ├── weather_manager.py  # Weather display module
│   ├── stock_manager.py    # Stock ticker display module
│   └── stock_news_manager.py # Stock news display module
└── display_controller.py   # Main application controller

Project Structure

  • src/
    • display_controller.py - Main application controller
    • config_manager.py - Configuration management
    • display_manager.py - LED matrix display handling
    • clock.py - Clock display module
    • weather_manager.py - Weather display module
    • stock_manager.py - Stock ticker display module
    • stock_news_manager.py - Stock news display module
  • config/
    • config.json - Configuration settings
    • config_secrets.json - Private settings (not in git)

Fonts

You can add any font to the assets/fonts/ folder but they need to be .ttf and updated in display_manager.py

Description
Raspberry Pi LED Matrix Project
Readme GPL-3.0 205 MiB
Languages
Python 58.8%
JavaScript 18.6%
HTML 15.8%
Shell 6.1%
CSS 0.7%