From b9641389d000ab91ef777f6fec3b6db1964e4442 Mon Sep 17 00:00:00 2001 From: Chuck <33324927+ChuckBuilds@users.noreply.github.com> Date: Mon, 7 Apr 2025 20:54:53 -0500 Subject: [PATCH] Flicker adjustments and text padding --- config/config.json | 10 +++++----- src/display_manager.py | 12 ++++++++---- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/config/config.json b/config/config.json index 3ffdea7c..9f73d095 100644 --- a/config/config.json +++ b/config/config.json @@ -11,19 +11,19 @@ "cols": 64, "chain_length": 2, "parallel": 1, - "brightness": 50, + "brightness": 60, "hardware_mapping": "adafruit-hat-pwm", "scan_mode": "progressive", - "pwm_bits": 11, - "pwm_dither_bits": 0, + "pwm_bits": 8, + "pwm_dither_bits": 1, "pwm_lsb_nanoseconds": 130, "disable_hardware_pulsing": true, "inverse_colors": false, "show_refresh_rate": false, - "limit_refresh_rate_hz": 0 + "limit_refresh_rate_hz": 100 }, "runtime": { - "gpio_slowdown": 4 + "gpio_slowdown": 2 }, "rotation_interval": 30 }, diff --git a/src/display_manager.py b/src/display_manager.py index 0a138adc..5e3bd38a 100644 --- a/src/display_manager.py +++ b/src/display_manager.py @@ -23,8 +23,8 @@ class DisplayManager: self.config = config logger.info("Initializing DisplayManager with config: %s", config) self._setup_matrix() # This now sets self.matrix - # Use a smaller font size for better fitting - self.font = ImageFont.truetype("DejaVuSans.ttf", 16) + # Use an even smaller font size for better fitting + self.font = ImageFont.truetype("DejaVuSans.ttf", 12) self.image = Image.new('RGB', (self.matrix.width, self.matrix.height)) self.draw = ImageDraw.Draw(self.image) DisplayManager._initialized = True @@ -89,6 +89,7 @@ class DisplayManager: line_widths = [] total_height = 0 max_width = 0 + padding = 2 # Add padding between lines for line in lines: bbox = self.draw.textbbox((0, 0), line, font=self.font) @@ -97,7 +98,10 @@ class DisplayManager: line_heights.append(line_height) line_widths.append(line_width) total_height += line_height - max_width = max(max_width, line_width) + + # Add padding between lines + if len(lines) > 1: + total_height += padding * (len(lines) - 1) # Calculate starting Y position to center all lines vertically if y is None: @@ -114,7 +118,7 @@ class DisplayManager: logger.info(f"Drawing line '{line}' at position ({line_x}, {current_y})") self.draw.text((line_x, current_y), line, font=self.font, fill=color) - current_y += line_heights[i] + current_y += line_heights[i] + padding self.matrix.SetImage(self.image)