All Projects → embedded-graphics → Embedded Graphics

embedded-graphics / Embedded Graphics

Licence: other
A no_std graphics library for embedded applications

Programming Languages

rust
11053 projects

Labels

Projects that are alternatives of or similar to Embedded Graphics

undo
A undo-redo library.
Stars: ✭ 38 (-87.03%)
Mutual labels:  no-std
easy-ext
An attribute macro for easily writing extension trait pattern.
Stars: ✭ 17 (-94.2%)
Mutual labels:  no-std
liar
Flexible, stand-alone benchmarking
Stars: ✭ 16 (-94.54%)
Mutual labels:  no-std
betafpv-f3
Board Support Crate for the BetaFPV F3 Drone Flight Controller
Stars: ✭ 37 (-87.37%)
Mutual labels:  no-std
pipe-trait
Make it possible to chain regular functions
Stars: ✭ 22 (-92.49%)
Mutual labels:  no-std
futures-async-stream
Async stream for Rust and the futures crate.
Stars: ✭ 141 (-51.88%)
Mutual labels:  no-std
metric
This library provides zero-cost dimensional analysis for safe, unit-aware numeric computations in Rust.
Stars: ✭ 23 (-92.15%)
Mutual labels:  no-std
Cortex M Rt
Minimal startup / runtime for Cortex-M microcontrollers
Stars: ✭ 286 (-2.39%)
Mutual labels:  no-std
optimath
A #[no_std] LinAlg library
Stars: ✭ 47 (-83.96%)
Mutual labels:  no-std
drone-cortexm
ARM® Cortex®-M platform crate for Drone, an Embedded Operating System.
Stars: ✭ 31 (-89.42%)
Mutual labels:  no-std
cassette
A simple, single-future, non-blocking executor intended for building state machines. Designed to be no-std and embedded friendly.
Stars: ✭ 47 (-83.96%)
Mutual labels:  no-std
atat
no_std crate for parsing AT commands
Stars: ✭ 50 (-82.94%)
Mutual labels:  no-std
pwm-pca9685-rs
Platform-agnostic Rust driver for the PCA9685 I2C 16-channel, 12-bit PWM/Servo/LED controller
Stars: ✭ 19 (-93.52%)
Mutual labels:  no-std
cast.rs
Machine scalar casting that meets your expectations
Stars: ✭ 70 (-76.11%)
Mutual labels:  no-std
littlefs2
Idiomatic Rust API for littlefs
Stars: ✭ 19 (-93.52%)
Mutual labels:  no-std
restricted-sparse-merkle-tree
An optimized sparse merkle tree.
Stars: ✭ 47 (-83.96%)
Mutual labels:  no-std
async-stm32f1xx
Abstractions for asynchronous programming on the STM32F1xx family of microcontrollers.
Stars: ✭ 24 (-91.81%)
Mutual labels:  no-std
Rubble
(going to be a) BLE stack for embedded Rust
Stars: ✭ 292 (-0.34%)
Mutual labels:  no-std
Drone Core
The core crate for Drone, an Embedded Operating System.
Stars: ✭ 263 (-10.24%)
Mutual labels:  no-std
gdbstub
An ergonomic and easy-to-integrate implementation of the GDB Remote Serial Protocol in Rust, with full no_std support.
Stars: ✭ 158 (-46.08%)
Mutual labels:  no-std

Embedded graphics logo

Build Status Crates.io Docs.rs embedded-graphics on Matrix

Embedded graphics

Embedded-graphics is a 2D graphics library that is focused on memory constrained embedded devices.

A core goal of embedded-graphics is to draw graphics without using any buffers; the crate is no_std compatible and works without a dynamic memory allocator, and without pre-allocating large chunks of memory. To achieve this, it takes an Iterator based approach, where pixel colors and positions are calculated on the fly, with the minimum of saved state. This allows the consuming application to use far less RAM at little to no performance penalty.

It contains built in items that make it easy to draw 2D graphics primitives:

  • Raw data images
  • Primitives
    • Lines
    • Rectangles (and squares)
    • Circles
    • Ellipses
    • Arcs
    • Sectors
    • Triangles
    • Polylines
    • Rounded rectangles
  • Text
  • Monospaced fonts

Additional functions provided by external crates

Embedded-graphics is designed to be extended by the application or other crates. Examples of this are adding support for different image formats or implementing custom fonts.

Note that some of these crates may not support the latest version of embedded-graphics.

If you know of a crate that is not in this list, please open an issue to add it.

Display drivers

To support many different kinds of display, embedded-graphics doesn't include any drivers directly but provides the DrawTarget API in embedded-graphics-core that can be implemented by external crates. In addition to the drivers for real displays, the simulator can be used to test code during development.

Embedded graphics on real hardware

These are just some of the displays the community has added embedded-graphics support to. This list is taken from the dependent crates list on crates.io so might be missing some unpublished entries. Please open an issue if there's a display driver that should be added to this list.

