Frame buffer manipulation
Quick example:
import framebuf
fbuf = framebuf.FrameBuffer(bytearray(10*100*2), 10, 100, framebuf.RGB565)
fbuf.fill(0)
fbuf.text('Pycom!', 10,10, 0xffff)
fbuf.hline(0, 20, 96, 0xffff)
Constructs a FrameBuffer object with parameters
framebuffer
: A bytearray object large enough to contain every pixelwidth
: The width of the FrameBuffer in pixelsheight
: The height of the FrameBuffer in pixelsformat
: The type of pixel used in the Framebuffer and can be one of the following constants:
framebuf.GS2_HMSB
: 2-bt grayscaleframebuf.GS4_HMSB
: 4-bit grayscaleframebuf.GS8
: 8-bit grayscaleframebuf.MONO_HLSB
: monochrome, horizontally mapped, LSBframebuf.MONO_HMSB
: monochrome, horizontally mapped, MSBframebuf.MONO_VLSB
: monochrhome, vertically mapped, LSBframebuf.MVLSB
: Same as MONO_VLSB
framebuf.RGB565
: 16-bit RGB color (5 bits red, 6 bits blue, 5 buts green)stride
: The number of pixels between each horizontal line of pixels in the FrameBuffer.The coordinates in the following methods are defined with (0, 0)
in the upper left-hand corner, with x
on the horizontal axis, and y
on the vertical axis.
The color arguments is a small int that depends the format
color order.
Provides compatibility with the legacy FrameBuffer class.
Fills the entire FrameBuffer with the specified color
Gets or sets the color at the specified pixel.
Draws a 1-pixel wide horizontal line starting at x, y
with width w
and color c
Draws a 1-pixel wide vertical line starting at x, y
with height h
and color c
Draws a 1-pixel wide line starting at x1, y1
to x2, y2
with color c
Draws a 1-pixel rectangle outline with starting corner x, y
, width w
, height h
and color c
Draws a colored rectangle with starting corner x, y
, width w
, height h
and color c
Write text to the FrameBuffer with characters of 8 by 8 pixels, with x, y
in the top left hand corner and c
as the color.
At the moment, it is not possible to change either the font, or its size.
Shifts the contents of the FrameBuffer by the given step size in x and y. The pixels will not roll around to the other side.
Draw another FrameBuffer on top of the current one at the given coordinates. If a key
is specified, the passed FrameBuffer will be considered transparent for that color. All pixels of that color will not be drawn.
## Constants
format: GS2_HMSB
, GS4_HMSB
, GS8
, MONO_HLSB
, MONO_HMSB
, MONO_VLSB
, MVLSB
, RGB565