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.

Parameters

face – Choose hub.FRONT, hub.BACK, hub.LEFT, or hub.RIGHT.

Returns

The new or current alignment.

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 brightness 9 - b.

Parameters

invert – Choose True to activate the inverted state. Choose False 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, or 1 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) and 9 (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) and 9 (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. Choose False to show all images in the background while your program continues.

  • loop – Choose True repeat the sequence of images for ever. Choose False to show it only once.

  • fade

    Sets the transitional behavior between images in the sequence:

    1. The image will appear immediately.

    2. The image will appear immediately.

    3. The image fades out while the next image fades in.

    4. Images will scroll to the right.

    5. Images will scroll to the left.

    6. Images will fade in, starting from an empty display.

    7. Images will fade out, starting from the original image.