Note that some drivers may not support the latest version of embedded-graphics.

  • embedded-graphics-web-simulator: Simulated display in your browser via Webassembly
  • epd-waveshare Driver for various ePaper displays (EPD) from Waveshare
  • hub75: A rust driver for hub75 rgb matrix displays
  • ili9341: A platform agnostic driver to interface with the ILI9341 (and ILI9340C) TFT LCD display
  • ls010b7dh01: A platform agnostic driver for the LS010B7DH01 memory LCD display
  • push2_display: Ableton Push2 embedded-graphics display driver
  • sh1106: I2C driver for the SH1106 OLED display
  • ssd1306: I2C and SPI (4 wire) driver for the SSD1306 OLED display
  • ssd1309: I2C/SPI driver for the SSD1309 OLED display written in 100% Rust.
  • ssd1322: Pure Rust driver for the SSD1322 OLED display chip
  • ssd1331: SPI (4 wire) driver for the SSD1331 OLED display
  • ssd1351: SSD1351 driver
  • ssd1675: Rust driver for the Solomon Systech SSD1675 e-Paper display (EPD) controller
  • st7735-lcd: Rust library for displays using the ST7735 driver
  • st7789: A Rust driver library for ST7789 displays
  • st7920: ST7920 LCD driver in Rust

Simulator

Embedded graphics comes with a simulator! The simulator can be used to test and debug embedded graphics code, or produce examples and interactive demos to show of embedded graphics features.

It can display all sorts of embedded-graphics test code.

Take a look at the simulator examples to see what embedded-graphics can do, and how it might look on a display. You can run the examples like this:

git clone https://github.com/embedded-graphics/embedded-graphics.git
cd embedded-graphics

cargo run -p embedded-graphics-simulator --example hello

Crate features

Additional features can be enabled by adding the following features to your Cargo.toml.

  • nalgebra_support - use the Nalgebra crate with no_std support to enable conversions from nalgebra::Vector2 to Point and Size.

  • fixed_point - use fixed point arithmetic instead of floating point for all trigonometric calculation.

Migrating from 0.5 to 0.6

Please read the migration guide.

Implementing embedded_graphics support for a display driver

To add support for embedded-graphics to a display driver, DrawTarget from embedded-graphics-core must be implemented. This allows all embedded-graphics items to be rendered by the display. See the DrawTarget documentation for implementation details.

Examples

Drawing examples

Collage of drawing examples

Example usage of drawing primitives, text and images with embedded-graphics can be found here.

Shapes and text

The following example draws some shapes and text to a MockDisplay in place of target hardware. The simulator can also be used for debugging, development or if hardware is not available.

use embedded_graphics::{
    mono_font::{ascii::Font6x9, MonoTextStyle},
    pixelcolor::BinaryColor,
    prelude::*,
    primitives::{Circle, Rectangle, Triangle, PrimitiveStyle},
    text::Text,
    mock_display::MockDisplay,
};

fn main() -> Result<(), std::convert::Infallible> {
    // Create a new mock display
    let mut display: MockDisplay<BinaryColor> = MockDisplay::new();
    # display.set_allow_overdraw(true);

    // Create styles used by the drawing operations.
    let thin_stroke = PrimitiveStyle::with_stroke(BinaryColor::On, 1);
    let thick_stroke = PrimitiveStyle::with_stroke(BinaryColor::On, 3);
    let fill = PrimitiveStyle::with_fill(BinaryColor::On);
    let text_style = MonoTextStyle::new(Font6x9, BinaryColor::On);

    let yoffset = 10;

    // Draw a 3px wide outline around the display.
    let display_size = display.size() - Size::new(1, 1);
    Rectangle::new(Point::zero(), display_size)
        .into_styled(thick_stroke)
        .draw(&mut display)?;

    // Draw a triangle.
    Triangle::new(
        Point::new(16, 16 + yoffset),
        Point::new(16 + 16, 16 + yoffset),
        Point::new(16 + 8, yoffset),
    )
    .into_styled(thin_stroke)
    .draw(&mut display)?;

    // Draw a filled square
    Rectangle::new(Point::new(52, yoffset), Size::new(16, 16))
        .into_styled(fill)
        .draw(&mut display)?;

    // Draw a circle with a 3px wide stroke.
    Circle::new(Point::new(88, yoffset), 17)
        .into_styled(thick_stroke)
        .draw(&mut display)?;

    // Draw centered text.
    let text = "embedded-graphics";
    let width = text.len() as i32 * 6;
    Text::new(text, Point::new(64 - width / 2, 40))
        .into_styled(text_style)
        .draw(&mut display)?;

    Ok(())
}

This example is also included in the simulator crate and can be run using cargo run --example hello-world. It produces this output:

Embedded Graphics Simulator example screenshot

Additional examples can be found in the simulator crate.

Minimum supported Rust version

The minimum supported Rust version for embedded-graphics is 1.40.0 or greater. Ensure you have the correct version of Rust installed, preferably through https://rustup.rs.

Development setup

Please see the development setup guide.

Attribution

All source font PNGs are taken from the excellent Uzebox Wiki page.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].