mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-04-10 13:02:59 +00:00
Luminance fix
luminance fix error
This commit is contained in:
16
src/clock.py
16
src/clock.py
@@ -23,11 +23,11 @@ class Clock:
|
||||
self.timezone = self._get_timezone()
|
||||
self.last_time = None
|
||||
self.last_date = None
|
||||
# Colors for different elements - using maximum brightness colors
|
||||
# Colors for different elements - using super bright colors
|
||||
self.COLORS = {
|
||||
'time': (255, 255, 255), # Pure white for time
|
||||
'ampm': (255, 255, 0), # Bright yellow for AM/PM
|
||||
'date': (255, 160, 0) # Orange for date
|
||||
'time': (255, 255, 255), # Pure white for time
|
||||
'ampm': (255, 255, 128), # Bright warm yellow for AM/PM
|
||||
'date': (255, 128, 64) # Bright orange for date
|
||||
}
|
||||
|
||||
def _get_timezone(self) -> pytz.timezone:
|
||||
@@ -111,18 +111,18 @@ class Clock:
|
||||
# Draw time (large, centered, near top)
|
||||
self.display_manager.draw_text(
|
||||
time_str,
|
||||
y=1, # Move to top
|
||||
y=3, # Move down slightly from top
|
||||
color=self.COLORS['time'],
|
||||
small_font=False
|
||||
)
|
||||
|
||||
# Draw AM/PM (small, next to time)
|
||||
time_width = self.display_manager.font.getlength(time_str)
|
||||
ampm_x = (display_width + time_width) // 2 + 1
|
||||
ampm_x = (display_width + time_width) // 2 + 2
|
||||
self.display_manager.draw_text(
|
||||
ampm,
|
||||
x=ampm_x,
|
||||
y=3, # Align with time
|
||||
y=5, # Align with time
|
||||
color=self.COLORS['ampm'],
|
||||
small_font=True
|
||||
)
|
||||
@@ -130,7 +130,7 @@ class Clock:
|
||||
# Draw date (small, centered below time)
|
||||
self.display_manager.draw_text(
|
||||
date_str,
|
||||
y=display_height - 7, # Move up slightly
|
||||
y=display_height - 9, # Move up more from bottom
|
||||
color=self.COLORS['date'],
|
||||
small_font=True
|
||||
)
|
||||
|
||||
@@ -47,9 +47,7 @@ class DisplayManager:
|
||||
options.disable_hardware_pulsing = True # Reduce flickering
|
||||
options.show_refresh_rate = False
|
||||
options.limit_refresh_rate_hz = 120 # Higher refresh rate
|
||||
|
||||
# Minimal GPIO slowdown for better performance
|
||||
options.gpio_slowdown = 1
|
||||
options.gpio_slowdown = 1 # Minimal GPIO slowdown
|
||||
|
||||
# Initialize the matrix
|
||||
self.matrix = RGBMatrix(options=options)
|
||||
@@ -61,9 +59,6 @@ class DisplayManager:
|
||||
self.image = Image.new('RGB', (self.matrix.width, self.matrix.height))
|
||||
self.draw = ImageDraw.Draw(self.image)
|
||||
|
||||
# Set matrix to use luminance correction for better color reproduction
|
||||
self.matrix.set_luminance_correct(True)
|
||||
|
||||
# Initialize font
|
||||
try:
|
||||
self.font = ImageFont.truetype("DejaVuSans.ttf", 14)
|
||||
@@ -124,6 +119,10 @@ class DisplayManager:
|
||||
|
||||
def draw_text(self, text: str, x: int = None, y: int = None, color: Tuple[int, int, int] = (255, 255, 255), small_font: bool = False) -> None:
|
||||
"""Draw text on the display with improved visibility."""
|
||||
# Create a new blank image for this text
|
||||
self.image = Image.new('RGB', (self.matrix.width, self.matrix.height))
|
||||
self.draw = ImageDraw.Draw(self.image)
|
||||
|
||||
# Ensure maximum brightness for text
|
||||
if isinstance(color, tuple) and len(color) == 3:
|
||||
# Increase brightness of colors while maintaining relative ratios
|
||||
|
||||
Reference in New Issue
Block a user