From ed392cf2938bd1f84973bd390c8a5b2452086b26 Mon Sep 17 00:00:00 2001 From: Chuck <33324927+ChuckBuilds@users.noreply.github.com> Date: Mon, 7 Apr 2025 19:05:50 -0500 Subject: [PATCH] First Working Display First working LED Display - Clock is functional. --- README.md | 48 +++++++++++++++++++++++++++++++++++++++++------- src/clock.py | 2 +- 2 files changed, 42 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index f910bb92..8eced835 100644 --- a/README.md +++ b/README.md @@ -15,19 +15,33 @@ A simple, modular clock application for Raspberry Pi using Adafruit LED Matrix d sudo apt-get update sudo apt-get install -y python3-pip python3-dev python3-setuptools sudo apt-get install -y build-essential git +sudo apt-get install -y python3-pil python3-pil.imagetk +sudo apt-get install -y cython3 ``` -2. Install the rpi-rgb-led-matrix library: +2. Install the rpi-rgb-led-matrix library and Python bindings: ```bash -cd rpi-rgb-led-matrix-master +# Make sure you're in the main project directory +cd ~/LEDSportsMatrix/rpi-rgb-led-matrix-master + +# Build the C++ library first make -sudo make install + +# Build and install Python bindings +cd bindings/python +sudo python3 setup.py install +cd ../.. + +# Install the library files +sudo cp -r lib/* /usr/local/lib/ +sudo cp -r include/* /usr/local/include/ +sudo ldconfig cd .. ``` -3. Install Python dependencies: +3. Install additional Python packages: ```bash -python3 -m pip install -r requirements.txt +sudo python3 -m pip install pytz ``` 4. Install the DejaVu Sans font: @@ -35,6 +49,26 @@ python3 -m pip install -r requirements.txt sudo apt-get install -y fonts-dejavu ``` +## Performance Optimization + +To reduce flickering and improve display quality, you have two options: + +1. Run the program with root privileges (quick solution): +```bash +sudo python3 clock.py +``` + +2. For better performance (recommended): + - Edit `/boot/firmware/cmdline.txt`: + ```bash + sudo nano /boot/firmware/cmdline.txt + ``` + - Add `isolcpus=3` at the end of the line + - Save and reboot: + ```bash + sudo reboot + ``` + ## Configuration Edit the `config/config.json` file to customize: @@ -44,10 +78,10 @@ Edit the `config/config.json` file to customize: ## Running the Clock -To start the clock: +To start the clock with optimal performance: ```bash cd src -python3 clock.py +sudo python3 clock.py ``` To stop the clock, press Ctrl+C. diff --git a/src/clock.py b/src/clock.py index 2d1ade2d..512e9ca3 100644 --- a/src/clock.py +++ b/src/clock.py @@ -22,7 +22,7 @@ class Clock: while True: current_time = self.get_current_time() # Center the text on the display - text_width = self.display_manager.font.getsize(current_time)[0] + text_width = self.display_manager.font.getlength(current_time) x = (self.display_manager.matrix.width - text_width) // 2 y = (self.display_manager.matrix.height - 24) // 2