error resolution

fixing luminance error
This commit is contained in:
Chuck
2025-04-08 18:32:54 -05:00
parent 902b53ec86
commit 96e81af0bf
2 changed files with 21 additions and 22 deletions

View File

@@ -23,11 +23,11 @@ class Clock:
self.timezone = self._get_timezone() self.timezone = self._get_timezone()
self.last_time = None self.last_time = None
self.last_date = None self.last_date = None
# Colors for different elements - using brighter colors # Colors for different elements - using maximum brightness colors
self.COLORS = { self.COLORS = {
'time': (255, 255, 255), # Bright white for time 'time': (255, 255, 255), # Pure white for time
'ampm': (200, 200, 255), # Light blue for AM/PM 'ampm': (255, 255, 0), # Bright yellow for AM/PM
'date': (255, 200, 200) # Light red for date 'date': (255, 160, 0) # Orange for date
} }
def _get_timezone(self) -> pytz.timezone: def _get_timezone(self) -> pytz.timezone:
@@ -111,18 +111,18 @@ class Clock:
# Draw time (large, centered, near top) # Draw time (large, centered, near top)
self.display_manager.draw_text( self.display_manager.draw_text(
time_str, time_str,
y=2, # Slightly higher y=1, # Move to top
color=self.COLORS['time'], color=self.COLORS['time'],
small_font=False small_font=False
) )
# Draw AM/PM (small, next to time) # Draw AM/PM (small, next to time)
time_width = self.display_manager.font.getlength(time_str) time_width = self.display_manager.font.getlength(time_str)
ampm_x = (display_width + time_width) // 2 + 1 # Closer to time ampm_x = (display_width + time_width) // 2 + 1
self.display_manager.draw_text( self.display_manager.draw_text(
ampm, ampm,
x=ampm_x, x=ampm_x,
y=4, # Align better with time y=3, # Align with time
color=self.COLORS['ampm'], color=self.COLORS['ampm'],
small_font=True small_font=True
) )
@@ -130,14 +130,11 @@ class Clock:
# Draw date (small, centered below time) # Draw date (small, centered below time)
self.display_manager.draw_text( self.display_manager.draw_text(
date_str, date_str,
y=display_height - 8, # Slightly higher from bottom y=display_height - 7, # Move up slightly
color=self.COLORS['date'], color=self.COLORS['date'],
small_font=True small_font=True
) )
# Update display
self.display_manager.update_display()
# Update cache # Update cache
self.last_time = time_str self.last_time = time_str
self.last_date = date_str self.last_date = date_str

View File

@@ -36,21 +36,20 @@ class DisplayManager:
options.parallel = hardware_config.get('parallel', 1) options.parallel = hardware_config.get('parallel', 1)
options.hardware_mapping = hardware_config.get('hardware_mapping', 'adafruit-hat-pwm') options.hardware_mapping = hardware_config.get('hardware_mapping', 'adafruit-hat-pwm')
# Increase brightness and optimize display quality # Optimize display settings for maximum visibility
options.brightness = hardware_config.get('brightness', 100) # Maximum brightness options.brightness = 100 # Maximum brightness
options.pwm_bits = hardware_config.get('pwm_bits', 11) # Maximum color depth options.pwm_bits = 11 # Maximum color depth
options.pwm_lsb_nanoseconds = hardware_config.get('pwm_lsb_nanoseconds', 130) options.pwm_lsb_nanoseconds = 130
options.led_rgb_sequence = hardware_config.get('led_rgb_sequence', 'RGB') options.led_rgb_sequence = 'RGB'
options.pixel_mapper_config = hardware_config.get('pixel_mapper_config', '') options.pixel_mapper_config = hardware_config.get('pixel_mapper_config', '')
options.row_address_type = hardware_config.get('row_addr_type', 0) options.row_address_type = 0
options.multiplexing = hardware_config.get('multiplexing', 0) options.multiplexing = 0
options.disable_hardware_pulsing = True # Reduce flickering options.disable_hardware_pulsing = True # Reduce flickering
options.show_refresh_rate = False options.show_refresh_rate = False
options.limit_refresh_rate_hz = hardware_config.get('limit_refresh_rate_hz', 120) # Higher refresh rate options.limit_refresh_rate_hz = 120 # Higher refresh rate
# Runtime configuration # Minimal GPIO slowdown for better performance
runtime_config = self.config.get('runtime', {}) options.gpio_slowdown = 1
options.gpio_slowdown = runtime_config.get('gpio_slowdown', 1) # Reduce slowdown
# Initialize the matrix # Initialize the matrix
self.matrix = RGBMatrix(options=options) self.matrix = RGBMatrix(options=options)
@@ -153,6 +152,9 @@ class DisplayManager:
# Draw main text # Draw main text
self.draw.text((x, y), text, font=font, fill=color) self.draw.text((x, y), text, font=font, fill=color)
# Update the display
self.update_display()
def draw_scrolling_text(self, text: str, scroll_position: int, force_clear: bool = False) -> None: def draw_scrolling_text(self, text: str, scroll_position: int, force_clear: bool = False) -> None:
"""Draw scrolling text on the display.""" """Draw scrolling text on the display."""