slint/internal/backends/mcu
2022-03-23 11:15:44 +01:00
..
LICENSES Fix LICENSES symlinks 2022-02-09 17:05:47 +01:00
pico_st7789 Add MCU board config setup (#1006) 2022-03-03 13:31:40 +01:00
renderer MCU renderer: fix artifact when drawing clipped border rectangle 2022-03-17 07:34:23 +01:00
simulator [reorg]: Move the rendering backends into internal 2022-01-31 16:00:50 +01:00
build.rs Add MCU board config setup (#1006) 2022-03-03 13:31:40 +01:00
Cargo.toml Janitor: bump rp-pico dependency 2022-03-14 11:50:05 +01:00
fonts.rs Adapt to the TextShaper API changes in the mcu font backend 2022-03-10 10:51:32 +01:00
lengths.rs Implement the length traits with generics 2022-03-17 07:34:23 +01:00
lib.rs MCU: run the timers 2022-03-18 18:51:29 +01:00
pico_st7789.rs MCU pico: increase heap size 2022-03-18 09:33:23 +01:00
profiler.rs cargo fmt 2022-03-03 14:00:13 +01:00
README.md Update MCU readme a little 2022-03-23 11:15:44 +01:00
renderer.rs MCU renderer: Fix border radius bigger than the item 2022-03-17 07:34:23 +01:00
simulator.rs MCU: Allow to use RGB565 for the draw buffer 2022-03-14 15:52:09 +01:00

NOTE: This library is an internal crate of the Slint project. This crate should not be used directly by applications using Slint. You should use the slint crate instead.

WARNING: This crate does not follow the semver convention for versioning and can only be used with version = "=x.y.z" in Cargo.toml.

Slint MCU backend

The MCU backend is still a work in progress.

We are currently working on getting demo running with the Raspberry Pi Pico and ST7789 based screen. The Raspberry Pi Pico uses a RP2040 micro-controller which has 264KB of RAM and 2MB of flash memory.

The other backend is the simulator which is a way to test the software rendering backend on desktop.

How to use

In order to use this backend, the final program must depend on both slint and i_slint_backend_mcu. The main.rs will look something like this

#![no_std]
#![cfg_attr(not(feature = "simulator"), no_main)]
slint::include_modules!();

#[i_slint_backend_mcu::entry]
fn main() -> ! {
    i_slint_backend_mcu::init();
    MainWindow::new().run();
    panic!("The event loop should not return");
}

Since i_slint_backend_mcu is at the moment an internal crate not uploaded to crates.io, you must use the git version of slint, slint-build, and i_slint_backend_mcu

[dependencies]
slint = { git = "https://github.com/slint-ui/slint" }
i_slint_backend_mcu = { git = "https://github.com/slint-ui/slint" }
# ...
[build-dependencies]
slint-build = { git = "https://github.com/slint-ui/slint" }

Run the demo:

Some environment variable must be set when building so the Slint compiler knows to embedd the images and font into the binary

export SLINT_EMBED_GLYPHS=1 
export SLINT_FONT_SIZES=8,11,10,12,13,14,15,16,18,20,22,24,32
export SLINT_PROCESS_IMAGES=1

The simulator

(Assume env variables are set)

cargo run -p printerdemo_mcu --features=i-slint-backend-mcu/simulator --release

On the Raspberry Pi Pico

You need nightly rust because that's the only way to get an allocator.

First set the environment variable above and build the demo with:

cargo +nightly build -p printerdemo_mcu --features=mcu-pico-st7789 --target=thumbv6m-none-eabi --release

You should process the file with elf2uf2-rs

cargo install elf2uf2-rs
elf2uf2-rs target/thumbv6m-none-eabi/release/printerdemo_mcu

Then upload the demo to the raspberry pi: push the "bootsel" white button on the device while connecting the micro-usb cable to the device, this connect some storage where you can store the binary.

Or from the command on linux: (connect the device while pressing the "bootsel" button.

# mount the device 
udisksctl mount -b /dev/sda1
# upload
elf2uf2-rs -d target/thumbv6m-none-eabi/release/printerdemo_mcu

Using probe-run

This require probe-run (cargo install probe-run) and to connect the pico via a probe (for example another pico running the probe)

Then you can simply run with cargo run

CARGO_TARGET_THUMBV6M_NONE_EABI_LINKER="flip-link" CARGO_TARGET_THUMBV6M_NONE_EABI_RUNNER="probe-run --chip RP2040" cargo +nightly run -p printerdemo_mcu --features=mcu-pico-st7789 --target=thumbv6m-none-eabi --release