Crate embedded_graphics_framebuf

Source
Expand description

§Embedded Graphics FrameBuffer

embedded-graphics-framebuf is a generalized frame buffer implementation for use with Rust’s embedded-graphics library.

The framebuffer approach helps to deal with display flickering when you update multiple parts of the display in separate operations. Instead, with this approach, you’re going to write to a in-memory display and push it all at once into your hardware display when the whole picture is drawn.

This technique is useful when you’re updating large portions of screen or just simply don’t want to deal with partial display updates. The downside is a higher RAM consumption for to the framebuffer.

The approach has been tested on TTGO (esp32) with ST7789

§Usage example

use embedded_graphics::{
    draw_target::DrawTarget,
    mock_display::MockDisplay,
    pixelcolor::BinaryColor,
    prelude::{Point, Primitive},
    primitives::{Line, PrimitiveStyle, Rectangle},
    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();
let area = Rectangle::new(Point::new(0, 0), fbuf.size());
display.fill_contiguous(&area, data).unwrap();

Modules§

backends
Backends for a framebuffer.

Structs§

FrameBuf
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.)
PixelIterator
An iterator for all Pixels in the framebuffer.