mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-28 06:14:10 +00:00
2.5 KiB
2.5 KiB
Generic Instructions for Slint on STM32 MCUs
The following instructions outline a rough, general path how to get started on an STM32 MCU with STM32 Cube tooling and Slint. Successful completion requires experience with STM32CubeMX as well as the peripherals of our board.
- Make sure to install all the project:../stm32.md#prerequisites.
- Start a new project with STM32CubeMX:
- Select your base board.
- Enable all peripherals needed. This includes LTDC and typically the FMC to be able to place the framebuffers in RAM.
- Select CMake in the code generator options.
- General the CMake project and skeleton code.
- In the STM32 VS Code Extension, choose the command to import a CMake project.
- In STM32CubeMX select the STM32Cube BSP that matches your board and install it.
- Copy the BSP drivers into your project's source tree and modify
CMakeLists.txt
to add them to the build. - Add C++ support to the generated CMake project by adding
CXX
to theLANGUAGES
option of theproject
command. - Download and extract https://github.com/slint-ui/slint/releases/latest/download/Slint-cpp-nightly-thumbv7em-none-eabihf.tar.gz
- Set
CMAKE_PREFIX_PATH
to the extracted directory. - Adjust your
CMakeLists.txt
for Slint use:- Add a
find_package(Slint)
call. - Enable resource embedding by adding
set(DEFAULT_SLINT_EMBED_RESOURCES embed-for-software-renderer)
. - Set the default style to
Fluent
withset(SLINT_STYLE "fluent-light")
. - Add
SLINT_STM32_BSP_NAME=<name>
to yourtarget_compile_definitions
and replace<name>
with the name of your BSP (for examplestm32h735g_discovery
orstm32h747i_discovery
). - Add
Slint::Slint
to yourtarget_link_libraries
.
- Add a
- Add a C++ source file to your project, for example
appmain.cpp
, with anappmain
function and call it from the generatedmain.c
. - Add a
.slint
file to your project and include it in your project by callingslint_target_sources
. - In your
appmain
function, initialize the screen viaBSP_LCD_InitEx
as well as the touch screen viaBSP_TS_Init
. - Include
#include <slint-stm32.h>
and callslint_stm32_init(SlintPlatformConfiguration());
to initialize the Slint platform integration for STM32. - Finally, include the header file for your
.slint
file, instantiate the generated class, and invoke the event loop by calling->run()
on the instance.