mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-04-29 12:03:00 +00:00
Fix TypeError in calendar update by returning y_pos on draw_event error
This commit is contained in:
@@ -98,6 +98,7 @@ class CalendarManager:
|
|||||||
|
|
||||||
def draw_event(self, event, y_start=1):
|
def draw_event(self, event, y_start=1):
|
||||||
"""Draw a single calendar event on the canvas."""
|
"""Draw a single calendar event on the canvas."""
|
||||||
|
y_pos_at_start = y_start # Store the starting position
|
||||||
try:
|
try:
|
||||||
# Get event details
|
# Get event details
|
||||||
summary = event.get('summary', 'No Title')
|
summary = event.get('summary', 'No Title')
|
||||||
@@ -136,9 +137,11 @@ class CalendarManager:
|
|||||||
break
|
break
|
||||||
self.display_manager.draw_text(line, y=y_pos, color=self.text_color, small_font=True)
|
self.display_manager.draw_text(line, y=y_pos, color=self.text_color, small_font=True)
|
||||||
y_pos += 8 + 2 # Move down for the next line, add 2px spacing
|
y_pos += 8 + 2 # Move down for the next line, add 2px spacing
|
||||||
|
return y_pos # Return the final y position if successful
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(f"Error drawing calendar event: {str(e)}", exc_info=True)
|
logging.error(f"Error drawing calendar event: {str(e)}", exc_info=True)
|
||||||
|
return y_pos_at_start # Return the original starting position on error
|
||||||
|
|
||||||
def _wrap_text(self, text, max_width, font):
|
def _wrap_text(self, text, max_width, font):
|
||||||
"""Wrap text to fit within max_width using the provided font."""
|
"""Wrap text to fit within max_width using the provided font."""
|
||||||
|
|||||||
Reference in New Issue
Block a user