Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions demos/home-automation/zephyr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ if(BOARD STREQUAL "native_sim/native/64")
elseif(BOARD STREQUAL "mimxrt1170_evk@B/mimxrt1176/cm7")
set(Rust_CARGO_TARGET "thumbv7em-none-eabihf")
set(BOARD_CONF_NAME "mimxrt1170_evk_mimxrt1176_cm7")
elseif(BOARD STREQUAL "rza3m_ek")
set(Rust_CARGO_TARGET "aarch64-unknown-none")
set(SLINT_LIBRARY_CARGO_FLAGS "-Zbuild-std=core,alloc")
set(BOARD_CONF_NAME "rza3m_ek")
else()
# See rustc --print target-list for available targets. Match that up with you supported board
# https://docs.zephyrproject.org/latest/boards
Expand Down
29 changes: 29 additions & 0 deletions demos/home-automation/zephyr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ The `-p always` option of the build command forces a pristine build. The Zephyr

## Build and Run the Example on a Device

### NXP MIMXRT1170-EVKB

This sample has been tested on the [NXP MIMXRT1170-EVKB](https://docs.zephyrproject.org/latest/boards/nxp/mimxrt1170_evk/doc/index.html) with a [RK055HDMIPI4MA0 MIPI display](https://docs.zephyrproject.org/latest/boards/shields/rk055hdmipi4ma0/doc/index.html). The board/debug probe may require configuring as described [here](https://docs.zephyrproject.org/latest/boards/nxp/mimxrt1170_evk/doc/index.html#configuring-a-debug-probe).

```bash
Expand All @@ -92,3 +94,30 @@ west build -b mimxrt1170_evk@B/mimxrt1176/cm7 -p always slint/demos/home-automat
# Flash
west flash
```

### Renesas EK-RZ/A3M

This sample can run on the [Renesas EK-RZ/A3M](https://www.renesas.com/en/products/microcontrollers-microprocessors/rz-mpus/ek-rza3m-evaluation-kit-rza3m-mpu) evaluation kit with its 5-inch 720x1280 MIPI display.

**Note:** The EK-RZ/A3M requires using Renesas's Zephyr fork. Replace step 4 of the prerequisites with:

```bash
# If Slint source is already checked out (use west-rza3m.yaml instead of west.yaml):
cd ..
west init -l --mf demos/zephyr-common/west-rza3m.yaml ./slint

# If you do not have Slint source yet:
west init -m https://github.com/slint-ui/slint --mr zephyr --mf demos/zephyr-common/west-rza3m.yaml slint-zephyr
cd slint-zephyr

# Checkout the repositories:
west update
```

```bash
# Build
west build -b rza3m_ek -p always slint/demos/home-automation/zephyr -- -DSHIELD=rtkapplcdms02001be -DCMAKE_BUILD_TYPE=Release

# Flash (using J-Link)
west flash
```
12 changes: 8 additions & 4 deletions demos/printerdemo/zephyr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ if(BOARD STREQUAL "native_sim/native/64")
elseif(BOARD STREQUAL "mimxrt1170_evk@B/mimxrt1176/cm7")
set(Rust_CARGO_TARGET "thumbv7em-none-eabi")
set(BOARD_CONF_NAME "mimxrt1170_evk_mimxrt1176_cm7")
elseif(BOARD STREQUAL "rza3m_ek")
set(Rust_CARGO_TARGET "aarch64-unknown-none")
set(SLINT_LIBRARY_CARGO_FLAGS "-Zbuild-std=core,alloc")
set(BOARD_CONF_NAME "rza3m_ek")
else()
# See rustc --print target-list for available targets. Match that up with you supported board
# https://docs.zephyrproject.org/latest/boards
Expand All @@ -33,10 +37,10 @@ endif()
find_package(Zephyr)
project(slint_zephyr_printer_demo_mcu LANGUAGES CXX)

set(SLINT_FEATURE_FREESTANDING ON)
set(SLINT_FEATURE_RENDERER_SOFTWARE ON)
set(DEFAULT_SLINT_EMBED_RESOURCES "embed-for-software-renderer" CACHE STRING "")
# set(CMAKE_BUILD_TYPE Release)
set(SLINT_FEATURE_FREESTANDING ON CACHE BOOL "" FORCE)
set(SLINT_FEATURE_RENDERER_SOFTWARE ON CACHE BOOL "" FORCE)
set(SLINT_FEATURE_SDF_FONTS ON CACHE BOOL "" FORCE)
set(DEFAULT_SLINT_EMBED_RESOURCES "embed-for-software-renderer-with-sdf" CACHE STRING "")
set(BUILD_SHARED_LIBS OFF)

# Work around gcc_s linker issue?
Expand Down
29 changes: 29 additions & 0 deletions demos/printerdemo/zephyr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ The `-p always` option of the build command forces a pristine build. The Zephyr

## Build and Run the Example on a Device

### NXP MIMXRT1170-EVKB

This sample has been tested on the [NXP MIMXRT1170-EVKB](https://docs.zephyrproject.org/latest/boards/nxp/mimxrt1170_evk/doc/index.html) with a [RK055HDMIPI4MA0 MIPI display](https://docs.zephyrproject.org/latest/boards/shields/rk055hdmipi4ma0/doc/index.html). The board/debug probe may require configuring as described [here](https://docs.zephyrproject.org/latest/boards/nxp/mimxrt1170_evk/doc/index.html#configuring-a-debug-probe).

```bash
Expand All @@ -92,3 +94,30 @@ west build -b mimxrt1170_evk@B/mimxrt1176/cm7 -p always slint/demos/printerdemo/
# Flash
west flash
```

### Renesas EK-RZ/A3M

This sample can run on the [Renesas EK-RZ/A3M](https://www.renesas.com/en/products/microcontrollers-microprocessors/rz-mpus/ek-rza3m-evaluation-kit-rza3m-mpu) evaluation kit with its 5-inch 720x1280 MIPI display.

**Note:** The EK-RZ/A3M requires using Renesas's Zephyr fork. Replace step 4 of the prerequisites with:

```bash
# If Slint source is already checked out (use west-rza3m.yaml instead of west.yaml):
cd ..
west init -l --mf demos/zephyr-common/west-rza3m.yaml ./slint

# If you do not have Slint source yet:
west init -m https://github.com/slint-ui/slint --mr zephyr --mf demos/zephyr-common/west-rza3m.yaml slint-zephyr
cd slint-zephyr

# Checkout the repositories:
west update
```

```bash
# Build
west build -b rza3m_ek -p always slint/demos/printerdemo/zephyr -- -DSHIELD=rtkapplcdms02001be -DCMAKE_BUILD_TYPE=Release

# Flash (using J-Link)
west flash
```
14 changes: 14 additions & 0 deletions demos/zephyr-common/boards/rza3m_ek.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright © SixtyFPS GmbH <[email protected]>
# SPDX-License-Identifier: MIT

CONFIG_MAIN_STACK_SIZE=65536
CONFIG_HEAP_MEM_POOL_SIZE=16777216
CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE=8388608

CONFIG_DISPLAY=y
CONFIG_MIPI_DSI=y
CONFIG_GPIO=y

CONFIG_INPUT=y
CONFIG_INPUT_GT911=y
CONFIG_INPUT_QUEUE_MAX_MSGS=64
8 changes: 8 additions & 0 deletions demos/zephyr-common/boards/rza3m_ek.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright © SixtyFPS GmbH <[email protected]>
// SPDX-License-Identifier: MIT

/ {
chosen {
zephyr,touch = &gt911_rtkapplcdms02001be;
};
};
50 changes: 37 additions & 13 deletions demos/zephyr-common/slint-zephyr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ struct RotationInfo
using RenderingRotation = slint::platform::SoftwareRenderer::RenderingRotation;
RenderingRotation rotation = RenderingRotation::NoRotation;
slint::PhysicalSize size;
bool software_rotation = false;

bool is_transpose() const
{
Expand All @@ -75,11 +76,19 @@ struct RotationInfo

bool mirror_width() const
{
if (software_rotation) {
return rotation == RenderingRotation::Rotate180
|| rotation == RenderingRotation::Rotate90;
}
return rotation == RenderingRotation::Rotate180 || rotation == RenderingRotation::Rotate270;
}

bool mirror_height() const
{
if (software_rotation) {
return rotation == RenderingRotation::Rotate270
|| rotation == RenderingRotation::Rotate180;
}
return rotation == RenderingRotation::Rotate90 || rotation == RenderingRotation::Rotate180;
}
};
Expand Down Expand Up @@ -150,7 +159,8 @@ class ZephyrWindowAdapter : public slint::platform::WindowAdapter

const struct device *m_display;
const RotationInfo m_rotationInfo;
const slint::PhysicalSize m_size;
const slint::PhysicalSize m_physicalSize;
const slint::PhysicalSize m_logicalSize;

bool m_needs_redraw = true;
std::vector<slint::platform::Rgb565Pixel> m_buffer;
Expand Down Expand Up @@ -228,6 +238,10 @@ std::unique_ptr<ZephyrWindowAdapter> ZephyrWindowAdapter::init_from(const device
info.rotation = slint::platform::SoftwareRenderer::RenderingRotation::Rotate180;
else if (IS_ENABLED(CONFIG_MCUX_ELCDIF_PXP_ROTATE_270))
info.rotation = slint::platform::SoftwareRenderer::RenderingRotation::Rotate90;
#ifdef CONFIG_BOARD_RZA3M_EK
info.rotation = slint::platform::SoftwareRenderer::RenderingRotation::Rotate90;
info.software_rotation = true;
#endif

const auto rotatedSize = transformed(info.size, info);
LOG_INF("Rotated screen size: %u x %u", rotatedSize.width, rotatedSize.height);
Expand All @@ -239,14 +253,19 @@ ZephyrWindowAdapter::ZephyrWindowAdapter(const device *display, RepaintBufferTyp
: m_renderer(buffer_type),
m_display(display),
m_rotationInfo(info),
m_size(transformed(m_rotationInfo.size, m_rotationInfo))
m_physicalSize(info.size),
m_logicalSize(transformed(info.size, info))
{
m_buffer.resize(m_size.width * m_size.height);
m_buffer.resize(m_physicalSize.width * m_physicalSize.height);

m_buffer_descriptor.buf_size = sizeof(m_buffer[0]) * m_buffer.size();
m_buffer_descriptor.width = m_size.width;
m_buffer_descriptor.height = m_size.height;
m_buffer_descriptor.pitch = m_size.width;
m_buffer_descriptor.width = m_physicalSize.width;
m_buffer_descriptor.height = m_physicalSize.height;
m_buffer_descriptor.pitch = m_physicalSize.width;

if (m_rotationInfo.software_rotation) {
m_renderer.set_rendering_rotation(m_rotationInfo.rotation);
}
}

void ZephyrWindowAdapter::request_redraw()
Expand All @@ -256,7 +275,7 @@ void ZephyrWindowAdapter::request_redraw()

slint::PhysicalSize ZephyrWindowAdapter::size()
{
return m_size;
return m_logicalSize;
}

slint::platform::AbstractRenderer &ZephyrWindowAdapter::renderer()
Expand All @@ -270,16 +289,16 @@ void ZephyrWindowAdapter::maybe_redraw()
return;

auto start = k_uptime_get();
auto region = m_renderer.render(m_buffer, m_size.width);
auto region = m_renderer.render(m_buffer, m_physicalSize.width);
const auto slintRenderDelta = k_uptime_delta(&start);
LOG_DBG("Rendering %d dirty regions:", std::ranges::size(region.rectangles()));
for (auto [o, s] : region.rectangles()) {
#ifndef CONFIG_SHIELD_RK055HDMIPI4MA0
#if !defined(CONFIG_SHIELD_RK055HDMIPI4MA0) && !defined(CONFIG_BOARD_RZA3M_EK)
// Convert to big endian pixel data for Zephyr, unless we are using the RK055HDMIPI4MA0
// shield. See is_supported_pixel_format above.
// shield or rza3m_ek board. See is_supported_pixel_format above.
for (int y = o.y; y < o.y + s.height; y++) {
for (int x = o.x; x < o.x + s.width; x++) {
auto px = reinterpret_cast<uint16_t *>(&m_buffer[y * m_size.width + x]);
auto px = reinterpret_cast<uint16_t *>(&m_buffer[y * m_physicalSize.width + x]);
*px = (*px << 8) | (*px >> 8);
}
}
Expand All @@ -292,7 +311,7 @@ void ZephyrWindowAdapter::maybe_redraw()
m_buffer_descriptor.height = s.height;

if (const auto ret = display_write(m_display, o.x, o.y, &m_buffer_descriptor,
m_buffer.data() + ((o.y * m_size.width) + o.x))
m_buffer.data() + ((o.y * m_physicalSize.width) + o.x))
!= 0) {
LOG_WRN("display_write returned non-zero: %d", ret);
}
Expand Down Expand Up @@ -391,7 +410,10 @@ void ZephyrPlatform::run_event_loop()
}

if (auto next_timer_update = slint::platform::duration_until_next_timer_update()) {
const auto wait_time_ms = next_timer_update.value().count();
auto wait_time_ms = next_timer_update.value().count();
#ifdef CONFIG_BOARD_RZA3M_EK
wait_time_ms = std::min(wait_time_ms, static_cast<decltype(wait_time_ms)>(10000));
#endif
LOG_DBG("Sleeping for %llims", wait_time_ms);
k_sem_take(&SLINT_SEM, K_MSEC(wait_time_ms));
} else {
Expand Down Expand Up @@ -483,7 +505,9 @@ void zephyr_process_input_event(struct input_event *event, void *user_data)
}
}

#if DT_HAS_CHOSEN(zephyr_touch)
INPUT_CALLBACK_DEFINE(DEVICE_DT_GET(DT_CHOSEN(zephyr_touch)), zephyr_process_input_event, NULL);
#endif

void slint_zephyr_init(const struct device *display)
{
Expand Down
17 changes: 17 additions & 0 deletions demos/zephyr-common/west-rza3m.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright © SixtyFPS GmbH <[email protected]>
# SPDX-License-Identifier: MIT

# West manifest for Renesas EK-RZ/A3M board.
# The RZ/A3M requires Renesas's Zephyr fork (wip_rz branch) for board and display support.
# Use this manifest instead of west.yaml when building for rza3m_ek.

---
manifest:
remotes:
- name: renesas
url-base: https://github.com/renesas
projects:
- name: zephyr
remote: renesas
revision: wip_rz
import: true
Loading