Skip to content
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
21 changes: 17 additions & 4 deletions ev3dev2/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ def text_pixels(self, text, clear_screen=True, x=0, y=0, text_color='black', fon
Display `text` starting at pixel (x, y).
The EV3 display is 178x128 pixels
- (0, 0) would be the top left corner of the display
- (89, 64) would be right in the middle of the display
Expand All @@ -374,15 +375,22 @@ def text_pixels(self, text, clear_screen=True, x=0, y=0, text_color='black', fon
https://www.w3schools.com/colors/colors_names.asp
'font' : can be any font displayed here
http://ev3dev-lang.readthedocs.io/projects/python-ev3dev/en/ev3dev-stretch/other.html#bitmap-fonts
http://ev3dev-lang.readthedocs.io/projects/python-ev3dev/en/ev3dev-stretch/display.html#bitmap-fonts
- If font is a string, it is the name of a font to be loaded.
- If font is a Font object, returned from :meth:`ev3dev2.fonts.load`, then it is
used directly. This is desirable for faster display times.
"""

if clear_screen:
self.clear()

if font is not None:
assert font in fonts.available(), "%s is an invalid font" % font
return self.draw.text((x, y), text, fill=text_color, font=fonts.load(font))
if isinstance(font, str):
assert font in fonts.available(), "%s is an invalid font" % font
font = fonts.load(font)
return self.draw.text((x, y), text, fill=text_color, font=font)
else:
return self.draw.text((x, y), text, fill=text_color)

Expand All @@ -400,7 +408,12 @@ def text_grid(self, text, clear_screen=True, x=0, y=0, text_color='black', font=
https://www.w3schools.com/colors/colors_names.asp
'font' : can be any font displayed here
http://ev3dev-lang.readthedocs.io/projects/python-ev3dev/en/ev3dev-stretch/other.html#bitmap-fonts
http://ev3dev-lang.readthedocs.io/projects/python-ev3dev/en/ev3dev-stretch/display.html#bitmap-fonts
- If font is a string, it is the name of a font to be loaded.
- If font is a Font object, returned from :meth:`ev3dev2.fonts.load`, then it is
used directly. This is desirable for faster display times.
"""

assert 0 <= x < Display.GRID_COLUMNS,\
Expand Down