pub struct FrameBuf<C: PixelColor, B: FrameBufferBackend<Color = C>> {
    pub data: B,
    /* private fields */
}
Expand description

Constructs a frame buffer in memory. Lets you define the width(X), height (Y) and pixel type your using in your display (RGB, Monochrome etc.)

Example

use embedded_graphics::{
    mono_font::{ascii::FONT_10X20, MonoTextStyle},
    pixelcolor::Rgb565,
    prelude::*,
    text::Text,
};
use embedded_graphics_framebuf::FrameBuf;

// Create a framebuffer for a 16-Bit 240x135px display
let mut data = [Rgb565::BLACK; 240 * 135];
let mut fbuff = FrameBuf::new(&mut data, 240, 135);

// write "Good luck" into the framebuffer.
Text::new(
    &"Good luck!",
    Point::new(10, 13),
    MonoTextStyle::new(&FONT_10X20, Rgb565::WHITE.into()),
)
.draw(&mut fbuff)
.unwrap();

Fields

data: B

Implementations

Create a new FrameBuf on top of an existing memory slice.

Panic

Panics if the size of the memory does not match the given width and height.

Example
use embedded_graphics::{pixelcolor::Rgb565, prelude::RgbColor};
use embedded_graphics_framebuf::FrameBuf;
let mut data = [Rgb565::BLACK; 240 * 135];
let mut fbuff = FrameBuf::new(&mut data, 240, 135);

Get the framebuffers width.

Get the framebuffers height.

Set a pixel’s color.

Get a pixel’s color.

Trait Implementations

The pixel color type the targetted display supports.

Error type to return when a drawing operation fails. Read more

Draw individual pixels to the display without a defined order. Read more

Fill the entire display with a solid color. Read more

Fill a given area with an iterator providing a contiguous stream of pixel colors. Read more

Fill a given area with a solid color. Read more

Creates an iterator over all Pixels in the frame buffer. Can be used for rendering the framebuffer to the physical display.

Example
use embedded_graphics::{
    draw_target::DrawTarget,
    mock_display::MockDisplay,
    pixelcolor::BinaryColor,
    prelude::{Point, Primitive},
    primitives::{Line, PrimitiveStyle},
    Drawable,
};
use embedded_graphics_framebuf::FrameBuf;
let mut data = [BinaryColor::Off; 12 * 11];
let mut fbuf = FrameBuf::new(&mut data, 12, 11);
let mut display: MockDisplay<BinaryColor> = MockDisplay::new();
Line::new(Point::new(2, 2), Point::new(10, 2))
    .into_styled(PrimitiveStyle::with_stroke(BinaryColor::On, 2))
    .draw(&mut fbuf)
    .unwrap();
display.draw_iter(fbuf.into_iter()).unwrap();

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Returns the size of the bounding box.

Provide a buffer usable for DMA reads. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Casts the value.

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Casts the value.

Casts the value.

Casts the value.

Returns the bounding box.

Creates a translated draw target based on this draw target. Read more

Creates a cropped draw target based on this draw target. Read more

Creates a clipped draw target based on this draw target. Read more

Creates a color conversion draw target. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Casts the value.

Casts the value.

Casts the value.

Casts the value.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Casts the value.

Casts the value.

Casts the value.

Casts the value.