LVGL ported to Emscripten to be converted to JavaScript
The result looks like this: https://lvgl.io/demos
Download SDL (a graphics library to open a window and handle the mouse). On Linux:
- Find the current version of SDL2:
apt-cache search libsdl2(e.g.,libsdl2-2.0-0) - Install SDL2:
sudo apt-get install libsdl2-2.0-0(replace with the found version) - Install the SDL2 development package:
sudo apt-get install libsdl2-dev - If build essentials are not installed yet:
sudo apt-get install build-essential
Download the Emscripten SDK and make sure it is in your PATH.
git clone https://github.com/emscripten-core/emsdk.gitcd emsdkgit pull./emsdk install latest./emsdk activate latestsource ./emsdk_env.sh
More info here: Emscripten Downloads
- Be sure you ran
. <path-to-emsdk>/emsdk_env.shto add EMSDK toPATH - In any directory:
git clone --recursive https://github.com/lvgl/lv_web_emscripten.git cd lv_web_emscriptenmkdir cmbuildcd cmbuildemcmake cmake ..emmake make -j4- A file called
index.htmlwill be generated. Open this in your browser
LVGL_CHOSEN_DEMOcan be set to the desired demo name so that you don't need to change any C files. This is useful to compile many demos in bulk using a script.
Example:
emcmake cmake .. -DLVGL_CHOSEN_DEMO=lv_demo_widgetsChrome might not be able to open the generated HTML file offline. It works if you copy the files to a server. Use Firefox or other browser for offline testing if needed.
Firefox might not be able to open the generated HTML file offline unless you go to about:config and change privacy.file_unique_origin to false.