Skip to content

Commit a48e24e

Browse files
Updates to documentation and parameter types.
1 parent 6fef6f1 commit a48e24e

File tree

2 files changed

+32
-34
lines changed

2 files changed

+32
-34
lines changed

adafruit_simple_text_display.py

Lines changed: 28 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
2222
* Adafruit CircuitPython firmware for the supported boards:
2323
https://github.com/adafruit/circuitpython/releases
24-
25-
* Adafruit's Register library: https://github.com/adafruit/Adafruit_CircuitPython_Display_Text
2624
"""
2725

2826
import board
@@ -62,9 +60,9 @@ def __init__( # pylint: disable=too-many-arguments
6260
self,
6361
title=None,
6462
title_color=(255, 255, 255),
65-
title_scale=1,
66-
title_length=80,
67-
text_scale=1,
63+
title_scale: int = 1,
64+
title_length: int = 80,
65+
text_scale: int = 1,
6866
font=None,
6967
colors=None,
7068
display=None,
@@ -78,39 +76,37 @@ def __init__( # pylint: disable=too-many-arguments
7876
must include the data call in the loop by using ``.text =``. For example, if setup is saved
7977
as ``temperature_data = simple_text_display()`` then ``temperature_data[0].text =
8078
microcontroller.cpu.temperature`` must be inside the ``while True:`` loop for the
81-
temperature data displayed to update as the values change. You must call ``show()`` at the
79+
temperature data displayed to update as the values change. You must call `show()` at the
8280
end of the list for anything to display. See example below for usage.
8381
84-
:param str title: The title displayed above the data. Set ``title="Title text"`` to provide
85-
a title. Defaults to None.
86-
:param title_color: The color of the title. Not necessary if no title is provided. Defaults
87-
to white (255, 255, 255).
82+
:param None,str title: The title displayed above the data. Set ``title="Title text"`` to
83+
provide a title. Defaults to `None`.
84+
:param None,Tuple(int,int,int) title_color: The color of the title. Not necessary if no
85+
title is provided. Defaults to white (255, 255, 255).
8886
:param int title_scale: Scale the size of the title. Not necessary if no title is provided.
89-
Defaults to 1.
87+
Defaults to 1.
9088
:param int title_length: The maximum number of characters allowed in the title. Only
91-
necessary if the title is longer than the default 80 characters.
92-
Defaults to 80.
89+
necessary if the title is longer than the default 80 characters. Defaults to 80.
9390
:param int text_scale: Scale the size of the data lines. Scales the title as well.
94-
Defaults to 1.
95-
:param str font: The font to use to display the title and data. Defaults to
96-
``terminalio.FONT``.
97-
:param colors: A list of colors for the lines of data on the display. If you provide a
98-
single color, all lines will be that color. Otherwise it will cycle through
99-
the list you provide if the list is less than the number of lines displayed.
100-
Default colors are used if ``colors`` is not set. For example, if creating
101-
two lines of data, ``colors=((255, 255, 255), (255, 0, 0))`` would set the
102-
first line white and the second line red, and if you created four lines of
103-
data with the same setup, it would alternate white and red. You can also use
104-
the colors built into the library. For example, if you import the library
105-
as ``from adafruit_simple_text_display import SimpleTextDisplay``, you can
106-
indicate the colors as follows:
107-
``colors=(SimpleDisplayText.WHITE, SimpleDisplayText.RED)``.
108-
:param display: The display object. Defaults to assuming a built-in display. To use with an
109-
external display, instantiate the display object and provide it here.
110-
Defaults to ``board.DISPLAY``.
91+
Defaults to 1.
92+
:param ~fontio.BuiltinFont,~adafruit_bitmap_font.bdf.BDF,~adafruit_bitmap_font.pcf.PCF font:
93+
The font to use to display the title and data. Defaults to `terminalio.FONT`.
94+
:param None,Tuple(Tuple(int,int,int),...) colors: A list of colors for the lines of data
95+
on the display. If you provide a single color, all lines will be that color. Otherwise
96+
it will cycle through the list you provide if the list is less than the number of lines
97+
displayed. Default colors are used if ``colors`` is not set. For example, if creating
98+
two lines of data, ``colors=((255, 255, 255), (255, 0, 0))`` would set the first line
99+
white and the second line red, and if you created four lines of data with the same
100+
setup, it would alternate white and red. You can also use the colors built into the
101+
library. For example, if you import the library as
102+
``from adafruit_simple_text_display import SimpleTextDisplay``, you can indicate the
103+
colors as follows: ``colors=(SimpleDisplayText.WHITE, SimpleDisplayText.RED)``.
104+
:param None,~displayio.Display display: The display object. Defaults to assuming a built-in
105+
display. To use with an external display, instantiate the display object and provide it
106+
here. Defaults to ``board.DISPLAY``.
111107
112108
This example displays two lines with temperature data in C and F on the display.
113-
Remember to call ``show()`` after the list to update the display.
109+
Remember to call `show()` after the list to update the display.
114110
115111
.. code-block:: python
116112
@@ -149,9 +145,7 @@ def __init__( # pylint: disable=too-many-arguments
149145
if display is None:
150146
display = board.DISPLAY
151147
self._display = display
152-
self._font = terminalio.FONT
153-
if font:
154-
self._font = font
148+
self._font = font if font else terminalio.FONT
155149

156150
self.text_group = displayio.Group(scale=text_scale)
157151

docs/conf.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@
3131
intersphinx_mapping = {
3232
"python": ("https://docs.python.org/3.4", None),
3333
"CircuitPython": ("https://circuitpython.readthedocs.io/en/latest/", None),
34+
"Adafruit_CircuitPython_Bitmap_Font": (
35+
"https://circuitpython.readthedocs.io/projects/bitmap-font/en/latest/",
36+
None,
37+
),
3438
}
3539

3640
# Show the docstring from both the class and its __init__() method.

0 commit comments

Comments
 (0)