Welcome

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

The Scroll pHAT provides a matrix of 55 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

scrollphat.buffer_len()[source]
scrollphat.clear()[source]
scrollphat.clear_buffer()[source]
scrollphat.graph(values, low=None, high=None)[source]
scrollphat.io_errors()[source]
scrollphat.load_font(new_font)[source]
scrollphat.scroll(delta=1)[source]
scrollphat.scroll_to(pos=0)[source]
scrollphat.set_brightness(brightness)[source]
scrollphat.set_buffer(buf)[source]
scrollphat.set_col(x, value)[source]
scrollphat.set_pixel(x, y, value)[source]
scrollphat.set_pixels(handler, auto_update=False)[source]
scrollphat.set_rotate(value)[source]
scrollphat.update()[source]
scrollphat.write_string(chars, x=0)[source]

Set A Single Pixel In Buffer

Scroll pHAT uses white LEDs which can be either on or off.

When you set a pixel it will not immediately display on Scroll pHAT, you must call scrollphat.update().

scrollphat.set_pixel(x, y, value)[source]

Turn a specific pixel on or off

Parameters:
  • x – The horizontal position of the pixel
  • y – The vertical position of the pixel: 0 to 4
  • value – On/Off state: True/False

Set All Pixels In Buffer

scrollphat.set_pixels(handler, auto_update=False)[source]

Use a pixel shader function to set 11x5 pixels

Useful for displaying patterns and animations, or the result of simple functions. For example:

scrollphat.set_pixels(lambda x, y: (x + y) % 2, True)

Will display a check pattern.

Parameters:
  • handler – A function which accepts an x and y position, and returns True or False
  • auto_update – Whether to update Scroll pHAT after setting all pixels (default False)

Write A Text String

scrollphat.write_string(chars, x=0)[source]

Write a text string to the buffer

Parameters:
  • chars – Text string to write
  • x – Left offset in pixels

Display Buffer

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

scrollphat.update()[source]

Update Scroll pHAT with the current buffer

Clear Buffer

scrollphat.clear_buffer()[source]

Clear just the buffer, do not update Scroll pHAT

Clear Buffer And Display

scrollphat.clear()[source]

Clear the buffer, and then update Scroll pHAT

Set The Brightness

scrollphat.set_brightness(brightness)[source]

Set the brightness of Scroll pHAT

Parameters:brightness – Brightness value: 0 to 255

Scroll The Buffer

scrollphat.scroll(delta=1)[source]

Scroll the offset

Scroll pHAT displays an 11 column wide window into the buffer, which starts at the left offset.

Parameters:delta – Amount to scroll (default 1)

Scroll To A Position

scrollphat.scroll_to(pos=0)[source]

Set the internal offset to a specific position

Parameters:pos – Position to set

Rotate The Display

scrollphat.set_rotate(value)[source]

Set the rotation of Scroll pHAT

Parameters:value – Rotate 180 degrees: True/False

Constants

ROTATE_OFF = False

ROTATE_180 = True