From 5a170cb7b15897f9055392f205ffc27e59035b58 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 16 Oct 2023 14:30:31 -0500 Subject: [PATCH 01/13] unpin sphinx and add sphinx-rtd-theme to docs reqs Signed-off-by: foamyguy --- docs/requirements.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/requirements.txt b/docs/requirements.txt index 797aa04..979f568 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -2,5 +2,6 @@ # # SPDX-License-Identifier: Unlicense -sphinx>=4.0.0 +sphinx sphinxcontrib-jquery +sphinx-rtd-theme From 057d7fd9facfe60c950d80ae50536c75f0b7b5db Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 7 Oct 2024 09:24:05 -0500 Subject: [PATCH 02/13] remove deprecated get_html_theme_path() call Signed-off-by: foamyguy --- docs/conf.py | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index 58baf1e..618ae93 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -127,7 +127,6 @@ import sphinx_rtd_theme html_theme = "sphinx_rtd_theme" -html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."] # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, From eeac41fe029f0a778eed43df9548960ea291bf30 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 2 Dec 2024 15:58:23 -0600 Subject: [PATCH 03/13] list standard colors in the docstrings --- adafruit_turtle.py | 63 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/adafruit_turtle.py b/adafruit_turtle.py index 23b2a54..3b5c3ae 100644 --- a/adafruit_turtle.py +++ b/adafruit_turtle.py @@ -46,21 +46,84 @@ class Color: """Standard colors""" WHITE = 0xFFFFFF + """White 0xFFFFFF + + :meta hide-value:""" + BLACK = 0x000000 + """Black 0x000000 + + :meta hide-value:""" + RED = 0xFF0000 + """Red 0xFF0000 + + :meta hide-value:""" + ORANGE = 0xFFA500 + """Orange 0xFFA500 + + :meta hide-value:""" + YELLOW = 0xFFEE00 + """Yellow 0xFFEE00 + + :meta hide-value:""" + GREEN = 0x00C000 + """Green 0x00C000 + + :meta hide-value:""" + BLUE = 0x0000FF + """Blue 0x0000FF + + :meta hide-value:""" + PURPLE = 0x8040C0 + """Purple 0x8040C0 + + :meta hide-value:""" + PINK = 0xFF40C0 + """Pink 0xFF40C0 + + :meta hide-value:""" + LIGHT_GRAY = 0xAAAAAA + """Light Gray 0xAAAAAA + + :meta hide-value:""" + GRAY = 0x444444 + """Gray 0x444444 + + :meta hide-value:""" + BROWN = 0xCA801D + """Brown 0xCA801D + + :meta hide-value:""" + DARK_GREEN = 0x008700 + """Dark Green 0x008700 + + :meta hide-value:""" + TURQUOISE = 0x00C0C0 + """Turquoise 0x00C0C0 + + :meta hide-value:""" + DARK_BLUE = 0x0000AA + """Dark Blue 0x0000AA + + :meta hide-value:""" + DARK_RED = 0x800000 + """Dark Red 0x800000 + + :meta hide-value:""" colors = ( BLACK, From ebd591df4541211b42ee31a8531494d7ed967c45 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 2 Dec 2024 16:02:41 -0600 Subject: [PATCH 04/13] remove duplicate color name --- adafruit_turtle.py | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/adafruit_turtle.py b/adafruit_turtle.py index 3b5c3ae..c7c41ea 100644 --- a/adafruit_turtle.py +++ b/adafruit_turtle.py @@ -46,83 +46,83 @@ class Color: """Standard colors""" WHITE = 0xFFFFFF - """White 0xFFFFFF + """0xFFFFFF :meta hide-value:""" BLACK = 0x000000 - """Black 0x000000 + """0x000000 :meta hide-value:""" RED = 0xFF0000 - """Red 0xFF0000 + """0xFF0000 :meta hide-value:""" ORANGE = 0xFFA500 - """Orange 0xFFA500 + """0xFFA500 :meta hide-value:""" YELLOW = 0xFFEE00 - """Yellow 0xFFEE00 + """0xFFEE00 :meta hide-value:""" GREEN = 0x00C000 - """Green 0x00C000 + """0x00C000 :meta hide-value:""" BLUE = 0x0000FF - """Blue 0x0000FF + """0x0000FF :meta hide-value:""" PURPLE = 0x8040C0 - """Purple 0x8040C0 + """0x8040C0 :meta hide-value:""" PINK = 0xFF40C0 - """Pink 0xFF40C0 + """0xFF40C0 :meta hide-value:""" LIGHT_GRAY = 0xAAAAAA - """Light Gray 0xAAAAAA + """0xAAAAAA :meta hide-value:""" GRAY = 0x444444 - """Gray 0x444444 + """0x444444 :meta hide-value:""" BROWN = 0xCA801D - """Brown 0xCA801D + """0xCA801D :meta hide-value:""" DARK_GREEN = 0x008700 - """Dark Green 0x008700 + """0x008700 :meta hide-value:""" TURQUOISE = 0x00C0C0 - """Turquoise 0x00C0C0 + """0x00C0C0 :meta hide-value:""" DARK_BLUE = 0x0000AA - """Dark Blue 0x0000AA + """0x0000AA :meta hide-value:""" DARK_RED = 0x800000 - """Dark Red 0x800000 - + """0x800000 + :meta hide-value:""" colors = ( From 0c57fd42dcf745ffa75a9e318a252b9ad001087b Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 2 Dec 2024 16:06:44 -0600 Subject: [PATCH 05/13] format --- adafruit_turtle.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_turtle.py b/adafruit_turtle.py index c7c41ea..b501c22 100644 --- a/adafruit_turtle.py +++ b/adafruit_turtle.py @@ -122,7 +122,7 @@ class Color: DARK_RED = 0x800000 """0x800000 - + :meta hide-value:""" colors = ( From f2ae512e0e86c6e70dcd2c04251480c98526ebb2 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 2 Dec 2024 17:24:48 -0600 Subject: [PATCH 06/13] default to "standard" mode --- adafruit_turtle.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/adafruit_turtle.py b/adafruit_turtle.py index 23b2a54..b255b84 100644 --- a/adafruit_turtle.py +++ b/adafruit_turtle.py @@ -171,11 +171,11 @@ def __init__( self._y = self._h // (2 * scale) self._speed = 6 self._heading: float = 0 - self._logomode = True self._fullcircle = 360.0 self._degreesPerAU = 1.0 - self._angleOrient = 1 - self._angleOffset: float = 0 + self._logomode = False + self._angleOrient = -1 + self._angleOffset: float = self._fullcircle / 4 self._bg_color = 0 self._splash: displayio.Group = displayio.Group() From e921f796f1578e6b87cd369f0735a9e07b071a0d Mon Sep 17 00:00:00 2001 From: foamyguy Date: Wed, 4 Dec 2024 09:30:24 -0600 Subject: [PATCH 07/13] make circle and dot always use degrees internally --- adafruit_turtle.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/adafruit_turtle.py b/adafruit_turtle.py index c9d7f97..ed5a550 100644 --- a/adafruit_turtle.py +++ b/adafruit_turtle.py @@ -626,6 +626,12 @@ def circle( # --or: circle(radius, extent) # arc # --or: circle(radius, extent, steps) # --or: circle(radius, steps=6) # 6-sided polygon + change_back = False + if not self._in_degrees(): + change_back = True + original_mode = "standard" if not self._logomode else "logo" + self.degrees() + self.mode("standard") pos = self.pos() h = self._heading if extent is None: @@ -647,6 +653,9 @@ def circle( # get back to exact same position and heading self.goto(pos) self.setheading(h) + if change_back: + self.radians() + self.mode(original_mode) # pylint: disable=possibly-used-before-assignment # pylint:disable=inconsistent-return-statements def speed(self, speed: Optional[int] = None) -> Optional[int]: @@ -690,6 +699,13 @@ def dot(self, size: Optional[int] = None, color: Optional[int] = None) -> None: :param color: the color of the dot """ + change_back = False + if not self._in_degrees(): + change_back = True + original_mode = "standard" if not self._logomode else "logo" + print(f"old mode: {original_mode}") + self.degrees() + self.mode("standard") if size is None: size = max(self._pensize + 4, self._pensize * 2) if color is None: @@ -713,6 +729,9 @@ def dot(self, size: Optional[int] = None, color: Optional[int] = None) -> None: self._pensize = 1 self._plot(self._x, self._y, color) self._pensize = pensize + if change_back: + self.radians() + self.mode(original_mode) # pylint: disable=possibly-used-before-assignment def stamp( self, @@ -882,6 +901,10 @@ def degrees(self, fullcircle: float = 360) -> None: """ self._setDegreesPerAU(fullcircle) + def _in_degrees(self) -> bool: + print(self._degreesPerAU) + return self._degreesPerAU == 1.0 + def radians(self) -> None: """Set the angle measurement units to radians. Equivalent to degrees(2*math.pi).""" From 96222c342964255c0a4f23d2cf7f077a408dec3f Mon Sep 17 00:00:00 2001 From: foamyguy Date: Wed, 4 Dec 2024 10:12:15 -0600 Subject: [PATCH 08/13] remove space --- adafruit_turtle.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/adafruit_turtle.py b/adafruit_turtle.py index ed5a550..dfa6d0e 100644 --- a/adafruit_turtle.py +++ b/adafruit_turtle.py @@ -655,7 +655,7 @@ def circle( self.setheading(h) if change_back: self.radians() - self.mode(original_mode) # pylint: disable=possibly-used-before-assignment + self.mode(original_mode) # pylint:disable=possibly-used-before-assignment # pylint:disable=inconsistent-return-statements def speed(self, speed: Optional[int] = None) -> Optional[int]: @@ -731,7 +731,7 @@ def dot(self, size: Optional[int] = None, color: Optional[int] = None) -> None: self._pensize = pensize if change_back: self.radians() - self.mode(original_mode) # pylint: disable=possibly-used-before-assignment + self.mode(original_mode) # pylint:disable=possibly-used-before-assignment def stamp( self, From 591b805474ebc34297c45f7416c2ad389588cc73 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Wed, 4 Dec 2024 10:16:11 -0600 Subject: [PATCH 09/13] remove pylint disables --- adafruit_turtle.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/adafruit_turtle.py b/adafruit_turtle.py index dfa6d0e..df57e77 100644 --- a/adafruit_turtle.py +++ b/adafruit_turtle.py @@ -655,7 +655,7 @@ def circle( self.setheading(h) if change_back: self.radians() - self.mode(original_mode) # pylint:disable=possibly-used-before-assignment + self.mode(original_mode) # pylint:disable=inconsistent-return-statements def speed(self, speed: Optional[int] = None) -> Optional[int]: @@ -731,7 +731,7 @@ def dot(self, size: Optional[int] = None, color: Optional[int] = None) -> None: self._pensize = pensize if change_back: self.radians() - self.mode(original_mode) # pylint:disable=possibly-used-before-assignment + self.mode(original_mode) def stamp( self, From 614e9e2b4fd2012679b8a35f49126495c12c3fb9 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 4 Dec 2024 17:51:34 -0600 Subject: [PATCH 10/13] Account for fractions of a pixel when drawing Previously, the endpoint of the line was always moved along in increments of 1 pixel, so that the endpoint would always be rounded down. This could accumulate to give quite large differences from what the program intended. Ensure that "goto" always ends up storing the floating point endpoints and that the line is drawn from the rounded-integer starting coordinate and rounded-integer ending coordinate. This makes the 3 test lines in the OP's "turtle_truncate.txt" example be the same length. Closes: #41 --- adafruit_turtle.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/adafruit_turtle.py b/adafruit_turtle.py index c9d7f97..54cdcf4 100644 --- a/adafruit_turtle.py +++ b/adafruit_turtle.py @@ -407,13 +407,17 @@ def goto( xn: float = x1[0] if y1 is None else x1 # type: ignore xn += self._w // 2 yn = self._h // 2 - yn - x0 = self._x - y0 = self._y if not self.isdown(): self._x = xn # woot, we just skip ahead self._y = yn self._drawturtle() return + + self._do_draw_line(round(self._x), round(self._y), round(xn), round(yn)) + self._x = xn + self._y = yn + + def _do_draw_line(self, x0: int, y0: int, xn: int, yn: int): steep = abs(yn - y0) > abs(xn - x0) rev = False dx = xn - x0 @@ -444,15 +448,11 @@ def goto( self._plot(int(y0), int(x0), self._pencolor) except IndexError: pass - self._x = y0 - self._y = x0 else: try: self._plot(int(x0), int(y0), self._pencolor) except IndexError: pass - self._x = x0 - self._y = y0 if self._speed > 0: if step >= self._speed: # mark the step From 277983a83636bd1bba1f50b40bea7dd27692be85 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 9 Dec 2024 09:12:37 -0600 Subject: [PATCH 11/13] fix for visible turtle location --- adafruit_turtle.py | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/adafruit_turtle.py b/adafruit_turtle.py index 54cdcf4..5c40b4d 100644 --- a/adafruit_turtle.py +++ b/adafruit_turtle.py @@ -311,6 +311,8 @@ def __init__( self._turtle_pic = None self._turtle_odb = None self._turtle_alt_sprite = None + self._turtle_x = self._x + self._turtle_y = self._y self._drawturtle() self._stamps = {} self._turtle_odb_use = 0 @@ -323,15 +325,23 @@ def __init__( def _drawturtle(self) -> None: if self._turtle_pic is None: - self._turtle_sprite.x = int(self._x - 4) - self._turtle_sprite.y = int(self._y - 4) + self._turtle_sprite.x = int(self._turtle_x - 4) + self._turtle_sprite.y = int(self._turtle_y - 4) else: if self._turtle_odb is not None: - self._turtle_alt_sprite.x = int(self._x - self._turtle_odb.width // 2) - self._turtle_alt_sprite.y = int(self._y - self._turtle_odb.height // 2) + self._turtle_alt_sprite.x = int( + self._turtle_x - self._turtle_odb.width // 2 + ) + self._turtle_alt_sprite.y = int( + self._turtle_y - self._turtle_odb.height // 2 + ) else: - self._turtle_alt_sprite.x = int(self._x - self._turtle_pic[0] // 2) - self._turtle_alt_sprite.y = int(self._y - self._turtle_pic[1] // 2) + self._turtle_alt_sprite.x = int( + self._turtle_x - self._turtle_pic[0] // 2 + ) + self._turtle_alt_sprite.y = int( + self._turtle_y - self._turtle_pic[1] // 2 + ) ########################################################################### # Move and draw @@ -448,11 +458,15 @@ def _do_draw_line(self, x0: int, y0: int, xn: int, yn: int): self._plot(int(y0), int(x0), self._pencolor) except IndexError: pass + self._turtle_x = y0 + self._turtle_y = x0 else: try: self._plot(int(x0), int(y0), self._pencolor) except IndexError: pass + self._turtle_x = x0 + self._turtle_y = y0 if self._speed > 0: if step >= self._speed: # mark the step From 5aaa6abd758af2e0b0d46744634617285d992700 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Tue, 14 Jan 2025 11:32:34 -0600 Subject: [PATCH 12/13] add sphinx configuration to rtd.yaml Signed-off-by: foamyguy --- .readthedocs.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 33c2a61..88bca9f 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -8,6 +8,9 @@ # Required version: 2 +sphinx: + configuration: docs/conf.py + build: os: ubuntu-20.04 tools: From cb4511ae61697247bb473741fb52b6b9e12a67cf Mon Sep 17 00:00:00 2001 From: Justin Myers Date: Thu, 27 Feb 2025 15:43:54 -0800 Subject: [PATCH 13/13] Remove secrets usage --- docs/conf.py | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index 618ae93..e4137e6 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -39,7 +39,6 @@ "adafruit_bitmap_font", "adafruit_display_text", "adafruit_esp32spi", - "secrets", "adafruit_sdcard", "storage", "adafruit_io",