Skip to content

Commit 4d72041

Browse files
committed
UPDATE - UPD direction inclusion - Docs Update
1 parent 3f5a042 commit 4d72041

File tree

2 files changed

+39
-4
lines changed

2 files changed

+39
-4
lines changed

adafruit_display_text/__init__.py

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,36 +161,67 @@ class LabelBase(Group):
161161
Subclasses should implement ``_set_text``, ``_set_font``, and ``_set_line_spacing`` to
162162
have the correct behavior for that type of label.
163163
164+
Anchor points are represented in the corners of the following graph
165+
166+
(0.0,0.0)┌──────────────────────────────────────────────────────────────┐ (1.0,0.0)
167+
│ @@ | │
168+
│ @@ Ascent │
169+
│ @@ | │
170+
│------------------------------------------@@+-----|-----------│
171+
│ %@ @% @@@@@@@@% %@@@@@@@@ | │
172+
│ %@ @% @@% %@ @% %@@ | │
173+
│ %@% @@ @% %@ @@ | │ Bounding BOX
174+
│ %@% @@ @$ $@ @@ | │
175+
│ %@ @% @@$ @ @% $@@ | │
176+
│ %@ @% @@@@@@@% %@@@@@@@ | │
177+
│-------------------@@+----------------------------------------│ Baseline
178+
│ @@ | │
179+
│ @@ Descent │
180+
│ @@___| │
181+
(0.0,1.0)╰──────────────────────────────────────────────────────────────┘(1.0,1.0)
182+
183+
164184
:param Font font: A font class that has ``get_bounding_box`` and ``get_glyph``.
165185
Must include a capital M for measuring character size.
166186
:param str text: Text to display
167187
:param int max_glyphs: Unnecessary parameter (provided only for direct compability
168188
with :py:func:`~adafruit_display_text.label.Label`)
189+
169190
:param int color: Color of all text in RGB hex
170191
:param int background_color: Color of the background, use `None` for transparent
192+
171193
:param float line_spacing: Line spacing of text to display
194+
172195
:param bool background_tight: Set `True` only if you want background box to tightly
173196
surround text. When set to 'True' Padding parameters will be ignored.
197+
174198
:param int padding_top: Additional pixels added to background bounding box at top
175199
:param int padding_bottom: Additional pixels added to background bounding box at bottom
176200
:param int padding_left: Additional pixels added to background bounding box at left
177201
:param int padding_right: Additional pixels added to background bounding box at right
202+
178203
:param (float,float) anchor_point: Point that anchored_position moves relative to.
179204
Tuple with decimal percentage of width and height.
180205
(E.g. (0,0) is top left, (1.0, 0.5): is middle right.)
181206
:param (int,int) anchored_position: Position relative to the anchor_point. Tuple
182207
containing x,y pixel coordinates.
208+
183209
:param int scale: Integer value of the pixel scaling
210+
184211
:param bool save_text: Set True to save the text string as a constant in the
185212
label structure. Set False to reduce memory use.
213+
186214
:param bool base_alignment: when True allows to align text label to the baseline.
187215
This is helpful when two or more labels need to be aligned to the same baseline
216+
188217
:param (int,str) tab_replacement: tuple with tab character replace information. When
189218
(4, " ") will indicate a tab replacement of 4 spaces, defaults to 4 spaces by
190219
tab character
220+
191221
:param str label_direction: string defining the label text orientation. There are 5
192222
configurations possibles ``LTR``-Left-To-Right ``RTL``-Right-To-Left
193-
``TTB``-Top-To-Bottom ``UPR``-Upwards ``DWR``-Downwards. It defaults to ``LTR``"""
223+
``TTB``-Top-To-Bottom ``UPR``-Upwards ``DWR``-Downwards and ``UPD``-Upside-Down
224+
(bitmap_label only). It defaults to ``LTR``"""
194225

195226
# pylint: disable=unused-argument, too-many-instance-attributes, too-many-locals, too-many-arguments
196227
def __init__(
@@ -235,7 +266,7 @@ def __init__(
235266

236267
self._text = text
237268

238-
if label_direction not in ["LTR", "RTL", "UPR", "DWR", "TTB"]:
269+
if label_direction not in ["LTR", "RTL", "UPR", "DWR", "TTB", "UPD"]:
239270
raise RuntimeError("Please provide a valid text direction")
240271
self._label_direction = label_direction
241272

@@ -384,6 +415,7 @@ def bounding_box(self) -> Tuple[int, int]:
384415
first two numbers are offset from the x, y origin of this group"""
385416
return tuple(self._bounding_box)
386417

418+
# pylint: disable=no-member
387419
@property
388420
def line_spacing(self) -> float:
389421
"""The amount of space between lines of text, in multiples of the font's
@@ -410,6 +442,6 @@ def _set_label_direction(self, new_label_direction: str) -> None:
410442
@label_direction.setter
411443
def label_direction(self, new_label_direction: str) -> None:
412444
"""Set the text direction of the label"""
413-
if new_label_direction not in ["LTR", "RTL", "UPR", "DWR", "TTB"]:
445+
if new_label_direction not in ["LTR", "RTL", "UPR", "DWR", "TTB", "UPD"]:
414446
raise RuntimeError("Please provide a valid text direction")
415447
self._set_label_direction(new_label_direction)

adafruit_display_text/bitmap_label.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class Label(LabelBase):
7979
tab character
8080
:param str label_direction: string defining the label text orientation. There are 5
8181
configurations possibles ``LTR``-Left-To-Right ``RTL``-Right-To-Left
82-
``UPR``-Upwards ``DWR``-Downwards. It defaults to ``LTR``"""
82+
``UPR``-Upwards ``DWR``-Downwards and ``UPD``-Upside-Down. It defaults to ``LTR``"""
8383

8484
# pylint: disable=unused-argument, too-many-instance-attributes, too-many-locals, too-many-arguments
8585
# pylint: disable=too-many-branches, no-self-use, too-many-statements
@@ -282,6 +282,9 @@ def _reset_text(
282282
if self._label_direction == "DWR":
283283
self.tilegrid.transpose_xy = True
284284
self.tilegrid.flip_y = True
285+
if self._label_direction == "UPD":
286+
self.tilegrid.flip_x = True
287+
self.tilegrid.flip_y = True
285288

286289
# Clear out any items in the local_group Group, in case this is an update to
287290
# the bitmap_label

0 commit comments

Comments
 (0)