Skip to content

Commit dab1951

Browse files
authored
Merge pull request #36 from ladyada/rotate
you spin me right round baby right round
2 parents 0905b50 + cf9b998 commit dab1951

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

adafruit_magtag/graphics.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,15 @@ class Graphics:
4141
Defaults to 0x000000.
4242
:param bool auto_refresh: Automatically refresh the eInk after writing to displayio.
4343
Defaults to True.
44+
:param rotation: Default rotation is landscape (270) but can be 0, 90, 180 for portrait/rotated
4445
:param debug: Turn on debug print outs. Defaults to False.
4546
4647
"""
4748

4849
# pylint: disable=too-many-instance-attributes, too-many-locals, too-many-branches, too-many-statements
49-
def __init__(self, *, default_bg=0xFFFFFF, auto_refresh=True, debug=False):
50+
def __init__(
51+
self, *, default_bg=0xFFFFFF, auto_refresh=True, rotation=270, debug=False
52+
):
5053

5154
self._debug = debug
5255
if not hasattr(board, "DISPLAY"):
@@ -65,7 +68,7 @@ def __init__(self, *, default_bg=0xFFFFFF, auto_refresh=True, debug=False):
6568
display_bus,
6669
width=296,
6770
height=128,
68-
rotation=270,
71+
rotation=rotation,
6972
black_bits_inverted=False,
7073
color_bits_inverted=False,
7174
grayscale=True,
@@ -74,6 +77,7 @@ def __init__(self, *, default_bg=0xFFFFFF, auto_refresh=True, debug=False):
7477
)
7578
else:
7679
self.display = board.DISPLAY
80+
self.display.rotation = rotation
7781

7882
self.auto_refresh = auto_refresh
7983

adafruit_magtag/magtag.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ class MagTag:
5454
NeoPixel. Defaults to ``None``, not the status LED
5555
:param json_transform: A function or a list of functions to call with the parsed JSON.
5656
Changes and additions are permitted for the ``dict`` object.
57+
:param rotation: Default rotation is landscape (270) but can be 0, 90, or 180 for
58+
portrait/rotated
5759
:param debug: Turn on debug print outs. Defaults to False.
5860
5961
"""
@@ -69,13 +71,15 @@ def __init__(
6971
default_bg=0xFFFFFF,
7072
status_neopixel=None,
7173
json_transform=None,
74+
rotation=270,
7275
debug=False,
7376
):
7477

7578
self._debug = debug
7679
self.graphics = Graphics(
7780
default_bg=default_bg,
7881
auto_refresh=False,
82+
rotation=rotation,
7983
debug=debug,
8084
)
8185
self.display = self.graphics.display

0 commit comments

Comments
 (0)