Welcome

This documentation will guide you through the methods available in the Scroll pHAT HD python library.

Scroll pHAT provides a matrix of 119 individually brightness controlled white LED 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

Matrix.clear()[source]
Matrix.clear_rect(x, y, width, height)[source]
Matrix.draw_char(x, y, char, font=None, brightness=1.0)[source]
Matrix.fill(brightness, x=0, y=0, width=0, height=0)[source]
Matrix.flip(x=False, y=False)[source]
Matrix.rotate(degrees=0)[source]
Matrix.scroll(x=0, y=0)[source]
Matrix.scroll_to(x=0, y=0)[source]
Matrix.set_graph(values, low=None, high=None, brightness=1.0, x=0, y=0, width=None, height=None)[source]
Matrix.set_pixel(x, y, brightness)[source]
Matrix.show()[source]
Matrix.write_string(string, x=0, y=0, font=None, letter_spacing=1, brightness=1.0)[source]

Set A Single Pixel In Buffer

Scroll pHAT HD uses white LEDs which can be brightness controlled.

When you set a pixel it will not immediately display on Scroll pHAT HD, you must call scrollphathd.show().

scrollphathd.set_pixel(x, y, brightness)

Set a single pixel in the buffer.

Parameters:
  • x – Position of pixel from left of buffer
  • y – Position of pixel from top of buffer
  • brightness – Intensity of the pixel, from 0.0 to 1.0 or 0 to 255.

Write A Text String

scrollphathd.write_string(string, x=0, y=0, font=None, letter_spacing=1, brightness=1.0)

Write a string to the buffer. Calls draw_char for each character.

Parameters:
  • string – The string to display
  • x – Offset x - distance of the string from the left of the buffer
  • y – Offset y - distance of the string from the top of the buffer
  • font – Font to use, default is to use the one specified with set_font
  • brightness – Brightness of the pixels that compromise the text, from 0.0 to 1.0

Draw A Single Char

scrollphathd.draw_char(x, y, char, font=None, brightness=1.0)

Draw a single character to the buffer.

Parameters:
  • o_x – Offset x - distance of the char from the left of the buffer
  • o_y – Offset y - distance of the char from the top of the buffer
  • char – Char to display- either an integer ordinal or a single letter
  • font – Font to use, default is to use one specified with set_font
  • brightness – Brightness of the pixels that compromise the char, from 0.0 to 1.0

Display A Graph

scrollphathd.set_graph(values, low=None, high=None, brightness=1.0, x=0, y=0, width=None, height=None)

Plot a series of values into the display buffer.

Parameters:
  • values – A list of numerical values to display
  • low – The lowest possible value (default min(values))
  • high – The highest possible value (default max(values))
  • brightness – Maximum graph brightness (from 0.0 to 1.0)
  • x – x position of graph in display buffer (default 0)
  • y – y position of graph in display buffer (default 0)
  • width – width of graph in display buffer (default 17)
  • height – height of graph in display buffer (default 7)
Returns:

None

Fill An Area

scrollphathd.fill(brightness, x=0, y=0, width=0, height=0)

Fill an area of the display.

Parameters:
  • brightness – Brightness of pixels
  • x – Offset x - distance of the area from the left of the buffer
  • y – Offset y - distance of the area from the top of the buffer
  • width – Width of the area (default is 17)
  • height – Height of the area (default is 7)

Clear An Area

scrollphathd.clear_rect(x, y, width, height)

Clear a rectangle.

Parameters:
  • x – Offset x - distance of the area from the left of the buffer
  • y – Offset y - distance of the area from the top of the buffer
  • width – Width of the area (default is 17)
  • height – Height of the area (default is 7)

Display Buffer

All of your changes to Scroll pHAT HD are stored in a Python buffer. To display them on Scroll pHAT HD you must call scrollphthd.update().

scrollphathd.show()

Show the buffer contents on the display.

The buffer is copied, then scrolling, rotation and flip y/x transforms applied before taking a 17x7 slice and displaying.

Clear Buffer

scrollphathd.clear()

Clear the buffer

You must call show after clearing the buffer to update the display.

Scroll The Buffer

scrollphathd.scroll(x=0, y=0)

Offset the buffer by x/y pixels

Scroll pHAT HD displays an 17x7 pixel window into the bufer, which starts at the left offset and wraps around.

The x and y values are added to the internal scroll offset.

If called with no arguments, a horizontal right to left scroll is used.

Parameters:
  • x – Amount to scroll on x-axis
  • y – Amount to scroll on y-axis

Scroll To A Position

scrollphathd.scroll_to(x=0, y=0)

Scroll the buffer to a specific location.

Scroll pHAT HD displays a 17x7 pixel window into the buffer, which starts at the left offset and wraps around.

The x and y values set the internal scroll offset.

If called with no arguments, the scroll offset is reset to 0,0

Parameters:
  • x – Position to scroll to on x-axis
  • y – Position to scroll to on y-axis

Rotate The Display

scrollphathd.rotate(degrees=0)

Rotate the buffer 0, 90, 180 or 270 degrees before dislaying.

Parameters:degrees – Amount to rotate- will snap to the nearest 90 degrees

Flip The Display

scrollphathd.flip(x=False, y=False)

Flip the buffer horizontally and/or vertically before displaying.

Parameters:
  • x – Flip horizontally left to right
  • y – Flip vertically up to down