Browse Source

update eez-framework

master
Martin Vladic 2 years ago
parent
commit
13a8a417b3
  1. 4
      CMakeLists.txt
  2. 2
      eez
  3. 12
      lvgl-template-web.eez-project
  4. 7
      main.c
  5. 168
      src/flow.cpp
  6. 32
      src/flow.h
  7. 2
      src/ui/actions.c
  8. 3
      src/ui/images.h
  9. 2
      src/ui/screens.c
  10. 13
      src/ui/ui.c
  11. 9
      src/ui/ui.h
  12. 2
      src/ui/vars.c

4
CMakeLists.txt

@ -1,8 +1,8 @@
cmake_minimum_required(VERSION 3.12)
project (lvgl-template-web)
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -O2 -s USE_SDL=2")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s INITIAL_MEMORY=83886080 -sLLD_REPORT_UNDEFINED")
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -O2")
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})

2
eez

@ -1 +1 @@
Subproject commit 70ddce6d411ec7c82ca3f42dfcc14e70cb97dcc7
Subproject commit 5fe7bc4f51e23d5a4804c9c51a15589ef8e54bd6

12
lvgl-template-web.eez-project

@ -28,7 +28,7 @@
{
"objID": "2212bc5e-cf4a-4a81-c9ab-a671066d086f",
"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",
@ -64,6 +64,16 @@
"objID": "bad0addd-10de-48f7-e57e-b40fce3e7c45",
"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*/"
},
{
"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"

7
main.c

@ -18,8 +18,7 @@
#include "lv_drivers/indev/mousewheel.h"
#include "lv_drivers/indev/keyboard.h"
#include "src/flow.h"
#include "src/ui/screens.h"
#include "src/ui/ui.h"
/*********************
* DEFINES
@ -72,7 +71,7 @@ int main(int argc, char ** argv)
hal_init();
/*Init*/
flowInit();
ui_init();
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.*/
lv_task_handler();
flowTick();
ui_tick();
SDL_Event event;

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

@ -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
src/ui/actions.c

@ -2,6 +2,6 @@
#include "actions.h"
#include "screens.h"
#include "../flow.h"
#include "ui.h"
// Define native actions here

3
src/ui/images.h

@ -6,10 +6,13 @@
extern const lv_img_dsc_t img_log_eez;
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 {
const char *name;
const lv_img_dsc_t *img_dsc;
} ext_img_desc_t;
#endif
extern const ext_img_desc_t images[2];

2
src/ui/screens.c

@ -2,7 +2,7 @@
#include "images.h"
#include "fonts.h"
#include "actions.h"
#include "../flow.h"
#include "ui.h"
objects_t objects;

13
src/ui/ui.c

@ -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

@ -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
src/ui/vars.c

@ -2,6 +2,6 @@
#include "vars.h"
#include "screens.h"
#include "../flow.h"
#include "ui.h"
// Define native variables here
Loading…
Cancel
Save