__init__ (version 0.0.5)
|
index /media/pi/PI4_TT/unicornhathd2/__init__.py
|
Unicorn HAT HD library 2.
Drive the 16x16 RGB pixel Pimoroni Unicorn HAT HD
over SPI from a Raspberry Pi or compatible platform.
Using the two chip selectors
Modules
|
|
|
colorsys
|
numpy
|
spidev
|
time
|
|
Classes
|
|
|
class Display
|
|
Represents a single display in a multi-display chain. Contains the coordinates for the slice of the pixel buffer which should be visible on this particular display.
|
|
Methods defined here:
- __init__(self, enabled, x, y, rotation)
- Initialise display.
:param enabled: True/False to indicate if this display is enabled :param x: x offset of display portion in buffer :param y: y offset of display portion in buffer :param rotation: rotation of display
- get_buffer_window(self, source)
- Grab the correct portion of the supplied buffer for this display.
:param source: source buffer, should be a numpy array
- update(self, x, y, rotation)
- Update display position.
:param x: x offset of display portion in buffer :param y: y offset of display portion in buffer :param rotation: rotation of display
|
|
Functions
|
|
|
- brightness(b)
- Set the display brightness between 0.0 and 1.0.
:param b: Brightness from 0.0 to 1.0 (default 0.5)
- clear()
- Clear the buffer.
- enable_addressing(enabled=True)
- Enable multi-panel addressing support (for Ubercorn).
- enable_display(address, enabled=True)
- Enable a single display in the chain.
:param address: address of the display from 0 to 7 :param enabled: True/False to indicate display is enabled
- get_pixel(x, y)
- Get pixel colour in RGB as a tuple.
:param x: Horizontal position from 0 to 15 :param y: Veritcal position from 0 to 15
- get_pixels()
- Return entire buffer.
- get_rotation()
- Return the display rotation in degrees.
- get_shape()
- Return the shape (width, height) of the display.
- off()
- Clear the buffer and immediately update Unicorn HAT HD.
Turns off all pixels.
- rotation(r)
- Set the display rotation in degrees.
Actual rotation will be snapped to the nearest 90 degrees.
- set_all(r, g, b)
- Set all pixels to RGB colour.
:param r: Amount of red from 0 to 255 :param g: Amount of green from 0 to 255 :param b: Amount of blue from 0 to 255
- set_pixel(x, y, r, g, b)
- Set a single pixel to RGB colour.
:param x: Horizontal position from 0 to 15 :param y: Veritcal position from 0 to 15 :param r: Amount of red from 0 to 255 :param g: Amount of green from 0 to 255 :param b: Amount of blue from 0 to 255
- set_pixel_hsv(x, y, h, s=1.0, v=1.0)
- Set a single pixel to a colour using HSV.
:param x: Horizontal position from 0 to 15 :param y: Veritcal position from 0 to 15 :param h: Hue from 0.0 to 1.0 ( IE: degrees around hue wheel/360.0 ) :param s: Saturation from 0.0 to 1.0 :param v: Value (also known as brightness) from 0.0 to 1.0
- setup(address=0)
- Initialize Unicorn HAT HD.
- setup_buffer(width, height)
- Set up the internal pixel buffer.
:param width: width of buffer, ideally in multiples of 16 :param height: height of buffer, ideally in multiples of 16
- setup_display(address, x, y, rotation)
- Configure a single display in the chain.
:param x: x offset of display portion in buffer :param y: y offset of display portion in buffer :param rotation: rotation of display
- shade_pixels(shader)
- Set all pixels to a colour determined by a shader function.
:param shader: function that accepts x/y position and returns an r,g,b tuple.
- show()
- Output the contents of the buffer to Unicorn HAT HD.
|
Data
|
|
|
HEIGHT = 16 PANEL_SHAPE = (16, 16) WIDTH = 16 __version__ = '0.0.5' is_setup = False
|