display - Display

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()
classmethod open()[source]

Opens the display. Will fail the display can’t be locked

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)[source]

Prints a string on the display. Font size is locked to 20px

Parameters
  • text – Text to print

  • fg – Foreground color (expects RGB triple)

  • bg – Background color (expects RGB triple)

  • posx – X-Position of the first character, 0 <= posx <= 160

  • posy – Y-Position of the first character, 0 <= posy <= 80

pixel(x, y, *, col=None)[source]

Draws a pixel on the display

Parameters
  • x – X coordinate, 0<= x <= 160

  • y – Y coordinate, 0<= y <= 80

  • col – color of the pixel (expects RGB tripple)

line(xs, ys, xe, ye, *, col=None, dotted=False, size=1)[source]

Draws a line on the display.

Parameters
  • xs – X start coordinate, 0 <= xs <= 160

  • ys – Y start coordinate, 0 <= ys <= 80

  • xe – X end coordinate, 0 <= xe <= 160

  • ye – Y end coordinate, 0 <= ye <= 80

  • 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, 0 <= xs <= 160

  • ys – Y start coordinate, 0 <= ys <= 80

  • xe – X end coordinate, 0 <= xe <= 160

  • ye – Y end coordinate, 0 <= ye <= 80

  • 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, 0 <= x <= 160

  • y – center y coordinate, 0 <= y <= 80

  • 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

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()