hub.display
– Display¶
The display module lets you control the light matrix display on the hub.
-
hub.display.
clear
()¶ Turns off all the pixels.
-
hub.display.
rotation
(rotation: int) → None¶ Rotates the display clockwise relative to its current orientation.
DEPRECATION WARNING - In the next release this is a do-nothing operation. Use the hub.display.align() API instead!
Following the next release this call will be removed.
-
hub.display.
align
() → int¶ -
hub.display.
align
(face: int) → int Rotates the display by aligning the top with the given face of the hub.
-
hub.display.
invert
() → bool¶ -
hub.display.
invert
(invert: bool) → bool Inverts all pixels. This affects what is currently displayed, as well as everything you display afterwards.
In the inverted state, the brightness of each pixel is the opposite of the normal state. If a pixel has brightness
b
, it will be displayed with brightness9 - b
.- Parameters
invert – Choose
True
to activate the inverted state. ChooseFalse
to restore the normal state.- Returns
The new or current inversion state.
-
hub.display.
callback
(self, function: Callable[[int], None]) → None¶ Sets the callback function that is called when a display operation is completed or interrupted.
The function must accept one argument, which indicates why the callback was called. It will receive
0
if a display operation completed successfully, or1
if it was interrupted.- Parameters
function – Callable function that takes one argument. Choose
None
to disable the callback.
-
hub.display.
pixel
(x: int, y: int) → int¶ -
hub.display.
pixel
(x: int, y: int, brightness: int) → None Gets or sets the brightness of one pixel.
- Parameters
x – Pixel position counted from the left, starting at zero.
y – Pixel position counted from the top, starting at zero.
brightness – Brightness between
0
(fully off) and9
(fully on).
- Returns
If no brightness is given, this returns the brightness of the selected pixel. Otherwise it returns
None
.
-
hub.display.
show
(image: hub.Image) → None¶ -
hub.display.
show
(image: Iterable[hub.Image], delay=400, level=9, clear=False, wait=True, loop=False, fade=0) → None Shows an image or a sequence of images.
Except for
image
, all arguments must be specified as keywords.- Parameters
image – The image or iterable of images to be displayed.
- Keyword Arguments
delay – Delay between each image in the iterable.
level – Scales the brightness of each pixel in and image or character to a value between
0
(fully off) and9
(fully on).clear – Choose
True
to clear the display after showing the last image in the iterable.wait – Choose
True
to block your program until all images are shown. ChooseFalse
to show all images in the background while your program continues.loop – Choose
True
repeat the sequence of images for ever. ChooseFalse
to show it only once.fade –
Sets the transitional behavior between images in the sequence:
The image will appear immediately.
The image will appear immediately.
The image fades out while the next image fades in.
Images will scroll to the right.
Images will scroll to the left.
Images will fade in, starting from an empty display.
Images will fade out, starting from the original image.