From c08ab09e327e124db8cef83cf5fee41ef46d12bf Mon Sep 17 00:00:00 2001 From: RetiredWizard Date: Sun, 23 Jun 2024 03:22:08 -0400 Subject: [PATCH 1/6] Use supervisor.ticks_ms for scrolling_label animation --- adafruit_display_text/scrolling_label.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/adafruit_display_text/scrolling_label.py b/adafruit_display_text/scrolling_label.py index 91206ec..2242803 100644 --- a/adafruit_display_text/scrolling_label.py +++ b/adafruit_display_text/scrolling_label.py @@ -26,7 +26,7 @@ __version__ = "0.0.0+auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_Display_Text.git" -import time +from supervisor import ticks_ms from adafruit_display_text import bitmap_label try: @@ -81,8 +81,10 @@ def update(self, force: bool = False) -> None: Default is False. :return: None """ - _now = time.monotonic() - if force or self._last_animate_time + self.animate_time <= _now: + _now = ticks_ms() + if _now < self._last_animate_time: # ticks_ms has rolled over + self._last_animate_time = _now + if force or self._last_animate_time + (self.animate_time*1000) <= _now: if len(self.full_text) <= self.max_characters: super()._set_text(self.full_text, self.scale) self._last_animate_time = _now From ecc0e039ec8fc690dfd8a71f4d601df235848c9f Mon Sep 17 00:00:00 2001 From: RetiredWizard Date: Sun, 23 Jun 2024 03:37:37 -0400 Subject: [PATCH 2/6] pre-commit fixes --- adafruit_display_text/scrolling_label.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_display_text/scrolling_label.py b/adafruit_display_text/scrolling_label.py index 2242803..454510f 100644 --- a/adafruit_display_text/scrolling_label.py +++ b/adafruit_display_text/scrolling_label.py @@ -84,7 +84,7 @@ def update(self, force: bool = False) -> None: _now = ticks_ms() if _now < self._last_animate_time: # ticks_ms has rolled over self._last_animate_time = _now - if force or self._last_animate_time + (self.animate_time*1000) <= _now: + if force or self._last_animate_time + (self.animate_time * 1000) <= _now: if len(self.full_text) <= self.max_characters: super()._set_text(self.full_text, self.scale) self._last_animate_time = _now From 5e2fd8bc115b585ed2c02eb7e35384e4d0cbfb4c Mon Sep 17 00:00:00 2001 From: RetiredWizard Date: Sun, 23 Jun 2024 15:19:27 -0400 Subject: [PATCH 3/6] Add supervisor to docs conf.py --- docs/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index a355fd3..b6e4093 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -27,7 +27,7 @@ # Uncomment the below if you use native CircuitPython modules such as # digitalio, micropython and busio. List the modules you use. Without it, the # autodoc module docs will fail to generate with a warning. -autodoc_mock_imports = ["displayio", "adafruit_bitmap_font", "fontio", "bitmaptools"] +autodoc_mock_imports = ["displayio", "adafruit_bitmap_font", "fontio", "bitmaptools","supervisor"] intersphinx_mapping = { From 2e3b344a8f820f4635686b038304346920dd5b1d Mon Sep 17 00:00:00 2001 From: RetiredWizard Date: Sun, 23 Jun 2024 15:22:25 -0400 Subject: [PATCH 4/6] pre-commit formatting change --- docs/conf.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index b6e4093..76b54bd 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -27,7 +27,13 @@ # Uncomment the below if you use native CircuitPython modules such as # digitalio, micropython and busio. List the modules you use. Without it, the # autodoc module docs will fail to generate with a warning. -autodoc_mock_imports = ["displayio", "adafruit_bitmap_font", "fontio", "bitmaptools","supervisor"] +autodoc_mock_imports = [ + "displayio", + "adafruit_bitmap_font", + "fontio", + "bitmaptools", + "supervisor", +] intersphinx_mapping = { From 34bb2f16151a9501eb482f9b27c15144749a9508 Mon Sep 17 00:00:00 2001 From: RetiredWizard Date: Sun, 23 Jun 2024 18:19:46 -0400 Subject: [PATCH 5/6] adafruit_circuitpython_ticks rather than supervisor --- adafruit_display_text/scrolling_label.py | 2 +- docs/conf.py | 1 - requirements.txt | 1 + 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/adafruit_display_text/scrolling_label.py b/adafruit_display_text/scrolling_label.py index 454510f..ac7d46d 100644 --- a/adafruit_display_text/scrolling_label.py +++ b/adafruit_display_text/scrolling_label.py @@ -26,7 +26,7 @@ __version__ = "0.0.0+auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_Display_Text.git" -from supervisor import ticks_ms +from adafruit_ticks import ticks_ms from adafruit_display_text import bitmap_label try: diff --git a/docs/conf.py b/docs/conf.py index 76b54bd..de06824 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -32,7 +32,6 @@ "adafruit_bitmap_font", "fontio", "bitmaptools", - "supervisor", ] diff --git a/requirements.txt b/requirements.txt index cb4ca17..cdc14cf 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,3 +5,4 @@ Adafruit-Blinka-displayio>=0.10.2 Adafruit-Blinka adafruit-circuitpython-bitmap-font +adafruit-circuitpython-ticks From 666731bc8d095fb5790cd511ef7ee04d1fdf06f5 Mon Sep 17 00:00:00 2001 From: RetiredWizard Date: Mon, 24 Jun 2024 14:39:03 -0400 Subject: [PATCH 6/6] use adafruit_ticks methods to handle ticks rollover --- adafruit_display_text/scrolling_label.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/adafruit_display_text/scrolling_label.py b/adafruit_display_text/scrolling_label.py index ac7d46d..2031c5d 100644 --- a/adafruit_display_text/scrolling_label.py +++ b/adafruit_display_text/scrolling_label.py @@ -26,7 +26,7 @@ __version__ = "0.0.0+auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_Display_Text.git" -from adafruit_ticks import ticks_ms +import adafruit_ticks from adafruit_display_text import bitmap_label try: @@ -81,10 +81,10 @@ def update(self, force: bool = False) -> None: Default is False. :return: None """ - _now = ticks_ms() - if _now < self._last_animate_time: # ticks_ms has rolled over - self._last_animate_time = _now - if force or self._last_animate_time + (self.animate_time * 1000) <= _now: + _now = adafruit_ticks.ticks_ms() + if force or adafruit_ticks.ticks_less( + self._last_animate_time + int(self.animate_time * 1000), _now + ): if len(self.full_text) <= self.max_characters: super()._set_text(self.full_text, self.scale) self._last_animate_time = _now