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:
-
Step 1: Add user actions
Go to User Actions tab, press + button, enter the name of user action and press OK:
-
Step 2: Set the "Implementation type" property of user action to "Native"
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.
-
Step 3: Create event handler and attach it to the user action
Select widget, for example Button, and in properties find Events section and press + button:
Now, select event and user action and press OK:
-
Step 4: Implement user action in C or C++
You need to implement in C or C++ a function called
void action_<user action name>(lv_event_t * e)
. For example, if user action is calledinc_counter
you need to implementvoid action_inc_counter(lv_event_t * e);
. Declaration of all user actions can be found in generated fileactions.h
. You can implement user actions in any existing C or C++ file (or even INO file if you are on Arduino) or you can addactions.cpp
file template in your project like this:
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:
-
Step 1: Add global variable
Go to Variables tab, select Global, press + button, enter the name and type of variable and press OK:
-
Step 2: Use variable inside widget
-
Step 3: Implement get and set functions in C++
You need to implement in C++, for each variable, functions called
<variable type> get_var_<variable name>()
andvoid set_var_<variable name>(<variable_type> value)
. For example, if variable is calledselected_item
and type isinteger
you need to implementint32_t get_var_selected_item();
andvoid set_var_selected_item(int32_t value)
. Function declarations for all variables can be found in generated filevars.h
. You can implement these functions in any C++ file or you can addvars.cpp
file template in your project like this:
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
).
Downlad 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 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.git
cd <path-to-emsdk>
git pull
./emsdk install latest
./emsdk activate latest
source ./emsdk_env.sh
More info here: https://kripken.github.io/emscripten-site/docs/getting_started/downloads.html
cd C:\work\eez\native-interface-lvgl-no-flow
mkdir build
cd build
emcmake cmake ..
emmake make -j4
- A file called
index.html
will be generated. Run this in your browser.