Welcome

This documentation will guide you through the methods available in the Unicorn HAT HD python library.

Unicorn HAT HD provides a matrix of 256 RGB pixels that is ideal for writing messages, showing graphs, and drawing pictures. Use it to output your IP address, show CPU usage, or just play pong!

At A Glance

unicornhathd.brightness(b)[source]
unicornhathd.clear()[source]
unicornhathd.get_rotation()[source]
unicornhathd.get_shape()[source]
unicornhathd.off()[source]
unicornhathd.rotation(r)[source]
unicornhathd.set_layout(pixel_map=None)[source]
unicornhathd.set_pixel(x, y, r, g, b)[source]
unicornhathd.set_pixel_hsv(x, y, h, s=1.0, v=1.0)[source]
unicornhathd.show()[source]

Set A Pixel

unicornhathd.set_pixel(x, y, r, g, b)[source]

Set a single pixel to RGB colour.

Parameters:
  • x – Horizontal position from 0 to 7
  • y – Veritcal position from 0 to 7
  • r – Amount of red from 0 to 255
  • g – Amount of green from 0 to 255
  • b – Amount of blue from 0 to 255
unicornhathd.set_pixel_hsv(x, y, h, s=1.0, v=1.0)[source]

set a single pixel to a colour using HSV.

Parameters:
  • x – Horizontal position from 0 to 7
  • y – Veritcal position from 0 to 7
  • h – Hue from 0.0 to 1.0 ( IE: degrees around hue wheel/360.0 )
  • s – Saturation from 0.0 to 1.0
  • v – Value (also known as brightness) from 0.0 to 1.0

Set Brightness

unicornhathd.brightness(b)[source]

Set the display brightness between 0.0 and 1.0.

Parameters:b – Brightness from 0.0 to 1.0 (default 0.2)

Set Rotation

unicornhathd.rotation(r)[source]

Set the display rotation in degrees.

Actual rotation will be snapped to the nearest 90 degrees.

unicornhathd.get_rotation()[source]

Returns the display rotation in degrees.

Show The Buffer

unicornhathd.show()[source]

Output the contents of the buffer to Unicorn HAT HD.

Clear The Buffer

unicornhathd.clear()[source]

Clear the buffer.

Clear The Display

unicornhathd.off()[source]

Clear the buffer and immediately update Unicorn HAT HD.

Turns off all pixels.

Porting From Unicorn HAT

The Unicorn HAT HD library has been structured to make it easier to port your code from Unicorn HAT.

A couple of methods exist solely for this purpose; get_shape and set_layout:

unicornhathd.get_shape()[source]

Return the shape (width, height) of the display.

unicornhathd.set_layout(pixel_map=None)[source]

Does nothing, for library compatibility with Unicorn HAT.