display
- Display¶
The display module let’s you draw on the card10’s display. Pixels are addressed from top left to bottom right with a range of x: 0 to 159 and y: 0 to 79.
0,0
+---------------------+
| |
| |
| |
| |
+---------------------+
159,79
Drawing operations are clipped, pixels outside of the screen will be ignored.
-
class
display.
Display
[source]¶ The display class provides methods to allow the lcd display in card10 to be used in a safe way. All draw methods return the display object so that it is possible to chain calls. It is recommended to use a context manager as following:
import display with display.open() as disp: disp.clear().update()
-
static
close
()[source]¶ Closes and unlocks the display. To be able to use it again, it is necessary to open and lock it again with Display.open()
-
update
()[source]¶ Updates the display based on the changes previously made by various draw functions
-
clear
(col=None)[source]¶ Clears the display using the color provided, or the default color black
- Parameters
col – Clearing color (expects RGB triple)
-
print
(text, *, fg=None, bg=None, posx=0, posy=0, font=3)[source]¶ Prints a string on the display.
- Parameters
text – Text to print
fg – Foreground color (expects RGB triple)
bg – Background color (expects RGB triple) or None for transparent background
posx – X-Position of the first character
posy – Y-Position of the first character
font – 0 <= font <= 4 (currently) selects a font
Avaiable Fonts:
display.FONT8
display.FONT12
display.FONT16
display.FONT20
display.FONT24
Example:
with display.open() as d: d.clear() d.print('Hello Earth!', font=display.FONT24) d.update()
Changed in version 1.11: Added transparent background printing.
-
pixel
(x, y, *, col=None)[source]¶ Draws a pixel on the display
- Parameters
x – X coordinate
y – Y coordinate
col – color of the pixel (expects RGB tripple)
-
backlight
(brightness)[source]¶ Set display backlight brightness
- Parameters
brightness – backlight brightness 0 <= brightness <= 100
-
line
(xs, ys, xe, ye, *, col=None, dotted=False, size=1)[source]¶ Draws a line on the display.
- Parameters
xs – X start coordinate
ys – Y start coordinate
xe – X end coordinate
ye – Y end coordinate
col – color of the line (expects RGB triple)
dotted – whether the line should be dotted or not (questionable implementation: draws every other pixel white, draws white squares at higher pixel sizes)
size – size of the individual pixels, ranges from 1 to 8
-
rect
(xs, ys, xe, ye, *, col=None, filled=True, size=1)[source]¶ Draws a rectangle on the display.
- Parameters
xs – X start coordinate
ys – Y start coordinate
xe – X end coordinate
ye – Y end coordinate
col – color of the outline and fill (expects RGB triple)
filled – whether the rectangle should be filled or not
size – size of the individual pixels, ranges from 1 to 8
-
circ
(x, y, rad, *, col=None, filled=True, size=1)[source]¶ Draws a circle on the display.
- Parameters
x – center x coordinate
y – center y coordinate
rad – radius
col – color of the outline and fill (expects RGB triple)
filled – whether the rectangle should be filled or not
size – size of the individual pixels, ranges from 1 to 8
-
static
-
display.
open
()¶ Opens the display. Will fail the display can’t be locked
-
display.
close
()¶ Closes and unlocks the display. To be able to use it again, it is necessary to open and lock it again with Display.open()