embedded-graphics-framebuf 0.1.0

Frame buffer helper for embedded-graphics
Documentation

Contributors Forks Stargazers Issues Build Status MIT License LinkedIn

About The Project

This library is a Rust implementation of framebuffer approach that is often used when driving hardware displays. The goal is to perform bulk-write of all the screen pixels at once, avoiding multiple individual updates that could lead to screen flickering.

This library has been designed to work with Rust's embedded-graphics library.

Built With

Getting Started

Make sure you have your rust environment configurated

Installation

  1. Add library to your Cargo.toml

    ...
    [dependencies]
    embedded-graphics-framebuf = "0.1.0"
    
  2. Use the library in you code

    use embedded_graphics_framebuf::FrameBuf;
    ...
    
    let mut display = st7789::ST7789::new(
        di,
        rst.into_output()?,
        // SP7789V is designed to drive 240x320 screens, even though the TTGO physical screen is smaller
        320,
        240,
    );
    
    static mut FBUFF: FrameBuf<Rgb565, 240_usize, 135_usize> = FrameBuf([[Rgb565::BLACK; 240]; 135]);
    let fbuff = unsafe { &mut FBUFF };
    
    fbuff.clear_black();
    Text::new(
        &"Good luck!",
        Point::new(10, 13),
        MonoTextStyle::new(&FONT_10X20, Rgb565::WHITE.into()),
    )
    .draw(fbuff).unwrap();
    
    // write to the actual display :-)
    let u16_iter = fbuff
        .into_iter()
        .map(|px| px.into_storage());
    
    // those are the offsets for my physical ST7789 display
    display.set_pixels(40, 53, 240 - 1 + 40, 53 + 135, u16_iter);
    
  3. Your flickering problems should be solved at this point :)

Roadmap

  • add tests
  • add rustdocs
  • CI integration with GithHub Actions
  • better error generation & handling

See the open issues for a full list of proposed features (and known issues).

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Bernard Kobos - @bkobos - bkobos@gmail.com

Project Link: https://github.com/bernii/embedded-graphics-framebuf

Acknowledgments