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!
- More information - https://shop.pimoroni.com/products/scroll-phat
- Get the code - https://github.com/pimoroni/scroll-phat
- GPIO pinout - https://pinout.xyz/pinout/scroll_phat
- Soldering - https://learn.pimoroni.com/tutorial/sandyj/soldering-phats
- Get help - http://forums.pimoroni.com/c/support
At A Glance¶
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
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