diff --git a/config/config.json b/config/config.json index cdf38aa2..4caaf8bc 100644 --- a/config/config.json +++ b/config/config.json @@ -8,24 +8,24 @@ "display": { "hardware": { "rows": 32, - "cols": 32, + "cols": 64, "chain_length": 2, "parallel": 1, "brightness": 50, "hardware_mapping": "adafruit-hat-pwm", "scan_mode": "progressive", "pwm_bits": 11, - "pwm_dither_bits": 2, + "pwm_dither_bits": 0, "pwm_lsb_nanoseconds": 130, "led_rgb_sequence": "RGB", - "pixel_mapper_config": "U-mapper;Rotate:180", - "panel_type": "FM6126A", + "pixel_mapper_config": "Rotate:180", + "panel_type": "", "row_addr_type": 0, "multiplexing": 0, "disable_hardware_pulsing": true, "inverse_colors": false, "show_refresh_rate": false, - "limit_refresh_rate_hz": 120 + "limit_refresh_rate_hz": 0 }, "runtime": { "gpio_slowdown": 4 diff --git a/src/display_manager.py b/src/display_manager.py index 8b36421b..60c2d854 100644 --- a/src/display_manager.py +++ b/src/display_manager.py @@ -35,7 +35,7 @@ class DisplayManager: # Hardware configuration hardware_config = self.config.get('hardware', {}) options.rows = hardware_config.get('rows', 32) - options.cols = hardware_config.get('cols', 64) + options.cols = hardware_config.get('cols', 32) # Each panel is 32 columns options.chain_length = hardware_config.get('chain_length', 2) options.parallel = hardware_config.get('parallel', 1) options.hardware_mapping = hardware_config.get('hardware_mapping', 'adafruit-hat-pwm') @@ -49,21 +49,22 @@ class DisplayManager: options.multiplexing = hardware_config.get('multiplexing', 0) options.disable_hardware_pulsing = hardware_config.get('disable_hardware_pulsing', True) options.show_refresh_rate = hardware_config.get('show_refresh_rate', False) - options.limit_refresh_rate_hz = hardware_config.get('limit_refresh_rate_hz', 100) + options.limit_refresh_rate_hz = hardware_config.get('limit_refresh_rate_hz', 120) # Runtime configuration runtime_config = self.config.get('runtime', {}) - options.gpio_slowdown = runtime_config.get('gpio_slowdown', 3) + options.gpio_slowdown = runtime_config.get('gpio_slowdown', 4) logger.info("Setting GPIO slowdown to: %d", options.gpio_slowdown) # Initialize the matrix logger.info("Initializing RGB matrix with options...") self.matrix = RGBMatrix(options=options) logger.info("RGB matrix initialized successfully") + logger.info(f"Matrix dimensions: {self.matrix.width}x{self.matrix.height}") - # Apply rotation if specified - self.rotation = hardware_config.get('rotation', 0) - logger.info("Display rotation set to: %d degrees", self.rotation) + # Create image with full chain width + self.image = Image.new('RGB', (self.matrix.width, self.matrix.height)) + self.draw = ImageDraw.Draw(self.image) def _draw_text(self, text, x, y, font, color=(255, 255, 255)): """Draw text on the canvas.""" @@ -75,9 +76,22 @@ class DisplayManager: self.draw.rectangle((0, 0, self.matrix.width, self.matrix.height), fill=(0, 0, 0)) self.matrix.SetImage(self.image) - def draw_text(self, text: str, x: int, y: int, color: tuple = (255, 255, 255)): - """Draw text on the display.""" + def draw_text(self, text: str, x: int = None, y: int = None, color: tuple = (255, 255, 255)): + """Draw text on the display with automatic centering.""" self.clear() + + # Get text size + text_bbox = self.draw.textbbox((0, 0), text, font=self.font) + text_width = text_bbox[2] - text_bbox[0] + text_height = text_bbox[3] - text_bbox[1] + + # Calculate center position if not specified + if x is None: + x = (self.matrix.width - text_width) // 2 + if y is None: + y = (self.matrix.height - text_height) // 2 + + logger.info(f"Drawing text '{text}' at position ({x}, {y})") self.draw.text((x, y), text, font=self.font, fill=color) self.matrix.SetImage(self.image)