Littlevgl
The related code/working directory of this example resides in directory {WAMR_DIR}/samples/littlevgl
Last updated
The related code/working directory of this example resides in directory {WAMR_DIR}/samples/littlevgl
Last updated
Note: The sample has been migrated to bytecodealliance/wamr-app-framework/samples/littlevgl.
This sample demonstrates that a graphic user interface application in WebAssembly by compiling the LittlevGL v5.3, an open-source embedded 2d graphic library into the WASM bytecode.
In this sample, the whole LittlevGL v5.3 source code is built into the WebAssembly code with the user application. The platform interfaces defined by LittlevGL is implemented in the runtime and registered for WASM application through calling wasm_runtime_full_init().
The runtime component supports building target for Linux and Zephyr/STM Nucleo board. The beauty of this sample is the WebAssembly application can have identical display and behavior when running from both runtime environments. That implies we can do majority of application validation from desktop environment as long as two runtime distributions support the same set of application interface.
Below pictures show the WASM application is running on an STM board with an LCD touch panel.
The number on top will plus one each second, and the number on the bottom will plus one when clicked. When users click the blue button, the WASM application increases the counter, and the latest counter value is displayed on the top banner of the touch panel.
The sample also provides the native Linux version of application without the runtime under folder "vgl-native-ui-app". It can help to check differences between the implementations in native and WebAssembly.
32 bit SDL(simple directmedia layer) (Note: only necessary when WAMR_BUILD_TARGET
is set to X86_32
when building WAMR runtime) Use apt-get:
Or download source from www.libsdl.org:
64 bit SDL(simple directmedia layer) (Note: only necessary when WAMR_BUILD_TARGET
is set to X86_64
when building WAMR runtime) Use apt-get:
Or download source from www.libsdl.org:
Build
All binaries are in "out", which contains "host_tool", "vgl_native_ui_app", "ui_app.wasm" "ui_app_no_wasi.wasm "and "vgl_wasm_runtime".
Run the native Linux build of the lvgl sample (no wasm)
Run WASM VM Linux applicaton & install WASM APP First start vgl_wasm_runtime in server mode.
Then install and uninstall wasm APPs by using host tool.
We can use a STM32 NUCLEO_F767ZI board with ILI9341 display and XPT2046 touch screen to run the test. Then use host_tool to remotely install wasm app into STM32.
Build WASM VM into Zephyr system a. clone zephyr source code Refer to Zephyr getting started.
b. copy samples
c. create a link to wamr root dir
d. build source code Since ui_app incorporated LittlevGL source code, so it needs more RAM on the device to install the application. It is recommended that RAM SIZE not less than 380KB. In our test use nucleo_f767zi, which is supported by Zephyr. Since the littlevgl wasm app is quite big (~100KB in wasm format and ~200KB in AOT format ), there isn't enough SRAM to build interpreter and AOT together. You can only choose one of them:
Interpreter
AOT
Hardware Connections
Install WASM application to Zephyr using host_tool First, connect PC and STM32 with UART. Then install to use host_tool.
Note: WASI is unavailable on zephyr currently, so you have to use the ui_app_builtin_libc.wasm which doesn't depend on WASI.
Install AOT version WASM application