Hello Pico Demo User!
Thank you for taking the time to try out the Slint demo on the Raspberry Pi Pico!
Running the Demo
The Raspberry Pi Pico comes with a Slint demo flashed into its memory. The device is powered through the USB connection, so just connect the provided USB cable to the micro USB port on to bottom of the Pico and connect the USB-A plug to any power source (computer, AC connecter or a powerbank). Once power is provided, the Pico will turn on and demo will start automatically.
Setting up a Development Environment to Change the Demo
The following steps involve downloading and executing software from the internet. Please make sure to follow these steps in an environment where that is allowed and possible!
Please follow the Prerequisites section of building Slint instructions to make sure all the basic tools are available.
Microcontrollers like the pico typically need the newest rust compiler
there is (`nightly`). Make sure that is installed using
rustup toolchain install nightly
. Once the nightly
toolchain is installed you will need to install support for the Pico's
CPU architecture using
rustup target add --toolchain nightly thumbv6m-none-eabi
.
Now that rust is installed and ready, you can install tools needed to
work with embedded devices in an rust environment
cargo install probe-run elf2uf2-rs
.
As an optional step you might want to check our
editor setup documentation
to make it more pleasant to work with .slint
code. This
is a one stop process for popular environments like Visual Studio
Code.
Afterwards you can check out the demo code
from github. The
demo can be found in examples/printerdemo_mcu
.
Note for Windows users
The slint repository makes use of symbolic links to avoid duplication of data in its repository, which does not work out of the box on Windows. There are two options to fix this:
-
Using git version
2.11.1
or later you can make use of symbolic links on Windows by runninggit clone -c core.symlinks=true https://github.com/slint-ui/slint
. Unfortunately this requires the checkout to be run as Administrator, so that the symbolic links can be created. -
You can manually create copies of the files needed: After a normal
checkout you need to remove
examples/printerdemo_mcu/ui/fonts
andexamples/printerdemo_mcu/ui/images
and copy these folders over fromexamples/printerdemo/ui
.
Flashing updates to the Pico
Running
cargo +nightly build -p printerdemo_mcu --features=mcu-pico-st7789
--target=thumbv6m-none-eabi --release
in the directory of the slint checkout created above will download all
necessary dependencies of slint, build the slint compiler, compile the
printer_demo's UI files to rust code and then build that together with
the business logic. You will need to allow for a bit of time for the
initial build, successive builds will be faster as the slint compiler
will already be available.
Once the build is successful, you can flash the binary onto the Pico.
Press and hold the white BOOTSEL
button on the back of
the device while connection the USB cable to your computer. This will
cause your a new USB storage device to show up on your computer.
Release the white button once the device has shown up.
The Pico is now ready to be flashed. Simply run
elf2uf2-rs -d
target/thumbv6m-none-eabi/release/printerdemo_mcu
to flash the demo. The Pico will automatically restart once the
flashing process is complete.
More information can be found here: MCU README.
Learning Slint
Slint UIs are defined in a simple, type-safe and fully declarative language that is easy to learn and use and enables reactive UIs.
To get started we recommend to follow along the tutorial.
The Slint UI description language reference is of course also available.
Details about how Rust and the Slint UI description language interact can be found in the Rust crate documentation.
Contact and Help
We are happy to help with your first steps into Slint!
Feel free to reach out via email, our Mattermost Chat Server, Github Discussions or Twitter.