slint-ui / slint

Slint is a declarative GUI toolkit to build native user interfaces for Rust, C++, or JavaScript apps.
https://slint.dev
Other
17.07k stars 573 forks source link

Demostrate Slint integration with Zephyr OS #5411

Closed 0x6e closed 2 months ago

0x6e commented 3 months ago

Using the existing printerdemo_mcu example, demonstrate how to implement slint::platform::Platform and slint::platform::WindowAdapter for Zephyr OS. The demo has been tested with the Zephyr native simulator, and the NXP MIMXRT1170-EVKB with a RK055HDMIPI4MA0 MIPI display.

Know issues:

  1. unlike the Espressif integration, we don't provide the platform integration as part of the Slint C++ API. In part, this is due to the way Zephyr OS handles device hardware. Zephyr uses the Device Tree to describe the hardware to the device driver model. In order to register an input event call back we need a pointer to a device obtained from a device tree node, and we also need to know how the driver behaves in order to write our callback function. The existing implementation is generic enough to cover the simulator and display shield drivers. A more general solution could be investigated in the future;
  2. double buffering is not supported as neither the simulator or the hardware used for testing reported it as supported;
  3. in the simulator, we convert dirty regions to big-endian. However, where regions overlap, the intersections get converted more than once resulting in incorrect colors on the display. This is a general issue caused by overlapping dirty regions, and should be tackled separately as it also affects the Espressif demo;
  4. if there are active animations, we need to make sure to sleep for a fixed period of time, otherwise the event loop runs forever, never re-rendering and never getting to a state where there are no active animations. I haven't figured out whether this is an issue with the async code in the platform integration, or something I missed regarding threading with Zephyr in particular (i.e. I haven't tried other schedulers yet);
  5. The example doesn't use the full screen on the hardware. We should probably use the non-mcu version of printerdemo. For this to work nicely we need to rotate the screen to landscape mode.

For now I would like to get the existing code reviewed, and look at fixing the issues in follow up PRs.