Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update font documentation for display_text() #50

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions adafruit_macropad.py
Original file line number Diff line number Diff line change
Expand Up @@ -899,21 +899,24 @@ def display_text(
Defaults to 80.
:param int text_scale: Scale the size of the data lines. Scales the title as well.
Defaults to 1.
:param font: The font or the path to the custom font file to use to display the text.
Defaults to the built-in ``terminalio.FONT``. Custom font files must be
provided as a string, e.g. ``"/Arial12.bdf"``.
:param ~FontProtocol|None font: The custom font to use to display the text. Defaults to the
built-in ``terminalio.FONT``. For more details, see:
https://docs.circuitpython.org/en/latest/shared-bindings/fontio/index.html

The following example displays a title and lines of text indicating which key is pressed,
the relative position of the rotary encoder, and whether the encoder switch is pressed.
Note that the key press line does not show up until a key is pressed.

.. code-block:: python

from adafruit_bitmap_font import bitmap_font
from adafruit_macropad import MacroPad
from displayio import Bitmap

macropad = MacroPad()

text_lines = macropad.display_text(title="MacroPad Info")
custom_font = bitmap_font.load_font("/Arial12.bdf", Bitmap)
text_lines = macropad.display_text(title="MacroPad Info", font=custom_font)

while True:
key_event = macropad.keys.events.get()
Expand Down