Setup LVGL in a simulator with 4 clicks in 2 minutes

Hi,

I’ve set up GitHub Codespace for LVGL. With this you can create, test, develop, build UIs with LVGL in an online VSCode editor. The result UI will be shown in VSCode too as a HTML file. All these are free for 30 hours per month (with the default 4 CPU core server)

All this takes only 4 click and 2 minutes assuming that you are already at the lvgl repo :slight_smile:

  • 1st click: Click on the Code button: image

  • 2nd click: Click on the Codespaces tab

  • 3rd click: Click the Create Codespace on master button:

  • Wait a minute while the workspace is setting up

  • Drag build_all.sh file to the Terminal and press enter (I considered it as one click :slightly_smiling_face: ) You can also just type ./build_all.sh into the Terminal.

  • Wait a minute while LVGL is compiling

  • Enjoy! :blush:

How does it work on your end?

Do you have any ideas how to start build_all.sh with a “real click”? :smiley:

6 Likes

First of all, thank you for your great effort. I stumbled accross your project when making the first steps for LVGL. I successfully could follow all your steps to setup the environment.

Now, wenn I try to run the project, I get this error
The path to the compiler for one or more source files was not found in the CMake cache. If you are using a toolchain file, this probably means that you need to specify the CACHE option when you set your C and/or C++ compiler path

and in the output I notice
[cmake] – Warning: Did not find file Compiler/-ASM

What am I missing to do?

1 Like

Hi,

I’ve just tried it out and it worked well for me. Could you try it again by creating a new codespace?

2 Likes

Hi there!
Being not very expert.
When runnig build_all.sh
I get these erros:

