All display features can be accessed through the rgb module.
Reference
Function | Parameters | Description |
---|---|---|
clear | - | Clears the screen contents, and shows the background colour if set. |
background | colors | Sets the background to a colour in the form of a tuple (r, g, b). |
getbrightness | - | Gets the current display brightness (0-32). |
setbrightness | brightness | Sets the current display brightness (0-32). |
framerate | framerate | Sets the framerate for scrolling text and animations. |
pixel | [color], [pos] | Sets a single pixel at pos (x, y) to colour (r, g, b). |
text | text, [color], [pos] | Shows text at pos (x, y) with colour (r, g, b). |
scrolltext | text, [color], [pos], [width] | Shows scrolling text at pos (x, y) with colour (r, g, b), within a window of specified width. |
image | data, [pos], size | Shows an image (list of pixel values 0xRRGGBBAA) of size (width, height) at pos (x, y). |
gif | data, [pos], size, frames | Shows an animated image (list of pixel values 0xRRGGBBAA, not actual .gif format) containing a given number of frames of size (width, height) at pos (x, y). |
setfont | font | Changes the currently rendering font (rgb.FONT_7x5 or rgb.FONT6x3). |
textwidth | text | Gets the width in pixels of the given text, if rendered with the current font. |
Advanced: | ||
disablecomp | Disables the compositor, which freezes rendering text/images/etc to the framebuffer. | |
enablecomp | Enables the compositor again. | |
frame | frame | Writes frame data in a list with the format 0x00rrggbb directly to the display framebuffer. |
Examples
Show a smiley face
import rgb
data = [0xffbf00ff, 0xffbf00ff, 0xffbf00ff, 0xffbf00ff, 0xffbf00ff, 0xffbf00ff, 0xffbf00ff, 0xffbf00ff, 0xffbf00ff, 0xffbf00ff, 0xffbf00ff, 0xffbf00ff, 0xffbf00ff, 0xffbf00ff, 0xffbf00ff, 0xffbf00ff, 0xffbf00ff, 0xffbf00ff, 0x000000ff, 0xffbf00ff, 0xffbf00ff, 0x000000ff, 0xffbf00ff, 0xffbf00ff, 0xffbf00ff, 0xffbf00ff, 0x000000ff, 0xffbf00ff, 0xffbf00ff, 0x000000ff, 0xffbf00ff, 0xffbf00ff, 0xffbf00ff, 0xffbf00ff, 0xffbf00ff, 0xffbf00ff, 0xffbf00ff, 0xffbf00ff, 0xffbf00ff, 0xffbf00ff, 0xffbf00ff, 0xffbf00ff, 0x000000ff, 0xffbf00ff, 0xffbf00ff, 0x000000ff, 0xffbf00ff, 0xffbf00ff, 0xffbf00ff, 0xffbf00ff, 0xffbf00ff, 0x000000ff, 0x000000ff, 0xffbf00ff, 0xffbf00ff, 0xffbf00ff, 0xffbf00ff, 0xffbf00ff, 0xffbf00ff, 0xffbf00ff, 0xffbf00ff, 0xffbf00ff, 0xffbf00ff, 0xffbf00ff]
rgb.clear()
rgb.image(data, pos=(12, 0), size=(8, 8))
Show an animated image
import rgb
data = [0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x808080ff, 0x808080ff, 0x808080ff, 0x808080ff, 0x808080ff, 0x808080ff, 0x000000ff, 0x808080ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x808080ff, 0x000000ff, 0x000000ff, 0x808080ff, 0x808080ff, 0x808080ff, 0x808080ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x808080ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x808080ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x808080ff, 0x808080ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x808080ff, 0x000000ff, 0x000000ff, 0x808080ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff,
0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x808080ff, 0x808080ff, 0x808080ff, 0x808080ff, 0x808080ff, 0x808080ff, 0x000000ff, 0x808080ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x808080ff, 0x000000ff, 0x000000ff, 0x808080ff, 0x808080ff, 0x808080ff, 0x808080ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x808080ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x808080ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0xffffffff, 0xffffffff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0xffffffff, 0x000000ff, 0x000000ff, 0xffffffff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff,
0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x808080ff, 0x808080ff, 0x808080ff, 0x808080ff, 0x808080ff, 0x808080ff, 0x000000ff, 0x808080ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x808080ff, 0x000000ff, 0x000000ff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0x000000ff, 0x000000ff, 0x000000ff, 0xffffffff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0xffffffff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0xffffffff, 0xffffffff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0xffffffff, 0x000000ff, 0x000000ff, 0xffffffff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff,
0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0x000000ff, 0xffffffff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0xffffffff, 0x000000ff, 0x000000ff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0x000000ff, 0x000000ff, 0x000000ff, 0xffffffff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0xffffffff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0xffffffff, 0xffffffff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0xffffffff, 0x000000ff, 0x000000ff, 0xffffffff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff, 0x000000ff]
rgb.clear()
rgb.framerate(2) # This makes the animation run at 2 frames per second
rgb.gif(data, pos=(12, 0), size=(8, 8), frames=4)