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

scrollphathd.clear()
scrollphathd.clear_rect(x, y, width, height)
scrollphathd.draw_char(x, y, char, font=None, brightness=1.0, monospaced=False)
scrollphathd.fill(brightness, x=0, y=0, width=None, height=None)
scrollphathd.flip(x=False, y=False)
scrollphathd.get_buffer_shape()
scrollphathd.get_shape()
scrollphathd.rotate(degrees=0)
scrollphathd.scroll(x=1, y=0)
scrollphathd.scroll_to(x=0, y=0)
scrollphathd.set_brightness(brightness)
scrollphathd.set_clear_on_exit(value=True)
scrollphathd.set_font(font)
scrollphathd.set_gamma(gamma_table)
scrollphathd.set_graph(values, low=None, high=None, brightness=1.0, x=0, y=0, width=None, height=None)
scrollphathd.set_pixel(x, y, brightness)
scrollphathd.show(before_display=None)
scrollphathd.write_string(string, x=0, y=0, font=None, letter_spacing=1, brightness=1.0, monospaced=False, fill_background=False)

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.

Write A Text String

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

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
  • monospaced – Whether to space characters out evenly

Draw A Single Char

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

Draw a single character to the buffer.

Returns the x and y coordinates of the bottom left-most corner of the drawn character.

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
  • monospaced – Whether to space characters out evenly

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=None, height=None)

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 buffer width)
  • height – Height of the area (default is buffer height)

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 scrollphathd.show().

scrollphathd.show(before_display=None)

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=1, 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 (default 1)
  • y – Amount to scroll on y-axis (default 0)

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 (default 0)
  • y – Position to scroll to on y-axis (default 0)

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

Get The Display Size

scrollphathd.get_shape()

Get the size/shape of the display.

Returns a tuple containing the width and height of the display, after applying rotation.

Get The Buffer Size

scrollphathd.get_buffer_shape()

Get the size/shape of the internal buffer.

Returns a tuple containing the width and height of the buffer.