Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
M

mousefood

> 编程语言
Open source

embedded-graphics backend for Ratatui

1.3K stars0 likes2 views
WebsiteGitHub

About

embedded-graphics backend for Ratatui

Mousefood - a no-std embedded-graphics backend for Ratatui!

Quickstart

Add mousefood as a dependency:

bash
cargo add mousefood

Exemplary setup:

…

Special characters

Embedded-graphics includes bitmap fonts that have a very limited set of characters to save space (ASCII, ISO 8859 or JIS X0201). This makes it impossible to draw most of Ratatui's widgets, which heavily use box-drawing glyphs, Braille, and other special characters.

Mousefood by default uses embedded-graphics-unicodefonts, which provides embedded-graphics fonts with a much larger set of characters.

Alternatives

In order to save space and speed up rendering, the fonts feature can be disabled by turning off the default crate features. ibm437 is a good alternative that includes some drawing characters, but is not as large as embedded-graphics-unicodefonts.

Bold and italic fonts

Bold and italic modifiers are supported, but this requires providing fonts through EmbeddedBackendConfig. If only regular font is provided, it serves as a fallback. All fonts must be of the same size.

rust
use mousefood::embedded_graphics::{mock_display::MockDisplay, pixelcolor::Rgb888};
use mousefood::{EmbeddedBackend, EmbeddedBackendConfig, fonts};
use ratatui::Terminal;

fn main() -> Result> {
    let mut display = MockDisplay::::new();
    let config = EmbeddedBackendConfig {
        font_regular: fonts::MONO_6X13,
        font_bold: Some(fonts::MONO_6X13_BOLD),
        font_italic: Some(fonts::MONO_6X13_ITALIC),
        ..Default::default()
    };
    let backend = EmbeddedBackend::new(&mut display, config);
    let _terminal = Terminal::new(backend)?;
    Ok(())
}

Color theme

Colors can be remapped using color_theme on EmbeddedBackendConfig. By default the ANSI palette is used.

…

Built-in themes

Mousefood includes popular color themes that can be used directly:

  • ColorTheme::ansi() - Standard ANSI colors (default)
  • ColorTheme::tokyo_night() - Tokyo Night dark theme with blue/purple tones

Cursor and blink

Mousefood supports configurable cursor styles and text blinking.

The cursor style can be set to Inverse (default), Underline, Outline, or Japanese. Inverse mode requires the framebuffer feature and falls back to underline without it.

let config = EmbeddedBackendConfig {
    cursor: CursorConfig {
        style: CursorStyle::Japanese,
        blink: true,
        color: Rgb888::WHITE,

    },
    ..Default::default()
};

Text blink modifiers (SLOW_BLINK, RAPID_BLINK) and cursor blinking are behind the blink feature flag to avoid unnecessary computation and memory usage when not needed:

toml
[dependencies]
mousefood = { version = "*", features = ["blink"] }

Blink timing is configurable:

let config = EmbeddedBackendConfig {
    #[cfg(feature = "blink")]
    blink: BlinkConfig {
        fps: 30,
        slow: BlinkTiming { blinks_per_sec: 1, duty_percent: 15 },
        fast: BlinkTiming { blinks_per_sec: 3, duty_percent: 50 },
    },
    ..Default::default()
};

Without the blink feature, blink modifiers are silently ignored and the cursor is always visible.

Simulator

Mousefood can be run in a simulator using embedded-graphics-simulator crate.

Run simulator example:

bash
git clone https://github.com/ratatui/mousefood.git
cd mousefood/examples/simulator
cargo run

For more details, view the simulator example.

EPD support

WeAct Studio

Support for EPD (e-ink displays) produced by WeAct Studio (weact-studio-epd driver) can be enabled using epd-weact feature.

This driver requires some additional configuration. Follow the weact-studio-epd crate docs and apply the same flush_callback pattern used in the Waveshare example below.

Setup example

EPD drivers include their own internal buffers, so the mousefood framebuffer adds memory overhead with no benefit. Disable default features to turn it off:

toml
[dependencies]
mousefood = { version = "*", default-features = false, features = ["epd-weact"] }
…

Waveshare

Support for EPD (e-ink displays) produced by Waveshare Electronics (epd-waveshare driver) can be enabled using epd-waveshare feature.

Setup example

EPD drivers include their own internal buffers, so the mousefood framebuffer adds memory overhead with no benefit. Disable default features to turn it off:

toml
[dependencies]
mousefood = { version = "*", default-features = false, features = ["epd-waveshare"] }
…

See the full embedded example at examples/epd-waveshare-demo.

Lilygo T5 e-paper

Support for the lilygo T5 e-paper produced by Lilygo with an esp32s3 and the EDO47TC1 panel driver. (lilygo-epd47 driver) can be enabled using lilygo-epd47 feature.

Setup example

The lilygo-epd47 driver include its own internal buffers, so the mousefood framebuffer adds memory overhead with no benefit. Disable default features to turn it off:

toml
[dependencies]
mousefood = { version = "*", default-features = false, features = ["lilygo-epd47"] }
…

See the full embedded example at examples/lilygo-epd47-demo.

Performance and hardware support

Flash memory on most embedded devices is very limited. Additionally, to achieve high frame rate when using the fonts feature, it is recommended to use opt-level = 3, which can make the resulting binary even larger.

Mousefood is hardware-agnostic. Successfully tested on:

Microcontrollers

  • ESP32 (Xtensa)
  • ESP32-S3 (Xtensa)
  • ESP32-C6 (RISC-V)
  • STM32
  • RP2040
  • RP2350

Display drivers

For every driver, the list of displays is not exhaustive.

For displays using embedded-graphics' Gray2, Gray4, or Gray8 pixel colors, enable the monochrome feature to convert Ratatui colors to grayscale:

toml
mousefood = { version = "*", features = ["monochrome"] }
  • ssd1306 for SSD1306
  • mipidsi for ILI9341, ST7735, etc.
  • epd-waveshare for e-paper displays from Waveshare (requires enabling epd-waveshare feature)
  • weact-studio-epd for e-paper displays from WeAct Studio (requires enabling epd-weact feature)
  • lilygo-epd47 for the Lilygo T5 e-paper from Lilygo (requires enabling lilygo-epd47 feature)

Send a pull request to add your microcontroller or display driver here!

Docs

Full API docs are available on docs.rs.

Contributing

All contributions are welcome!

Before opening a pull request, please read the contributing guidelines.

Built with Mousefood

Here are some projects built using Mousefood:

  • AirSniffer - Get information about your indoor climate at a glance.
  • Tuitar - A portable guitar training tool.
  • Mnyaoo32 - An eccentric way to consume IRC messages using ESP32.
  • Phone-OS - A modern phone OS for ESP32 CYD.
  • MaraTUI - A terminal dashboard for keeping an eye on Lelit Mara X espresso shots.

Send a pull request to add your project here!

License

Mousefood is dual-licensed under Apache 2.0 and MIT terms.

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Rustembedded-graphicsratatuirusttui

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言