/workspace/lvgl_app $ ‘/workspace/lvgl_app/build_all.sh’
configure: cmake … -DCMAKE_TOOLCHAIN_FILE=/usr/local/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -DCMAKE_CROSSCOMPILING_EMULATOR=/usr/local/emsdk/node/18.20.3_64bit/bin/node
– The ASM compiler identification is unknown
– Found assembler: /usr/local/emsdk/upstream/emscripten/emcc
– Warning: Did not find file Compiler/-ASM
– Configuring done
– Generating done
– Build files have been written to: /workspace/lvgl_app/build
make: make -j4
Scanning dependencies of target lvgl
[ 0%] Building C object lvgl/CMakeFiles/lvgl.dir/src/core/lv_obj.c.o
[ 0%] Building C object lvgl/CMakeFiles/lvgl.dir/src/core/lv_group.c.o
[ 0%] Building C object lvgl/CMakeFiles/lvgl.dir/src/core/lv_obj_draw.c.o
[ 0%] Building C object lvgl/CMakeFiles/lvgl.dir/src/core/lv_obj_class.c.o
ports:INFO: retrieving port: sdl2 from https://github.com/libsdl-org/SDL/archive/release-2.28.4.zip
ports:INFO: unpacking port: sdl2
cache:INFO: generating port: sysroot/lib/wasm32-emscripten/libSDL2.a… (this will be cached in “/usr/local/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/libSDL2.a” for subsequent builds)
system_libs:INFO: compiled 117 inputs in 12.17s
cache:INFO: - ok
/workspace/lvgl_app/lvgl/src/core/lv_obj.c:384:5: error: call to undeclared function ‘lv_obj_assign_id’; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
384 | lv_obj_assign_id(class_p, obj);
| ^
/workspace/lvgl_app/lvgl/src/core/lv_obj.c:384:5: note: did you mean ‘lv_obj_align_to’?
/workspace/lvgl_app/lvgl/src/core/lv_obj_pos.h:190:6: note: ‘lv_obj_align_to’ declared here
190 | void lv_obj_align_to(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, int32_t x_ofs,
| ^
/workspace/lvgl_app/lvgl/src/core/lv_obj.c:421:5: error: call to undeclared function ‘lv_obj_free_id’; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
421 | lv_obj_free_id(obj);
| ^
/workspace/lvgl_app/lvgl/src/core/lv_obj.c:421:5: note: did you mean ‘lv_obj_fade_in’?
/workspace/lvgl_app/lvgl/src/core/lv_obj_style.h:218:6: note: ‘lv_obj_fade_in’ declared here
218 | void lv_obj_fade_in(lv_obj_t * obj, uint32_t time, uint32_t delay);
| ^
2 errors generated.
make[2]: *** [lvgl/CMakeFiles/lvgl.dir/build.make:78: lvgl/CMakeFiles/lvgl.dir/src/core/lv_obj.c.o] Error 1
make[2]: *** Waiting for unfinished jobs…
make[1]: *** [CMakeFiles/Makefile2:212: lvgl/CMakeFiles/lvgl.dir/all] Error 2
make: *** [Makefile:130: all] Error 2
emmake: error: ‘make -j4’ failed (returned 2)

Do you have a guess?
japi

@kisvegabor
It does fail

/workspace/lvgl_app/lvgl/src/core/lv_obj.c:427:5: note: did you mean ‘lv_obj_fade_in’?
/workspace/lvgl_app/lvgl/src/core/lv_obj_style.h:218:6: note: ‘lv_obj_fade_in’ declared here
218 | void lv_obj_fade_in(lv_obj_t * obj, uint32_t time, uint32_t delay);
| ^
2 errors generated.
make[2]: *** [lvgl/CMakeFiles/lvgl.dir/build.make:78: lvgl/CMakeFiles/lvgl.dir/src/core/lv_obj.c.o] Error 1
make[2]: *** Waiting for unfinished jobs…
make[1]: *** [CMakeFiles/Makefile2:212: lvgl/CMakeFiles/lvgl.dir/all] Error 2
make: *** [Makefile:130: all] Error 2
emmake: error: ‘make -j4’ failed (returned 2)

Thank you for reporting it!

I’ve open PR to fix it: fix(codespace): set LV_OBJ_ID_AUTO_ASSIGN 0 by kisvegabor · Pull Request #6417 · lvgl/lvgl · GitHub

You can easily do the same change manually in your Codespace.

However, the HTML file can’t be opened for me. Does it work for you?

Hello,

Like japi_vgl I am not very expert, in fact I have no knowledge at all of how to use Codespace.

I have worked through your four clicks, including build_all.sh
As far as I can tell this all works OK with no errors.
The Terminal Prompt is “@Ken - 1010”, so I guess this is the moniker assigned to me.

A tab opens in the editing pane showing the display that I think is generated by file:
lv_demo_widgets.c
( Profile Tab shows Elena Smith )

So far so good, but where do I go from here?

I’d like to try to run some of the many demos and examples that I can see in the explorer pane, and try some edits myself to see how the display changes.

Can you give a short description of how to go about this?, or point me to some instructions – hopefully fairly short and simple.

Many thanks. Ken.

Great news! Thank you for the feedback!

You can just edit main.c. Call an other lv_demo_..., lv_example_... or add your custom LVGL code.

1 Like

Hi again,
Your instruction is very straightforward, but I now seem to have a new problem.
I open file main.c, with its original call to lv_demo_widgets();
Build: Build finished with exit code 0 (I assume this mean no errors)
Run:
To run, I click on the small triangle icon at bottom, which says
“Launch the selected target in terminal window: [index]”
when I hover mouse on it.
I’m not sure if that is correct, because it fails to run. In the Terminal panel I get:
“Setting environment variables”, followed by PATH= and then a large block of text which
looks quite normal to me. But it finishes with:
@Ken-1010 ➜ /workspace/lvgl_app/build $ /workspace/lvgl_app/build/index.html
bash: /workspace/lvgl_app/build/index.html: Permission denied
@Ken-1010 ➜ /workspace/lvgl_app/build $

I tried editing main.c to replace lv_demo_widgets(); with lv_demo_keypad_encoder();
It is same as above; Build is OK, but it has same “Permission denied” when I Run.

I did not have this problem when I first launched lvgl in CodeSpaces, so I don’t know what has gone wrong.

It’s working on my end. Please this:

@kisvegabor ➜ /workspace/lvgl_app $ cd build/
@kisvegabor ➜ /workspace/lvgl_app/build $ ls -l
total 1576
-rw-r--r-- 1 codespace codespace   14129 Aug  5 11:22 CMakeCache.txt
drwxr-xr-x 4 codespace codespace    4096 Aug  5 11:22 CMakeFiles
-rw-r--r-- 1 codespace codespace    8404 Aug  5 11:22 Makefile
-rw-r--r-- 1 codespace codespace    1551 Aug  5 11:20 cmake_install.cmake
-rw-r--r-- 1 codespace codespace 1568713 Aug  5 11:22 index.html
drwxr-xr-x 2 codespace codespace    4096 Aug  5 11:21 lib
drwxr-xr-x 3 codespace codespace    4096 Aug  5 11:22 lvgl

What is the permission of index.html for you?

Hi,
Sorry about delay in responding – been away all day.

I have followed your instructions with result:

@Ken-1010 ➜ /workspace/lvgl_app/build $ ls -l
total 8472
-rw-r–r-- 1 codespace codespace 14081 Jul 31 10:11 CMakeCache.txt
drwxr-xr-x 4 codespace codespace 4096 Aug 5 15:53 CMakeFiles
-rw-r–r-- 1 codespace codespace 8404 Aug 5 15:53 Makefile
-rw-r–r-- 1 codespace codespace 1556 Jul 31 10:11 cmake_install.cmake
-rw-r–r-- 1 codespace codespace 296774 Aug 5 15:53 compile_commands.json
-rw-r–r-- 1 codespace codespace 8330244 Aug 1 18:11 index.html
drwxr-xr-x 2 codespace codespace 4096 Aug 1 18:07 lib
drwxr-xr-x 3 codespace codespace 4096 Aug 5 15:53 lvgl
@Ken-1010 ➜ /workspace/lvgl_app/build $

So my permission for index.html is same as yours.
But I notice that the size is much larger ?

Hi again,

I have made some progress! –

  1. Deleted my codespace “account”, and started from scratch.
    LVGL compiles and runs as before.

  2. I now realise that the command “./build_all.sh” launches the simulation – it is in effect the “Run” button. That is where I was stuck.

  3. In file main.c I replaced “lv_demo_widgets()” with “lv_demo_keypad_encoder()”, and it runs correctly – big step forward!

  4. I have tried a few of the demos, some work OK, eg “lv_demo_stress()”, but some do not work, eg “lv_demo_vector_graphic()”.

  5. I am not too bothered about that, but what I want is to be able to run the examples, such as:
    examples/widgets/button/lv_example_button_1.c
    I’d like to be able to run the file, do some edits, and run again to see effect of my edits.
    I cannot figure out how to do this. Just putting “lv_example_button_1()” in the main.c file does not work.

I don’t fully understand. What was the actual issue here?

What error do you see?

upon running the shell file i got this: [ 27%] Building C object lvgl/CMakeFiles/lvgl.dir/src/libs/fsdrv/lv_fs_win32.c.o
/workspace/lvgl_app/lvgl/src/libs/fsdrv/lv_fs_memfs.c:51:6: error: “LV_FS_MEMFS_LETTER must be set to a valid value”
51 | #error “LV_FS_MEMFS_LETTER must be set to a valid value”
| ^
1 error generated.
make[2]: *** [lvgl/CMakeFiles/lvgl.dir/build.make:2622: lvgl/CMakeFiles/lvgl.dir/src/libs/fsdrv/lv_fs_memfs.c.o] Error 1
make[2]: *** Waiting for unfinished jobs…
make[1]: *** [CMakeFiles/Makefile2:212: lvgl/CMakeFiles/lvgl.dir/all] Error 2
make: *** [Makefile:130: all] Error 2
emmake: error: ‘make -j4’ failed (returned 2)

Sorry, I’ve just noticed that you post flagged as spam. I’ve tested it and could reproduce the issue. I’ll send a fix today or tomorrow.

1 Like

Same problem.

[ 28%] Building C object lvgl/CMakeFiles/lvgl.dir/src/libs/gif/gifdec.c.o
/workspace/lvgl_app/lvgl/src/libs/fsdrv/lv_fs_memfs.c:51:6: error: "LV_FS_MEMFS_LETTER must be set to a valid value"
   51 |     #error "LV_FS_MEMFS_LETTER must be set to a valid value"
      |      ^
1 error generated.
make[2]: *** [lvgl/CMakeFiles/lvgl.dir/build.make:2832: lvgl/CMakeFiles/lvgl.dir/src/libs/fsdrv/lv_fs_memfs.c.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [CMakeFiles/Makefile2:212: lvgl/CMakeFiles/lvgl.dir/all] Error 2
make: *** [Makefile:130: all] Error 2
emmake: error: 'make -j4' failed (returned 2)

Sorry for the delay. I’ve fixed it here: fix(codespace): use lv_conf.defaults to generate lv_conf.h by kisvegabor · Pull Request #7075 · lvgl/lvgl · GitHub

1 Like

THIS IS SO EASY!! Why isn’t this an option under the LVGL guide on Simulator on PC — LVGL documentation ???

They need to rename the page to “Simulators” and have a cloud and PC section within the page.

The PC simulator is maybe not so well maintained, so no mention there. It’s also possible that the PC simulator doesn’t support any input (from either mouse or keyboard) so it’s in a different quality class.

This method (using Github Codespace) supports intput right, or is it also missing all input methods?