Skip to main content

Display

Display

Library

Stemi display library includes a couple of functions and a global switch to ease handling of the display.

display.py
group = None # variable that will hold the display's group instance
print_to_display = True
wrap_lines = True

def clear(hard=False):
...

def write(text, line=None):
...

def write_to_str(text, text_before="", line=None):
...

Explanations

ReturnsDescription
groupAn instance of displayio.Group(), can be used to display additional information on the display, ex. additional shapes or text layers
print_to_displayControls if print() will also output to the display
wrap_linesIf True, both write and write_to_str will wrap their given text around display width
clearClears the display of text, if hard=True will also remove any additional elements attached to group
writeWill output given text to the display, if line is specified (as int), it will override whatever text was on that line or
write_to_strstringReturns a string as if using write without outputting to the display, if line is specified (as int), it will override whatever text was on that line

Example

main.py
from adafruit_display_text import label
from stemi import display

display.print_to_display = False

print("This will not be shown on the display")
display.write("But this will")

my_label = label.Label(...)
display.group.append(my_label)
note

The display will work as described above only if the user doesn't release the display

Releasing the display example

import displayio

displayio.release_displays()