adafruit_framebuf

CircuitPython pure-python framebuf module, based on the micropython framebuf module.

Implementation Notes

Hardware:

Software and Dependencies:

class adafruit_framebuf.BitmapFont(font_name='font5x8.bin')

A helper class to read binary font tiles and ‘seek’ through them as a file to display in a framebuffer. We use file access so we dont waste 1KB of RAM on a font!

deinit()

Close the font file as cleanup.

draw_char(char, x, y, framebuffer, color, size=1)

Draw one character at position (x,y) to a framebuffer in a given color

width(text)

Return the pixel width of the specified text message.

class adafruit_framebuf.FrameBuffer(buf, width, height, buf_format=0, stride=None)

FrameBuffer object.

Parameters:
  • buf – An object with a buffer protocol which must be large enough to contain every pixel defined by the width, height and format of the FrameBuffer.
  • width – The width of the FrameBuffer in pixel
  • height – The height of the FrameBuffer in pixel
  • buf_format – Specifies the type of pixel used in the FrameBuffer; permissible values are listed under Constants below. These set the number of bits used to encode a color value and the layout of these bits in buf. Where a color value c is passed to a method, c is a small integer with an encoding that is dependent on the format of the FrameBuffer.
  • stride – The number of pixels between each horizontal line of pixels in the FrameBuffer. This defaults to width but may need adjustments when implementing a FrameBuffer within another larger FrameBuffer or screen. The buf size must accommodate an increased step size.
blit()

blit is not yet implemented

circle(center_x, center_y, radius, color)

Draw a circle at the given midpoint location, radius and color. The `circle` method draws only a 1 pixel outline.

fill(color)

Fill the entire FrameBuffer with the specified color.

fill_rect(x, y, width, height, color)

Draw a rectangle at the given location, size and color. The fill_rect method draws both the outline and interior.

hline(x, y, width, color)

Draw a horizontal line up to a given length.

image(img)

Set buffer to value of Python Imaging Library image. The image should be in 1 bit mode and a size equal to the display size.

line(x_0, y_0, x_1, y_1, color)

Bresenham’s line algorithm

pixel(x, y, color=None)

If color is not given, get the color value of the specified pixel. If color is given, set the specified pixel to the given color.

rect(x, y, width, height, color, *, fill=False)

Draw a rectangle at the given location, size and color. The `rect` method draws only a 1 pixel outline.

rotation

The rotation setting of the display, can be one of (0, 1, 2, 3)

scroll(delta_x, delta_y)

shifts framebuf in x and y direction

text(string, x, y, color, *, font_name='font5x8.bin', size=1)

Place text on the screen in variables sizes. Breaks on to next line.

Does not break on line going off screen.
vline(x, y, height, color)

Draw a vertical line up to a given length.

class adafruit_framebuf.FrameBuffer1(buf, width, height, buf_format=0, stride=None)

FrameBuffer1 object. Inherits from FrameBuffer.

class adafruit_framebuf.MHMSBFormat
static fill(framebuf, color)

completely fill/clear the buffer with a color

static fill_rect(framebuf, x, y, width, height, color)

Draw a rectangle at the given location, size and color. The fill_rect method draws both the outline and interior.

static get_pixel(framebuf, x, y)

Get the color of a given pixel

static set_pixel(framebuf, x, y, color)

Set a given pixel to a color.

class adafruit_framebuf.MVLSBFormat
static fill(framebuf, color)

completely fill/clear the buffer with a color

static fill_rect(framebuf, x, y, width, height, color)

Draw a rectangle at the given location, size and color. The fill_rect method draws both the outline and interior.

static get_pixel(framebuf, x, y)

Get the color of a given pixel

static set_pixel(framebuf, x, y, color)

Set a given pixel to a color.

class adafruit_framebuf.RGB888Format
static fill(framebuf, color)

completely fill/clear the buffer with a color

static fill_rect(framebuf, x, y, width, height, color)

Draw a rectangle at the given location, size and color. The fill_rect method draws both the outline and interior.

static get_pixel(framebuf, x, y)

Get the color of a given pixel

static set_pixel(framebuf, x, y, color)

Set a given pixel to a color.