mirror of
https://github.com/eez-open/lvgl-template-web.git
synced 2026-11-17 05:58:55 +01:00
update eez-framework
This commit is contained in:
parent
29d33fb0ad
commit
13a8a417b3
@ -1,8 +1,8 @@
|
|||||||
cmake_minimum_required(VERSION 3.12)
|
cmake_minimum_required(VERSION 3.12)
|
||||||
project (lvgl-template-web)
|
project (lvgl-template-web)
|
||||||
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -O2 -s USE_SDL=2")
|
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -O2")
|
||||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s INITIAL_MEMORY=83886080 -sLLD_REPORT_UNDEFINED")
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s INITIAL_MEMORY=83886080 -sLLD_REPORT_UNDEFINED -s USE_SDL=2")
|
||||||
|
|
||||||
include_directories(${PROJECT_SOURCE_DIR})
|
include_directories(${PROJECT_SOURCE_DIR})
|
||||||
|
|
||||||
|
|||||||
2
eez
2
eez
@ -1 +1 @@
|
|||||||
Subproject commit 70ddce6d411ec7c82ca3f42dfcc14e70cb97dcc7
|
Subproject commit 5fe7bc4f51e23d5a4804c9c51a15589ef8e54bd6
|
||||||
@ -28,7 +28,7 @@
|
|||||||
{
|
{
|
||||||
"objID": "2212bc5e-cf4a-4a81-c9ab-a671066d086f",
|
"objID": "2212bc5e-cf4a-4a81-c9ab-a671066d086f",
|
||||||
"fileName": "screens.c",
|
"fileName": "screens.c",
|
||||||
"template": "#include \"screens.h\"\n#include \"images.h\"\n#include \"fonts.h\"\n#include \"actions.h\"\n#include \"../flow.h\"\n\n//${eez-studio LVGL_SCREENS_DEF}\n//${eez-studio LVGL_SCREENS_DEF_EXT}"
|
"template": "#include \"screens.h\"\n#include \"images.h\"\n#include \"fonts.h\"\n#include \"actions.h\"\n#include \"ui.h\"\n\n//${eez-studio LVGL_SCREENS_DEF}\n//${eez-studio LVGL_SCREENS_DEF_EXT}"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"objID": "19d3d573-88a3-4550-f4da-753b61d7f0c4",
|
"objID": "19d3d573-88a3-4550-f4da-753b61d7f0c4",
|
||||||
@ -64,6 +64,16 @@
|
|||||||
"objID": "bad0addd-10de-48f7-e57e-b40fce3e7c45",
|
"objID": "bad0addd-10de-48f7-e57e-b40fce3e7c45",
|
||||||
"fileName": "fonts.h",
|
"fileName": "fonts.h",
|
||||||
"template": "#ifndef EEZ_LVGL_UI_FONTS_H\r\n#define EEZ_LVGL_UI_FONTS_H\r\n\r\n#include \"lvgl/lvgl.h\"\r\n\r\n//${eez-studio LVGL_FONTS_DECL}\r\n\r\n#endif /*EEZ_LVGL_UI_FONTS_H*/"
|
"template": "#ifndef EEZ_LVGL_UI_FONTS_H\r\n#define EEZ_LVGL_UI_FONTS_H\r\n\r\n#include \"lvgl/lvgl.h\"\r\n\r\n//${eez-studio LVGL_FONTS_DECL}\r\n\r\n#endif /*EEZ_LVGL_UI_FONTS_H*/"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"objID": "7bc0152a-1716-469c-a3f8-8346707369a1",
|
||||||
|
"fileName": "ui.h",
|
||||||
|
"template": "#ifndef EEZ_LVGL_UI_GUI_H\n#define EEZ_LVGL_UI_GUI_H\n\n#include <eez/flow/lvgl_api.h>\n\nvoid ui_init();\nvoid ui_tick();\n\n#endif // EEZ_LVGL_UI_GUI_H"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"objID": "cb1d0e99-b8a8-43f7-815f-e6a8f7f5fe6f",
|
||||||
|
"fileName": "ui.c",
|
||||||
|
"template": "#include \"ui.h\"\n#include \"screens.h\"\n#include \"images.h\"\n#include \"flow_def.h\"\n\nvoid ui_init() {\n eez_flow_init(assets, sizeof(assets), (lv_obj_t **)&objects, sizeof(objects), images, sizeof(images));\n}\n\nvoid ui_tick() {\n eez_flow_tick();\n tick_screen(g_currentScreen);\n}\n"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"destinationFolder": "src/ui"
|
"destinationFolder": "src/ui"
|
||||||
|
|||||||
7
main.c
7
main.c
@ -18,8 +18,7 @@
|
|||||||
#include "lv_drivers/indev/mousewheel.h"
|
#include "lv_drivers/indev/mousewheel.h"
|
||||||
#include "lv_drivers/indev/keyboard.h"
|
#include "lv_drivers/indev/keyboard.h"
|
||||||
|
|
||||||
#include "src/flow.h"
|
#include "src/ui/ui.h"
|
||||||
#include "src/ui/screens.h"
|
|
||||||
|
|
||||||
/*********************
|
/*********************
|
||||||
* DEFINES
|
* DEFINES
|
||||||
@ -72,7 +71,7 @@ int main(int argc, char ** argv)
|
|||||||
hal_init();
|
hal_init();
|
||||||
|
|
||||||
/*Init*/
|
/*Init*/
|
||||||
flowInit();
|
ui_init();
|
||||||
|
|
||||||
emscripten_set_main_loop_arg(do_loop, NULL, -1, true);
|
emscripten_set_main_loop_arg(do_loop, NULL, -1, true);
|
||||||
}
|
}
|
||||||
@ -83,7 +82,7 @@ void do_loop(void *arg)
|
|||||||
* It could be done in a timer interrupt or an OS task too.*/
|
* It could be done in a timer interrupt or an OS task too.*/
|
||||||
lv_task_handler();
|
lv_task_handler();
|
||||||
|
|
||||||
flowTick();
|
ui_tick();
|
||||||
|
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
|
|
||||||
|
|||||||
168
src/flow.cpp
168
src/flow.cpp
@ -1,168 +0,0 @@
|
|||||||
#include <stdio.h>
|
|
||||||
#include <lvgl/lvgl.h>
|
|
||||||
|
|
||||||
#if HAS_FLOW_SUPPORT
|
|
||||||
#include <eez/core/os.h>
|
|
||||||
#include <eez/core/action.h>
|
|
||||||
|
|
||||||
#include <eez/flow/flow.h>
|
|
||||||
#include <eez/flow/expression.h>
|
|
||||||
#include <eez/flow/hooks.h>
|
|
||||||
#include <eez/flow/debugger.h>
|
|
||||||
#include <eez/flow/components.h>
|
|
||||||
#include <eez/flow/flow_defs_v3.h>
|
|
||||||
|
|
||||||
#include "ui/flow_def.h"
|
|
||||||
|
|
||||||
static void replacePageHook(int16_t pageId, uint32_t animType, uint32_t speed, uint32_t delay);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "ui/screens.h"
|
|
||||||
#include "ui/images.h"
|
|
||||||
|
|
||||||
static int16_t currentScreen = -1;
|
|
||||||
|
|
||||||
static lv_obj_t *getLvglObjectFromIndex(int32_t index) {
|
|
||||||
if (index == -1) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return ((lv_obj_t **)&objects)[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
static const void *getLvglImageByName(const char *name) {
|
|
||||||
for (size_t imageIndex = 0; imageIndex < sizeof(images) / sizeof(ext_img_desc_t); imageIndex++) {
|
|
||||||
if (strcmp(images[imageIndex].name, name) == 0) {
|
|
||||||
return images[imageIndex].img_dsc;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" void loadScreen(int index) {
|
|
||||||
currentScreen = index;
|
|
||||||
lv_obj_t *screen = getLvglObjectFromIndex(index);
|
|
||||||
lv_scr_load_anim(screen, LV_SCR_LOAD_ANIM_FADE_IN, 200, 0, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" void flowInit() {
|
|
||||||
#if HAS_FLOW_SUPPORT
|
|
||||||
eez::initAssetsMemory();
|
|
||||||
eez::loadMainAssets(assets, sizeof(assets));
|
|
||||||
eez::initOtherMemory();
|
|
||||||
eez::initAllocHeap(eez::ALLOC_BUFFER, eez::ALLOC_BUFFER_SIZE);
|
|
||||||
|
|
||||||
eez::flow::replacePageHook = replacePageHook;
|
|
||||||
eez::flow::getLvglObjectFromIndexHook = getLvglObjectFromIndex;
|
|
||||||
eez::flow::getLvglImageByNameHook = getLvglImageByName;
|
|
||||||
|
|
||||||
eez::flow::start(eez::g_mainAssets);
|
|
||||||
|
|
||||||
create_screens();
|
|
||||||
replacePageHook(1, 0, 0, 0);
|
|
||||||
#else
|
|
||||||
create_screens();
|
|
||||||
loadScreen(0);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" void flowTick() {
|
|
||||||
#if HAS_FLOW_SUPPORT
|
|
||||||
eez::flow::tick();
|
|
||||||
#endif
|
|
||||||
tick_screen(currentScreen);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if HAS_FLOW_SUPPORT
|
|
||||||
|
|
||||||
namespace eez {
|
|
||||||
ActionExecFunc g_actionExecFunctions[] = { 0 };
|
|
||||||
}
|
|
||||||
|
|
||||||
void replacePageHook(int16_t pageId, uint32_t animType, uint32_t speed, uint32_t delay) {
|
|
||||||
eez::flow::onPageChanged(currentScreen + 1, pageId);
|
|
||||||
currentScreen = pageId - 1;
|
|
||||||
lv_scr_load_anim(getLvglObjectFromIndex(currentScreen), (lv_scr_load_anim_t)animType, speed, delay, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" void flowOnPageLoaded(int pageIndex) {
|
|
||||||
eez::flow::getPageFlowState(eez::g_mainAssets, pageIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" void flowPropagateValue(unsigned pageIndex, unsigned componentIndex, unsigned outputIndex) {
|
|
||||||
eez::flow::FlowState *flowState = eez::flow::getPageFlowState(eez::g_mainAssets, pageIndex);
|
|
||||||
eez::flow::propagateValue(flowState, componentIndex, outputIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
static char textValue[1000];
|
|
||||||
|
|
||||||
extern "C" const char *evalTextProperty(unsigned pageIndex, unsigned componentIndex, unsigned propertyIndex, const char *errorMessage) {
|
|
||||||
eez::flow::FlowState *flowState = eez::flow::getPageFlowState(eez::g_mainAssets, pageIndex);
|
|
||||||
eez::Value value;
|
|
||||||
if (!eez::flow::evalProperty(flowState, componentIndex, propertyIndex, value, errorMessage)) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
value.toText(textValue, sizeof(textValue));
|
|
||||||
return textValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" int32_t evalIntegerProperty(unsigned pageIndex, unsigned componentIndex, unsigned propertyIndex, const char *errorMessage) {
|
|
||||||
eez::flow::FlowState *flowState = eez::flow::getPageFlowState(eez::g_mainAssets, pageIndex);
|
|
||||||
eez::Value value;
|
|
||||||
if (!eez::flow::evalProperty(flowState, componentIndex, propertyIndex, value, errorMessage)) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
int err;
|
|
||||||
int32_t intValue = value.toInt32(&err);
|
|
||||||
if (err) {
|
|
||||||
eez::flow::throwError(flowState, componentIndex, errorMessage);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return intValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" bool evalBooleanProperty(unsigned pageIndex, unsigned componentIndex, unsigned propertyIndex, const char *errorMessage) {
|
|
||||||
eez::flow::FlowState *flowState = eez::flow::getPageFlowState(eez::g_mainAssets, pageIndex);
|
|
||||||
eez::Value value;
|
|
||||||
if (!eez::flow::evalProperty(flowState, componentIndex, propertyIndex, value, errorMessage)) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
int err;
|
|
||||||
bool booleanValue = value.toBool(&err);
|
|
||||||
if (err) {
|
|
||||||
eez::flow::throwError(flowState, componentIndex, errorMessage);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return booleanValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" void assignIntegerProperty(unsigned pageIndex, unsigned componentIndex, unsigned propertyIndex, int32_t value, const char *errorMessage) {
|
|
||||||
eez::flow::FlowState *flowState = eez::flow::getPageFlowState(eez::g_mainAssets, pageIndex);
|
|
||||||
|
|
||||||
auto component = flowState->flow->components[componentIndex];
|
|
||||||
|
|
||||||
eez::Value dstValue;
|
|
||||||
if (!eez::flow::evalAssignableExpression(flowState, componentIndex, component->properties[propertyIndex]->evalInstructions, dstValue, errorMessage)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
eez::Value srcValue((int)value, eez::VALUE_TYPE_INT32);
|
|
||||||
|
|
||||||
eez::flow::assignValue(flowState, componentIndex, dstValue, srcValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" void assignBooleanProperty(unsigned pageIndex, unsigned componentIndex, unsigned propertyIndex, bool value, const char *errorMessage) {
|
|
||||||
eez::flow::FlowState *flowState = eez::flow::getPageFlowState(eez::g_mainAssets, pageIndex);
|
|
||||||
|
|
||||||
auto component = flowState->flow->components[componentIndex];
|
|
||||||
|
|
||||||
eez::Value dstValue;
|
|
||||||
if (!eez::flow::evalAssignableExpression(flowState, componentIndex, component->properties[propertyIndex]->evalInstructions, dstValue, errorMessage)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
eez::Value srcValue(value, eez::VALUE_TYPE_BOOLEAN);
|
|
||||||
|
|
||||||
eez::flow::assignValue(flowState, componentIndex, dstValue, srcValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
32
src/flow.h
32
src/flow.h
@ -1,32 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <lvgl/lvgl.h>
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void flowInit();
|
|
||||||
void flowTick();
|
|
||||||
|
|
||||||
lv_obj_t *getLvglObjectFromIndex(int32_t index);
|
|
||||||
void loadScreen(int index);
|
|
||||||
|
|
||||||
#if HAS_FLOW_SUPPORT
|
|
||||||
|
|
||||||
void flowOnPageLoaded(unsigned pageIndex);
|
|
||||||
void flowPropagateValue(unsigned pageIndex, unsigned componentIndex, unsigned outputIndex);
|
|
||||||
|
|
||||||
const char *evalTextProperty(unsigned pageIndex, unsigned componentIndex, unsigned propertyIndex, const char *errorMessage);
|
|
||||||
int32_t evalIntegerProperty(unsigned pageIndex, unsigned componentIndex, unsigned propertyIndex, const char *errorMessage);
|
|
||||||
bool evalBooleanProperty(unsigned pageIndex, unsigned componentIndex, unsigned propertyIndex, const char *errorMessage);
|
|
||||||
|
|
||||||
void assignIntegerProperty(unsigned pageIndex, unsigned componentIndex, unsigned propertyIndex, int32_t value, const char *errorMessage);
|
|
||||||
void assignBooleanProperty(unsigned pageIndex, unsigned componentIndex, unsigned propertyIndex, bool value, const char *errorMessage);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
@ -2,6 +2,6 @@
|
|||||||
|
|
||||||
#include "actions.h"
|
#include "actions.h"
|
||||||
#include "screens.h"
|
#include "screens.h"
|
||||||
#include "../flow.h"
|
#include "ui.h"
|
||||||
|
|
||||||
// Define native actions here
|
// Define native actions here
|
||||||
@ -6,10 +6,13 @@
|
|||||||
extern const lv_img_dsc_t img_log_eez;
|
extern const lv_img_dsc_t img_log_eez;
|
||||||
extern const lv_img_dsc_t img_logo_lvgl;
|
extern const lv_img_dsc_t img_logo_lvgl;
|
||||||
|
|
||||||
|
#ifndef EXT_IMG_DESC_T
|
||||||
|
#define EXT_IMG_DESC_T
|
||||||
typedef struct _ext_img_desc_t {
|
typedef struct _ext_img_desc_t {
|
||||||
const char *name;
|
const char *name;
|
||||||
const lv_img_dsc_t *img_dsc;
|
const lv_img_dsc_t *img_dsc;
|
||||||
} ext_img_desc_t;
|
} ext_img_desc_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
extern const ext_img_desc_t images[2];
|
extern const ext_img_desc_t images[2];
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
#include "images.h"
|
#include "images.h"
|
||||||
#include "fonts.h"
|
#include "fonts.h"
|
||||||
#include "actions.h"
|
#include "actions.h"
|
||||||
#include "../flow.h"
|
#include "ui.h"
|
||||||
|
|
||||||
objects_t objects;
|
objects_t objects;
|
||||||
|
|
||||||
|
|||||||
13
src/ui/ui.c
Normal file
13
src/ui/ui.c
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#include "ui.h"
|
||||||
|
#include "screens.h"
|
||||||
|
#include "images.h"
|
||||||
|
#include "flow_def.h"
|
||||||
|
|
||||||
|
void ui_init() {
|
||||||
|
eez_flow_init(assets, sizeof(assets), (lv_obj_t **)&objects, sizeof(objects), images, sizeof(images));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ui_tick() {
|
||||||
|
eez_flow_tick();
|
||||||
|
tick_screen(g_currentScreen);
|
||||||
|
}
|
||||||
9
src/ui/ui.h
Normal file
9
src/ui/ui.h
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#ifndef EEZ_LVGL_UI_GUI_H
|
||||||
|
#define EEZ_LVGL_UI_GUI_H
|
||||||
|
|
||||||
|
#include <eez/flow/lvgl_api.h>
|
||||||
|
|
||||||
|
void ui_init();
|
||||||
|
void ui_tick();
|
||||||
|
|
||||||
|
#endif // EEZ_LVGL_UI_GUI_H
|
||||||
@ -2,6 +2,6 @@
|
|||||||
|
|
||||||
#include "vars.h"
|
#include "vars.h"
|
||||||
#include "screens.h"
|
#include "screens.h"
|
||||||
#include "../flow.h"
|
#include "ui.h"
|
||||||
|
|
||||||
// Define native variables here
|
// Define native variables here
|
||||||
Loading…
Reference in New Issue
Block a user