mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-04-10 21:03:01 +00:00
adjusting news manager scroll speed
This commit is contained in:
@@ -336,6 +336,9 @@ class NewsManager:
|
|||||||
|
|
||||||
# Calculate scroll position for smooth animation
|
# Calculate scroll position for smooth animation
|
||||||
if self.total_scroll_width > 0:
|
if self.total_scroll_width > 0:
|
||||||
|
# Use modulo for continuous scrolling like stock ticker
|
||||||
|
self.scroll_position = (self.scroll_position + self.scroll_speed) % self.total_scroll_width
|
||||||
|
|
||||||
# Scroll from right to left
|
# Scroll from right to left
|
||||||
x_pos = width - self.scroll_position
|
x_pos = width - self.scroll_position
|
||||||
|
|
||||||
@@ -346,12 +349,8 @@ class NewsManager:
|
|||||||
if x_pos + self.total_scroll_width < width:
|
if x_pos + self.total_scroll_width < width:
|
||||||
draw.text((x_pos + self.total_scroll_width, y_pos), self.cached_text, font=font, fill=self.text_color)
|
draw.text((x_pos + self.total_scroll_width, y_pos), self.cached_text, font=font, fill=self.text_color)
|
||||||
|
|
||||||
# Update scroll position
|
# Check if we should rotate headlines (when scroll wraps around)
|
||||||
self.scroll_position += self.scroll_speed
|
if self.scroll_position == 0:
|
||||||
|
|
||||||
# Reset scroll when text has completely passed
|
|
||||||
if self.scroll_position >= self.total_scroll_width:
|
|
||||||
self.scroll_position = 0
|
|
||||||
self.rotation_count += 1
|
self.rotation_count += 1
|
||||||
|
|
||||||
# Check if we should rotate headlines
|
# Check if we should rotate headlines
|
||||||
|
|||||||
Reference in New Issue
Block a user