Skip to content

Commit 7501aba

Browse files
committed
updated example
1 parent c5a613f commit 7501aba

30 files changed

+1642
-252
lines changed

README.md

Lines changed: 63 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,66 @@
1-
# LVGL web simulator project with EEZ Studio
1+
# Example of native interface between EEZ Studio and LVGL when EEZ Flow is not used
22

3-
## How to get started
3+
## User actions
4+
5+
In LVGL project with EEZ Flow you can define user actions that can be attached to the event handlers. You are doing this in 4 steps:
6+
7+
- Step 1: Add user actions
8+
9+
Go to User Actions tab, press + button, enter the name of user action and press OK:
10+
11+
![alt text](readme-images/user_actions_tab.png)
12+
13+
![alt text](readme-images/add_action_dialog.png)
14+
15+
- Step 2: Set the "Implementation type" property of user action to "Native"
16+
17+
![alt text](readme-images/impl_type_native.png)
18+
19+
Note: You can still provide flow implementation of native function. This implemenentation will be used when running project inside EEZ Studio with the Run button.
20+
21+
- Step 3: Create event handler and attach it to the user action
22+
23+
Select widget, for example Button, and in properties find Events section and press + button:
24+
25+
![alt text](readme-images/event_handlers.png)
26+
27+
Now, select event and user action and press OK:
28+
29+
![alt text](readme-images/add_event_handler_dialog.png)
30+
31+
- Step 4: Implement user action in C
32+
33+
You need to implement in C++ function called `void action_<user action name>(lv_event_t * e)`. For example, if user action is called `inc_counter` you need to implement `void action_inc_counter(lv_event_t * e);`. Declaration of all user actions can be found in generated file `actions.h`. You can implement user actions in any C file or you can add `actions.cpp` file template in your project like this:
34+
35+
![alt text](readme-images/add_actions_cpp_file_template.png)
36+
37+
## Variables
38+
39+
In LVGL project with EEZ Flow you can define native global variables with the get/set functions that you must implement in C++. You are doing this in 3 steps:
40+
41+
- Step 1: Add global variable
42+
43+
Go to Variables tab, select Global, press + button, enter the name and type of variable and press OK:
44+
45+
![alt text](readme-images/add_variable.png)
46+
47+
![alt text](readme-images/add_variable_dialog.png)
48+
49+
- Step 2: Use variable inside widget
50+
51+
![alt text](readme-images/use_variable.png)
52+
53+
- Step 3: Implement get and set functions in C++
54+
55+
You need to implement in C++, for each variable, functions called `<variable type> get_var_<variable name>()` and `void set_var_<variable name>(<variable_type> value)`. For example, if variable is called `selected_item` and type is `integer` you need to implement `int32_t get_var_selected_item();` and `void set_var_selected_item(int32_t value)`. Function declarations for all variables can be found in generated file `vars.h`. You can implement these functions in any C++ file or you can add `vars.cpp` file template in your project like this:
56+
57+
![alt text](readme-images/implement_variable.png)
58+
59+
## Accessing flow variables from the native code
60+
61+
Chech the `vars.cpp` file to see how can you **set flow variable value** from native code (check function `init_vars` from `vars.cpp`), or how can you **get flow variable value** from natiave code (check function `get_var_greeting_str` from `vars.cpp`).
62+
63+
## How to build project
464

565
### Install SDL
666

@@ -23,15 +83,9 @@ Download the [Emscripten SDK](https://kripken.github.io/emscripten-site/) and ma
2383
More info here: https://kripken.github.io/emscripten-site/docs/getting_started/downloads.html
2484

2585
### Build the project
26-
1. `cd C:\Users\mvladic\eez-projects\native-interface-lvgl-with-flow.eez-project`
86+
1. `cd C:\work\eez\native-interface-lvgl-no-flow`
2787
2. `mkdir build`
2888
3. `cd build`
2989
4. `emcmake cmake ..`
3090
5. `emmake make -j4`
3191
6. A file called `index.html` will be generated. Run this in your browser.
32-
33-
#### Known issue with Google Chrome browser
34-
Chrome can't open the generated html file offline. It works if you copy the files to a server. Use Firefox or other browser for offline testing.
35-
36-
#### Known issue with Firefox
37-
Firefox can't open the generated html file offline unless you go to `about:config` and change `privacy.file_unique_origin` to `false`.

eez-framework

native-interface-lvgl-with-flow.eez-project.eez-project renamed to native-interface-lvgl-with-flow.eez-project

Lines changed: 880 additions & 115 deletions
Large diffs are not rendered by default.

readme-images/add_action_dialog.png

3.31 KB
Loading
28.4 KB
Loading
10.6 KB
Loading

readme-images/add_variable.png

4 KB
Loading

readme-images/add_variable_dialog.png

12.1 KB
Loading

readme-images/event_handlers.png

2.46 KB
Loading

readme-images/impl_type_native.png

7.58 KB
Loading

0 commit comments

Comments
 (0)