From 0f98f76bcad299898c372a33b122cbf26f8b061b Mon Sep 17 00:00:00 2001 From: Martin Vladic Date: Sat, 29 Oct 2022 13:11:00 +0200 Subject: [PATCH] Initial commit --- .gitignore | 64 ++++++ CMakeLists.txt | 118 ++++++++++ LICENSE | 21 ++ README.md | 50 +++++ confdef.txt | 40 ++++ lv_conf.h | 616 ++++++++++++++++++++++++++++++++++++++++++++++++++++ lv_drv_conf.h | 229 +++++++++++++++++++ lvgl_shell.html | 65 ++++++ main.c | 175 +++++++++++++++ mouse_cursor_icon.c | 104 +++++++++ src/conf/eez/conf.h | 11 + src/flow.cpp | 167 ++++++++++++++ src/flow.h | 32 +++ src/ui/actions.c | 7 + src/ui/actions.h | 8 + src/ui/flow_def.cpp | 19 ++ src/ui/flow_def.h | 23 ++ src/ui/fonts.h | 8 + src/ui/images.c | 4 + src/ui/images.h | 15 ++ src/ui/screens.c | 58 +++++ src/ui/screens.h | 35 +++ src/ui/vars.c | 7 + src/ui/vars.h | 8 + ui.eez-project | 155 +++++++++++++ 25 files changed, 2039 insertions(+) create mode 100644 .gitignore create mode 100644 CMakeLists.txt create mode 100644 LICENSE create mode 100644 README.md create mode 100644 confdef.txt create mode 100644 lv_conf.h create mode 100644 lv_drv_conf.h create mode 100644 lvgl_shell.html create mode 100644 main.c create mode 100644 mouse_cursor_icon.c create mode 100644 src/conf/eez/conf.h create mode 100644 src/flow.cpp create mode 100644 src/flow.h create mode 100644 src/ui/actions.c create mode 100644 src/ui/actions.h create mode 100644 src/ui/flow_def.cpp create mode 100644 src/ui/flow_def.h create mode 100644 src/ui/fonts.h create mode 100644 src/ui/images.c create mode 100644 src/ui/images.h create mode 100644 src/ui/screens.c create mode 100644 src/ui/screens.h create mode 100644 src/ui/vars.c create mode 100644 src/ui/vars.h create mode 100644 ui.eez-project diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..35bf4d4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,64 @@ +# Prerequisites +*.d + +# Object files +*.o +*.ko +*.obj +*.elf + +# Linker output +*.ilk +*.map +*.exp + +# Precompiled Headers +*.gch +*.pch + +# Libraries +*.lib +*.a +*.la +*.lo + +# Shared objects (inc. Windows DLLs) +*.dll +*.so +*.so.* +*.dylib + +# Executables +*.exe +*.out +*.app +*.i*86 +*.x86_64 +*.hex + +# Debug files +*.dSYM/ +*.su +*.idb +*.pdb + +# Kernel Module Compile Results +*.mod* +*.cmd +.tmp_versions/ +modules.order +Module.symvers +Mkfile.old +dkms.conf + +lvgl.html +lvgl.js +lvgl.wasm + +# CMake output +build/* +.vscode + +!build/index.html + +*.eez-project-ui-state diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..fdb3dd9 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,118 @@ +cmake_minimum_required(VERSION 3.12) +project (lv_emscripten) + +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") + +include_directories(${PROJECT_SOURCE_DIR}) + +add_subdirectory(lvgl) +add_subdirectory(lv_drivers) +file(GLOB MY_SOURCES "./*.c") +set(SOURCES ${MY_SOURCES}) + +# Comment out following statements to build project without eez flow support. +# Also, build lvgl-demo-no-flow.eez-project with EEZ Studio. +add_definitions(-DHAS_FLOW_SUPPORT=1) +set (HAS_FLOW_SUPPORT 1) + +file(GLOB_RECURSE my_src + ./src/*.cpp + ./src/*.c +) +list(APPEND SOURCES ${my_src}) + +if (${HAS_FLOW_SUPPORT}) + ################################################################################ + # EEZ Framework + add_definitions(-DEEZ_PLATFORM_SIMULATOR) + add_definitions(-DEEZ_FOR_LVGL) + add_definitions(-DOPTION_GUI=0) + + include_directories( + ./ + ./eez/libs/agg + ./eez/platform/simulator + ./src/conf + ) + + file(GLOB_RECURSE src_eez + ./eez/*.cpp + ./eez/*.c + ) + + # exclude gui specific files + set(EXCLUDE_DIR "./eez/gui") + + foreach(TMP_PATH ${src_eez}) + string(FIND ${TMP_PATH} ${EXCLUDE_DIR} EXCLUDE_DIR_FOUND) + + if(NOT ${EXCLUDE_DIR_FOUND} EQUAL -1) + list(REMOVE_ITEM src_eez ${TMP_PATH}) + endif() + endforeach(TMP_PATH) + + # exclude fs specific files + set(EXCLUDE_DIR "./eez/fs") + + foreach(TMP_PATH ${src_eez}) + string(FIND ${TMP_PATH} ${EXCLUDE_DIR} EXCLUDE_DIR_FOUND) + + if(NOT ${EXCLUDE_DIR_FOUND} EQUAL -1) + list(REMOVE_ITEM src_eez ${TMP_PATH}) + endif() + endforeach(TMP_PATH) + + # exclude STM32 platform specific files + set(EXCLUDE_DIR "./eez/platform/stm32") + + foreach(TMP_PATH ${src_eez}) + string(FIND ${TMP_PATH} ${EXCLUDE_DIR} EXCLUDE_DIR_FOUND) + + if(NOT ${EXCLUDE_DIR_FOUND} EQUAL -1) + list(REMOVE_ITEM src_eez ${TMP_PATH}) + endif() + endforeach(TMP_PATH) + + # exclude libscpi + set(EXCLUDE_DIR "./eez/libs/libscpi") + + foreach(TMP_PATH ${src_eez}) + string(FIND ${TMP_PATH} ${EXCLUDE_DIR} EXCLUDE_DIR_FOUND) + + if(NOT ${EXCLUDE_DIR_FOUND} EQUAL -1) + list(REMOVE_ITEM src_eez ${TMP_PATH}) + endif() + endforeach(TMP_PATH) + + # exclude agg + set(EXCLUDE_DIR "../eez/libs/agg") + + foreach(TMP_PATH ${src_eez}) + string(FIND ${TMP_PATH} ${EXCLUDE_DIR} EXCLUDE_DIR_FOUND) + + if(NOT ${EXCLUDE_DIR_FOUND} EQUAL -1) + list(REMOVE_ITEM src_eez ${TMP_PATH}) + endif() + endforeach(TMP_PATH) + + list(APPEND SOURCES ${src_eez}) + + ################################################################################ +endif(${HAS_FLOW_SUPPORT}) + +add_executable(index ${SOURCES} ${INCLUDES}) + +if(NOT LVGL_CHOSEN_DEMO) + set(LVGL_CHOSEN_DEMO lv_demo_widgets) +endif() +set_source_files_properties(main.c PROPERTIES COMPILE_FLAGS -DCHOSEN_DEMO=${LVGL_CHOSEN_DEMO}) + +set(CMAKE_EXECUTABLE_SUFFIX ".html") +target_link_libraries(index + lvgl + lvgl_examples + lvgl_demos + lv_drivers +) +set_target_properties(index PROPERTIES LINK_FLAGS "--shell-file ${PROJECT_SOURCE_DIR}/lvgl_shell.html -s SINGLE_FILE=1") diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..e418490 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Littlev Graphics Library + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..0bb85a1 --- /dev/null +++ b/README.md @@ -0,0 +1,50 @@ +# Emscripten port + +**LVGL ported to Emscripten to be converted to JavaScript** + +The result looks like this https://lvgl.io/demos + +# How to get started + +## Install SDL + +Downlad [SDL](https://www.libsdl.org/) (a graphics library to ope na window and handle the mouse). On Linux: +1. Find the current version of SDL2: `apt-cache search libsdl2 (e.g. libsdl2-2.0-0)` +2. Install SDL2: `sudo apt-get install libsdl2-2.0-0` (replace with the found version) +3. Install SDL2 development package: `sudo apt-get install libsdl2-dev` +4. If build essentials are not installed yet: `sudo apt-get install build-essential` + + +## Install Emscripten SDK +Download the [Emscripten SDK](https://kripken.github.io/emscripten-site/) and make sure it is in your PATH. + +1. `git clone https://github.com/emscripten-core/emsdk.git` +2. `cd ` +3. `git pull` +4. `./emsdk install latest` +5. `./emsdk activate latest` +6. `source ./emsdk_env.sh` + +More info here: https://kripken.github.io/emscripten-site/docs/getting_started/downloads.html + +## Get the Emscripten-LVGL project +1. Be sure you ran `. /emsdk_env.sh` to add EMSDK to `PATH` +2. In any directoy: `git clone --recurse-submodules https://github.com/mvladic/lv_web_emscripten.git` +3. `cd ` +4. `mkdir build` +5. `cd build` +6. `emcmake cmake ..` +7. `emmake make -j4` +5. A file called `index.html` will be generated. Run this in your browser. + +### Build options (environment variables) + +* `LVGL_CHOSEN_DEMO` can be set to the desired demo name so that you don't need to change any C files. This is useful to compile many demos in bulk using a script. + +Example `emcmake cmake .. -DLVGL_CHOSEN_DEMO=lv_demo_widgets` + +### Known issue with Google Chrome browser +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. + +### Known issue with Firefox +Firefox can't open the generated html file offline unless you go to `about:config` and change `privacy.file_unique_origin` to `false`. diff --git a/confdef.txt b/confdef.txt new file mode 100644 index 0000000..9e42eda --- /dev/null +++ b/confdef.txt @@ -0,0 +1,40 @@ +LV_COLOR_DEPTH 32 +LV_HOR_RES_MAX 800 +LV_VER_RES_MAX 480 +LV_INDEXED_CHROMA 1 +LV_MEM_CUSTOM 1 +LV_TICK_CUSTOM 1 +LV_TICK_CUSTOM_INCLUDE +LV_TICK_CUSTOM_SYS_TIME_EXPR ((uint32_t)emscripten_get_now()) +LV_FONT_MONTSERRAT_8 1 +LV_FONT_MONTSERRAT_10 1 +LV_FONT_MONTSERRAT_12 1 +LV_FONT_MONTSERRAT_14 1 +LV_FONT_MONTSERRAT_16 1 +LV_FONT_MONTSERRAT_18 1 +LV_FONT_MONTSERRAT_20 1 +LV_FONT_MONTSERRAT_22 1 +LV_FONT_MONTSERRAT_24 1 +LV_FONT_MONTSERRAT_26 1 +LV_FONT_MONTSERRAT_28 1 +LV_FONT_MONTSERRAT_30 1 +LV_FONT_MONTSERRAT_32 1 +LV_FONT_MONTSERRAT_34 1 +LV_FONT_MONTSERRAT_36 1 +LV_FONT_MONTSERRAT_38 1 +LV_FONT_MONTSERRAT_40 1 +LV_FONT_MONTSERRAT_42 1 +LV_FONT_MONTSERRAT_44 1 +LV_FONT_MONTSERRAT_46 1 +LV_FONT_MONTSERRAT_48 1 +LV_FONT_MONTSERRAT_12_SUBPX 1 +LV_FONT_MONTSERRAT_28_COMPRESSED 1 +LV_FONT_DEJAVU_16_PERSIAN_HEBREW 1 +LV_FONT_SIMSUN_16_CJK 1 +LV_FONT_UNSCII_8 1 +LV_USE_EXT_CLICK_AREA LV_EXT_CLICK_AREA_FULL +LV_THEME_DEFAULT_FONT_SMALL &lv_font_montserrat_12 +LV_THEME_DEFAULT_FONT_NORMAL &lv_font_montserrat_16 +LV_THEME_DEFAULT_FONT_SUBTITLE &lv_font_montserrat_20 +LV_THEME_DEFAULT_FONT_TITLE &lv_font_montserrat_24 +LV_LINEMETER_PRECISE 1 diff --git a/lv_conf.h b/lv_conf.h new file mode 100644 index 0000000..97f529a --- /dev/null +++ b/lv_conf.h @@ -0,0 +1,616 @@ +/** + * @file lv_conf.h + * Configuration file for v8.0.0-dev + */ + +/* + * COPY THIS FILE AS `lv_conf.h` NEXT TO the `lvgl` FOLDER + */ + +#if 1 /*Set it to "1" to enable content*/ + +#ifndef LV_CONF_H +#define LV_CONF_H +/*clang-format off*/ + +#include + + +/*==================== + COLOR SETTINGS + *====================*/ + +/*Color depth: 1 (1 byte per pixel), 8 (RGB332), 16 (RGB565), 32 (ARGB8888)*/ +#define LV_COLOR_DEPTH 32 + +/*Swap the 2 bytes of RGB565 color. Useful if the display has a 8 bit interface (e.g. SPI)*/ +#define LV_COLOR_16_SWAP 0 + +/*Enable more complex drawing routines to manage screens transparency. + *Can be used if the UI is above an other layer, e.g. an OSD menu or video player. + *Requires `LV_COLOR_DEPTH = 32` colors and the screen's `bg_opa` should be set to non LV_OPA_COVER value*/ +#define LV_COLOR_SCREEN_TRANSP 1 + +/*Images pixels with this color will not be drawn if they are chroma keyed)*/ +#define LV_COLOR_CHROMA_KEY lv_color_hex(0x00ff00) /*pure green*/ + +/*========================= + MEMORY SETTINGS + *=========================*/ + +/*1: use custom malloc/free, 0: use the built-in `lv_mem_alloc()` and `lv_mem_free()`*/ +#define LV_MEM_CUSTOM 1 +#if LV_MEM_CUSTOM == 0 +/*Size of the memory available for `lv_mem_alloc()` in bytes (>= 2kB)*/ +# define LV_MEM_SIZE (128U * 1024U) /*[bytes]*/ + +/*Set an address for the memory pool instead of allocating it as a normal array. Can be in external SRAM too.*/ +# define LV_MEM_ADR 0 /*0: unused*/ +#else /*LV_MEM_CUSTOM*/ +# define LV_MEM_CUSTOM_INCLUDE /*Header for the dynamic memory function*/ +# define LV_MEM_CUSTOM_ALLOC malloc +# define LV_MEM_CUSTOM_FREE free +# define LV_MEM_CUSTOM_REALLOC realloc +#endif /*LV_MEM_CUSTOM*/ + +/*Use the standard `memcpy` and `memset` instead of LVGL's own functions. (Might or might not be faster).*/ +#define LV_MEMCPY_MEMSET_STD 1 + +/*==================== + HAL SETTINGS + *====================*/ + +/*Default display refresh period. LVG will redraw changed ares with this period time*/ +#define LV_DISP_DEF_REFR_PERIOD 30 /*[ms]*/ + +/*Input device read period in milliseconds*/ +#define LV_INDEV_DEF_READ_PERIOD 30 /*[ms]*/ + +/*Use a custom tick source that tells the elapsed time in milliseconds. + *It removes the need to manually update the tick with `lv_tick_inc()`)*/ +#define LV_TICK_CUSTOM 1 +#if LV_TICK_CUSTOM +#define LV_TICK_CUSTOM_INCLUDE +#define LV_TICK_CUSTOM_SYS_TIME_EXPR ((uint32_t)emscripten_get_now()) +#endif /*LV_TICK_CUSTOM*/ + +/*Default Dot Per Inch. Used to initialize default sizes such as widgets sized, style paddings. + *(Not so important, you can adjust it to modify default sizes and spaces)*/ +#define LV_DPI_DEF 130 /*[px/inch]*/ + +/*======================= + * FEATURE CONFIGURATION + *=======================*/ + +/*------------- + * Drawing + *-----------*/ + +/*Enable complex draw engine. + *Required to draw shadow, gradient, rounded corners, circles, arc, skew lines, image transformations or any masks*/ +#define LV_DRAW_COMPLEX 1 +#if LV_DRAW_COMPLEX != 0 + +/*Allow buffering some shadow calculation. + *LV_SHADOW_CACHE_SIZE is the max. shadow size to buffer, where shadow size is `shadow_width + radius` + *Caching has LV_SHADOW_CACHE_SIZE^2 RAM cost*/ +#define LV_SHADOW_CACHE_SIZE 0 +#endif /*LV_DRAW_COMPLEX*/ + +/*Default image cache size. Image caching keeps the images opened. + *If only the built-in image formats are used there is no real advantage of caching. (I.e. if no new image decoder is added) + *With complex image decoders (e.g. PNG or JPG) caching can save the continuous open/decode of images. + *However the opened images might consume additional RAM. + *0: to disable caching*/ +#define LV_IMG_CACHE_DEF_SIZE 0 + +/*Maximum buffer size to allocate for rotation. Only used if software rotation is enabled in the display driver.*/ +#define LV_DISP_ROT_MAX_BUF (10*1024) +/*------------- + * GPU + *-----------*/ + +/*Use STM32's DMA2D (aka Chrom Art) GPU*/ +#define LV_USE_GPU_STM32_DMA2D 0 +#if LV_USE_GPU_STM32_DMA2D +/*Must be defined to include path of CMSIS header of target processor +e.g. "stm32f769xx.h" or "stm32f429xx.h"*/ +#define LV_GPU_DMA2D_CMSIS_INCLUDE +#endif + +/*Use NXP's PXP GPU iMX RTxxx platforms*/ +#define LV_USE_GPU_NXP_PXP 0 +#if LV_USE_GPU_NXP_PXP +/*1: Add default bare metal and FreeRTOS interrupt handling routines for PXP (lv_gpu_nxp_pxp_osa.c) + * and call lv_gpu_nxp_pxp_init() automatically during lv_init(). Note that symbol FSL_RTOS_FREE_RTOS + * has to be defined in order to use FreeRTOS OSA, otherwise bare-metal implementation is selected. + *0: lv_gpu_nxp_pxp_init() has to be called manually before lv_init() + */ +#define LV_USE_GPU_NXP_PXP_AUTO_INIT 0 +#endif + +/*Use NXP's VG-Lite GPU iMX RTxxx platforms*/ +#define LV_USE_GPU_NXP_VG_LITE 0 + +/*------------- + * Logging + *-----------*/ + +/*Enable the log module*/ +#define LV_USE_LOG 1 +#if LV_USE_LOG + +/*How important log should be added: + *LV_LOG_LEVEL_TRACE A lot of logs to give detailed information + *LV_LOG_LEVEL_INFO Log important events + *LV_LOG_LEVEL_WARN Log if something unwanted happened but didn't cause a problem + *LV_LOG_LEVEL_ERROR Only critical issue, when the system may fail + *LV_LOG_LEVEL_USER Only logs added by the user + *LV_LOG_LEVEL_NONE Do not log anything*/ +# define LV_LOG_LEVEL LV_LOG_LEVEL_WARN + +/*1: Print the log with 'printf'; + *0: User need to register a callback with `lv_log_register_print_cb()`*/ +# define LV_LOG_PRINTF 1 + +/*Enable/disable LV_LOG_TRACE in modules that produces a huge number of logs*/ +# define LV_LOG_TRACE_MEM 1 +# define LV_LOG_TRACE_TIMER 1 +# define LV_LOG_TRACE_INDEV 1 +# define LV_LOG_TRACE_DISP_REFR 1 +# define LV_LOG_TRACE_EVENT 1 +# define LV_LOG_TRACE_OBJ_CREATE 1 +# define LV_LOG_TRACE_LAYOUT 1 +# define LV_LOG_TRACE_ANIM 1 + +#endif /*LV_USE_LOG*/ + +/*------------- + * Asserts + *-----------*/ + +/*Enable asserts if an operation is failed or an invalid data is found. + *If LV_USE_LOG is enabled an error message will be printed on failure*/ +#define LV_USE_ASSERT_NULL 1 /*Check if the parameter is NULL. (Very fast, recommended)*/ +#define LV_USE_ASSERT_MALLOC 1 /*Checks is the memory is successfully allocated or no. (Very fast, recommended)*/ +#define LV_USE_ASSERT_STYLE 0 /*Check if the styles are properly initialized. (Very fast, recommended)*/ +#define LV_USE_ASSERT_MEM_INTEGRITY 0 /*Check the integrity of `lv_mem` after critical operations. (Slow)*/ +#define LV_USE_ASSERT_OBJ 0 /*Check the object's type and existence (e.g. not deleted). (Slow)*/ + +/*Add a custom handler when assert happens e.g. to restart the MCU*/ +#define LV_ASSERT_HANDLER_INCLUDE +#define LV_ASSERT_HANDLER while(1); /*Halt by default*/ + +/*------------- + * Others + *-----------*/ + +/*1: Show CPU usage and FPS count in the right bottom corner*/ +#define LV_USE_PERF_MONITOR 0 + +/*1: Show the used memory and the memory fragmentation in the left bottom corner + * Requires LV_MEM_CUSTOM = 0*/ +#define LV_USE_MEM_MONITOR 0 + +/*1: Draw random colored rectangles over the redrawn areas*/ +#define LV_USE_REFR_DEBUG 0 + +/*Change the built in (v)snprintf functions*/ +#define LV_SPRINTF_CUSTOM 0 +#if LV_SPRINTF_CUSTOM +# define LV_SPRINTF_INCLUDE +# define lv_snprintf snprintf +# define lv_vsnprintf vsnprintf +#else /*LV_SPRINTF_CUSTOM*/ +# define LV_SPRINTF_USE_FLOAT 0 +#endif /*LV_SPRINTF_CUSTOM*/ + +#define LV_USE_USER_DATA 1 +#if LV_USE_USER_DATA +typedef void * lv_user_data_t; +#endif + +/*Garbage Collector settings + *Used if lvgl is binded to higher level language and the memory is managed by that language*/ +#define LV_ENABLE_GC 0 +#if LV_ENABLE_GC != 0 +# define LV_GC_INCLUDE "gc.h" /*Include Garbage Collector related things*/ +#endif /*LV_ENABLE_GC*/ + +/*===================== + * COMPILER SETTINGS + *====================*/ + +/*For big endian systems set to 1*/ +#define LV_BIG_ENDIAN_SYSTEM 0 + +/*Define a custom attribute to `lv_tick_inc` function*/ +#define LV_ATTRIBUTE_TICK_INC + +/*Define a custom attribute to `lv_timer_handler` function*/ +#define LV_ATTRIBUTE_TIMER_HANDLER + +/*Define a custom attribute to `lv_disp_flush_ready` function*/ +#define LV_ATTRIBUTE_FLUSH_READY + +/*Required alignment size for buffers*/ +#define LV_ATTRIBUTE_MEM_ALIGN_SIZE + +/*Will be added where memories needs to be aligned (with -Os data might not be aligned to boundary by default). + * E.g. __attribute__((aligned(4)))*/ +#define LV_ATTRIBUTE_MEM_ALIGN + +/*Attribute to mark large constant arrays for example font's bitmaps*/ +#define LV_ATTRIBUTE_LARGE_CONST + +/*Complier prefix for a big array declaration in RAM*/ +#define LV_ATTRIBUTE_LARGE_RAM_ARRAY + +/*Place performance critical functions into a faster memory (e.g RAM)*/ +#define LV_ATTRIBUTE_FAST_MEM + +/*Prefix variables that are used in GPU accelerated operations, often these need to be placed in RAM sections that are DMA accessible*/ +#define LV_ATTRIBUTE_DMA + +/*Export integer constant to binding. This macro is used with constants in the form of LV_ that + *should also appear on LVGL binding API such as Micropython.*/ +#define LV_EXPORT_CONST_INT(int_value) struct _silence_gcc_warning /*The default value just prevents GCC warning*/ + +/*Extend the default -32k..32k coordinate range to -4M..4M by using int32_t for coordinates instead of int16_t*/ +#define LV_USE_LARGE_COORD 0 + +/*================== + * FONT USAGE + *===================*/ + +/*Montserrat fonts with ASCII range and some symbols using bpp = 4 + *https://fonts.google.com/specimen/Montserrat*/ +#define LV_FONT_MONTSERRAT_8 1 +#define LV_FONT_MONTSERRAT_10 1 +#define LV_FONT_MONTSERRAT_12 1 +#define LV_FONT_MONTSERRAT_14 1 +#define LV_FONT_MONTSERRAT_16 1 +#define LV_FONT_MONTSERRAT_18 1 +#define LV_FONT_MONTSERRAT_20 1 +#define LV_FONT_MONTSERRAT_22 1 +#define LV_FONT_MONTSERRAT_24 1 +#define LV_FONT_MONTSERRAT_26 1 +#define LV_FONT_MONTSERRAT_28 1 +#define LV_FONT_MONTSERRAT_30 1 +#define LV_FONT_MONTSERRAT_32 1 +#define LV_FONT_MONTSERRAT_34 1 +#define LV_FONT_MONTSERRAT_36 1 +#define LV_FONT_MONTSERRAT_38 1 +#define LV_FONT_MONTSERRAT_40 1 +#define LV_FONT_MONTSERRAT_42 1 +#define LV_FONT_MONTSERRAT_44 1 +#define LV_FONT_MONTSERRAT_46 1 +#define LV_FONT_MONTSERRAT_48 1 + +/*Demonstrate special features*/ +#define LV_FONT_MONTSERRAT_12_SUBPX 1 +#define LV_FONT_MONTSERRAT_28_COMPRESSED 1 /*bpp = 3*/ +#define LV_FONT_DEJAVU_16_PERSIAN_HEBREW 1 /*Hebrew, Arabic, Perisan letters and all their forms*/ +#define LV_FONT_SIMSUN_16_CJK 1 /*1000 most common CJK radicals*/ + +/*Pixel perfect monospace fonts + *http://pelulamu.net/unscii/*/ +#define LV_FONT_UNSCII_8 1 +#define LV_FONT_UNSCII_16 1 + +/*Optionally declare custom fonts here. + *You can use these fonts as default font too and they will be available globally. + *E.g. #define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(my_font_1) LV_FONT_DECLARE(my_font_2)*/ +#define LV_FONT_CUSTOM_DECLARE + +/*Always set a default font*/ +#define LV_FONT_DEFAULT &lv_font_montserrat_14 + +/*Enable handling large font and/or fonts with a lot of characters. + *The limit depends on the font size, font face and bpp. + *Compiler error will be triggered if a font needs it.*/ +#define LV_FONT_FMT_TXT_LARGE 0 + +/*Enables/disables support for compressed fonts.*/ +#define LV_USE_FONT_COMPRESSED 0 + +/*Enable subpixel rendering*/ +#define LV_USE_FONT_SUBPX 0 +#if LV_USE_FONT_SUBPX +/*Set the pixel order of the display. Physical order of RGB channels. Doesn't matter with "normal" fonts.*/ +#define LV_FONT_SUBPX_BGR 0 /*0: RGB; 1:BGR order*/ +#endif + +/*================= + * TEXT SETTINGS + *=================*/ + +/** + * Select a character encoding for strings. + * Your IDE or editor should have the same character encoding + * - LV_TXT_ENC_UTF8 + * - LV_TXT_ENC_ASCII + */ +#define LV_TXT_ENC LV_TXT_ENC_UTF8 + + /*Can break (wrap) texts on these chars*/ +#define LV_TXT_BREAK_CHARS " ,.;:-_" + +/*If a word is at least this long, will break wherever "prettiest" + *To disable, set to a value <= 0*/ +#define LV_TXT_LINE_BREAK_LONG_LEN 0 + +/*Minimum number of characters in a long word to put on a line before a break. + *Depends on LV_TXT_LINE_BREAK_LONG_LEN.*/ +#define LV_TXT_LINE_BREAK_LONG_PRE_MIN_LEN 3 + +/*Minimum number of characters in a long word to put on a line after a break. + *Depends on LV_TXT_LINE_BREAK_LONG_LEN.*/ +#define LV_TXT_LINE_BREAK_LONG_POST_MIN_LEN 3 + +/*The control character to use for signalling text recoloring.*/ +#define LV_TXT_COLOR_CMD "#" + +/*Support bidirectional texts. Allows mixing Left-to-Right and Right-to-Left texts. + *The direction will be processed according to the Unicode Bidirectioanl Algorithm: + *https://www.w3.org/International/articles/inline-bidi-markup/uba-basics*/ +#define LV_USE_BIDI 1 +#if LV_USE_BIDI +/*Set the default direction. Supported values: + *`LV_BIDI_DIR_LTR` Left-to-Right + *`LV_BIDI_DIR_RTL` Right-to-Left + *`LV_BIDI_DIR_AUTO` detect texts base direction*/ +#define LV_BIDI_BASE_DIR_DEF LV_BASE_DIR_AUTO +#endif + +/*Enable Arabic/Persian processing + *In these languages characters should be replaced with an other form based on their position in the text*/ +#define LV_USE_ARABIC_PERSIAN_CHARS 1 + +/*================== + * WIDGET USAGE + *================*/ + +/*Documentation of the widgets: https://docs.lvgl.io/latest/en/html/widgets/index.html*/ + +#define LV_USE_ARC 1 + +#define LV_USE_BAR 1 + +#define LV_USE_BTN 1 + +#define LV_USE_BTNMATRIX 1 + +#define LV_USE_CANVAS 1 + +#define LV_USE_CHECKBOX 1 + +#define LV_USE_CHART 1 + +#define LV_USE_DROPDOWN 1 /*Requires: lv_label*/ + +#define LV_USE_IMG 1 /*Requires: lv_label*/ + +#define LV_USE_LABEL 1 +#if LV_USE_LABEL +# define LV_LABEL_TEXT_SEL 1 /*Enable selecting text of the label*/ +# define LV_LABEL_LONG_TXT_HINT 1 /*Store some extra info in labels to speed up drawing of very long texts*/ +#endif + +#define LV_USE_LINE 1 + +#define LV_USE_METER 1 + +#define LV_USE_ROLLER 1 /*Requires: lv_label*/ +#if LV_USE_ROLLER +# define LV_ROLLER_INF_PAGES 7 /*Number of extra "pages" when the roller is infinite*/ +#endif + +#define LV_USE_SLIDER 1 /*Requires: lv_bar*/ + +#define LV_USE_SWITCH 1 + +#define LV_USE_TEXTAREA 1 /*Requires: lv_label*/ +#if LV_USE_TEXTAREA != 0 +# define LV_TEXTAREA_DEF_PWD_SHOW_TIME 1500 /*ms*/ +#endif + +#define LV_USE_TABLE 1 + +/*================== + * EXTRA COMPONENTS + *==================*/ + +/*----------- + * Widgets + *----------*/ +#define LV_USE_CALENDAR 1 +#if LV_USE_CALENDAR +# define LV_CALENDAR_WEEK_STARTS_MONDAY 0 +# if LV_CALENDAR_WEEK_STARTS_MONDAY +# define LV_CALENDAR_DEFAULT_DAY_NAMES {"Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"} +# else +# define LV_CALENDAR_DEFAULT_DAY_NAMES {"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"} +# endif + +# define LV_CALENDAR_DEFAULT_MONTH_NAMES {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"} +# define LV_USE_CALENDAR_HEADER_ARROW 1 +# define LV_USE_CALENDAR_HEADER_DROPDOWN 1 +#endif /*LV_USE_CALENDAR*/ + +#define LV_USE_COLORWHEEL 1 + +#define LV_USE_IMGBTN 1 + +#define LV_USE_KEYBOARD 1 + +#define LV_USE_LED 1 + +#define LV_USE_LIST 1 + +#define LV_USE_MSGBOX 1 + +#define LV_USE_SPINBOX 1 + +#define LV_USE_SPINNER 1 + +#define LV_USE_TABVIEW 1 + +#define LV_USE_TILEVIEW 1 + +#define LV_USE_WIN 1 + +/*----------- + * Themes + *----------*/ +/*A simple, impressive and very complete theme*/ +#define LV_USE_THEME_DEFAULT 1 +#if LV_USE_THEME_DEFAULT + +/*1: Light mode; 0: Dark mode*/ +# define LV_THEME_DEFAULT_PALETTE_LIGHT 1 + +/*1: Enable grow on press*/ +# define LV_THEME_DEFAULT_GROW 1 + +/*Default transition time in [ms]*/ +# define LV_THEME_DEFAULT_TRANSITON_TIME 80 +#endif /*LV_USE_THEME_DEFAULT*/ + + /*An very simple them that is a good starting point for a custom theme*/ + #define LV_USE_THEME_BASIC 1 + +/*----------- + * Layouts + *----------*/ +#define LV_USE_FLEX 1 +#define LV_USE_GRID 1 + +/*--------------------- + * 3rd party libraries + *--------------------*/ + +/*File system interfaces for common APIs + *To enable set a driver letter for that API*/ +#define LV_USE_FS_STDIO 'A' /*Uses fopen, fread, etc*/ +#define LV_USE_FS_POSIX '\0' /*Uses open, read, etc*/ +#define LV_USE_FS_FATFS '\0' /*Uses f_open, F_read, etc*/ + +/*PNG decoder library*/ +#define LV_USE_PNG 1 + +/*BMP decoder library*/ +#define LV_USE_BMP 1 + +/* JPG + Split JPG decoder library. + * Split JPG is a custom format optimized for embedded systems. */ +#define LV_USE_SJPG 1 + +/*GIF decoder library*/ +#define LV_USE_GIF 1 + +/*QR code library*/ +#define LV_USE_QRCODE 1 + +#define LV_USE_FREETYPE 0 +#if LV_USE_FREETYPE +/*Memory used by FreeType to cache characters [bytes]*/ +# define LV_FREETYPE_CACHE_SIZE (16 * 1024) +#endif + +/*----------- + * Others + *----------*/ + +/*1: Enable API to take snapshot for object*/ +#define LV_USE_SNAPSHOT 1 + +/*1: Enable Monkey test*/ +#define LV_USE_MONKEY 1 + +/*1: Enable grid navigation*/ +#define LV_USE_GRIDNAV 1 + +/*1: Enable lv_obj fragment*/ +#define LV_USE_FRAGMENT 1 + +/*1: Enable a published subscriber based messaging system */ +#define LV_USE_MSG 1 + +/*1: Enable Pinyin input method*/ +/*Requires: lv_keyboard*/ +#define LV_USE_IME_PINYIN 0 +#if LV_USE_IME_PINYIN + /*1: Use default thesaurus*/ + /*If you do not use the default thesaurus, be sure to use `lv_ime_pinyin` after setting the thesauruss*/ + #define LV_IME_PINYIN_USE_DEFAULT_DICT 1 + /*Set the maximum number of candidate panels that can be displayed*/ + /*This needs to be adjusted according to the size of the screen*/ + #define LV_IME_PINYIN_CAND_TEXT_NUM 6 + + /*Use 9-key input(k9)*/ + #define LV_IME_PINYIN_USE_K9_MODE 1 + #if LV_IME_PINYIN_USE_K9_MODE == 1 + #define LV_IME_PINYIN_K9_CAND_TEXT_NUM 3 + #endif // LV_IME_PINYIN_USE_K9_MODE +#endif + +/*1: Enable Pinyin input method*/ +/*Requires: lv_table*/ +#define LV_USE_FILE_EXPLORER 1 +#if LV_USE_FILE_EXPLORER + /*Maximum length of path*/ + #define LV_FILE_EXPLORER_PATH_MAX_LEN (128) + /*Quick access bar, 1:use, 0:not use*/ + /*Requires: lv_list*/ + #define LV_FILE_EXPLORER_QUICK_ACCESS 1 +#endif + +/* Built-in TTF decoder */ +#define LV_USE_TINY_TTF 1 +#if LV_USE_TINY_TTF + /* Enable loading TTF data from files */ + #define LV_TINY_TTF_FILE_SUPPORT 1 +#endif + +/*================== +* EXAMPLES +*==================*/ + +/*Enable the examples to be built with the library*/ +#define LV_BUILD_EXAMPLES 1 + +/*=================== + * DEMO USAGE + ====================*/ + +/*Show some widget*/ +#define LV_USE_DEMO_WIDGETS 1 +#if LV_USE_DEMO_WIDGETS +#define LV_DEMO_WIDGETS_SLIDESHOW 0 +#endif + +/*Demonstrate the usage of encoder and keyboard*/ +#define LV_USE_DEMO_KEYPAD_AND_ENCODER 1 + +/*Benchmark your system*/ +#define LV_USE_DEMO_BENCHMARK 1 + +/*Stress test for LVGL*/ +#define LV_USE_DEMO_STRESS 1 + +/*Music player demo*/ +#define LV_USE_DEMO_MUSIC 1 +#if LV_USE_DEMO_MUSIC +# define LV_DEMO_MUSIC_SQUARE 0 +# define LV_DEMO_MUSIC_LANDSCAPE 1 +# define LV_DEMO_MUSIC_ROUND 0 +# define LV_DEMO_MUSIC_LARGE 0 +# define LV_DEMO_MUSIC_AUTO_PLAY 0 +#endif + +/*--END OF LV_CONF_H--*/ + +#endif /*LV_CONF_H*/ + +#endif /*End of "Content enable"*/ diff --git a/lv_drv_conf.h b/lv_drv_conf.h new file mode 100644 index 0000000..66c7cc5 --- /dev/null +++ b/lv_drv_conf.h @@ -0,0 +1,229 @@ +/** + * @file lv_drv_conf.h + * + */ + +/* + * COPY THIS FILE AS lv_drv_conf.h + */ + +#if 1 /*Set it to "1" to enable the content*/ + +#ifndef LV_DRV_CONF_H +#define LV_DRV_CONF_H + +#include "lv_conf.h" + +/********************* + * DELAY INTERFACE + *********************/ +#define LV_DRV_DELAY_INCLUDE /*Dummy include by default*/ +#define LV_DRV_DELAY_US(us) /*delay_us(us)*/ /*Delay the given number of microseconds*/ +#define LV_DRV_DELAY_MS(ms) /*delay_ms(ms)*/ /*Delay the given number of milliseconds*/ + +/********************* + * DISPLAY INTERFACE + *********************/ + +/*------------ + * Common + *------------*/ +#define LV_DRV_DISP_INCLUDE /*Dummy include by default*/ +#define LV_DRV_DISP_CMD_DATA(val) /*pin_x_set(val)*/ /*Set the command/data pin to 'val'*/ +#define LV_DRV_DISP_RST(val) /*pin_x_set(val)*/ /*Set the reset pin to 'val'*/ + +/*--------- + * SPI + *---------*/ +#define LV_DRV_DISP_SPI_CS(val) /*spi_cs_set(val)*/ /*Set the SPI's Chip select to 'val'*/ +#define LV_DRV_DISP_SPI_WR_BYTE(data) /*spi_wr(data)*/ /*Write a byte the SPI bus*/ +#define LV_DRV_DISP_SPI_WR_ARRAY(adr, n) /*spi_wr_mem(adr, n)*/ /*Write 'n' bytes to SPI bus from 'adr'*/ + +/*------------------ + * Parallel port + *-----------------*/ +#define LV_DRV_DISP_PAR_CS(val) /*par_cs_set(val)*/ /*Set the Parallel port's Chip select to 'val'*/ +#define LV_DRV_DISP_PAR_SLOW /*par_slow()*/ /*Set low speed on the parallel port*/ +#define LV_DRV_DISP_PAR_FAST /*par_fast()*/ /*Set high speed on the parallel port*/ +#define LV_DRV_DISP_PAR_WR_WORD(data) /*par_wr(data)*/ /*Write a word to the parallel port*/ +#define LV_DRV_DISP_PAR_WR_ARRAY(adr, n) /*par_wr_mem(adr,n)*/ /*Write 'n' bytes to Parallel ports from 'adr'*/ + +/*************************** + * INPUT DEVICE INTERFACE + ***************************/ + +/*---------- + * Common + *----------*/ +#define LV_DRV_INDEV_INCLUDE /*Dummy include by default*/ +#define LV_DRV_INDEV_RST(val) /*pin_x_set(val)*/ /*Set the reset pin to 'val'*/ +#define LV_DRV_INDEV_IRQ_READ 0 /*pn_x_read()*/ /*Read the IRQ pin*/ + +/*--------- + * SPI + *---------*/ +#define LV_DRV_INDEV_SPI_CS(val) /*spi_cs_set(val)*/ /*Set the SPI's Chip select to 'val'*/ +#define LV_DRV_INDEV_SPI_XCHG_BYTE(data) 0 /*spi_xchg(val)*/ /*Write 'val' to SPI and give the read value*/ + +/*--------- + * I2C + *---------*/ +#define LV_DRV_INDEV_I2C_START /*i2c_start()*/ /*Make an I2C start*/ +#define LV_DRV_INDEV_I2C_STOP /*i2c_stop()*/ /*Make an I2C stop*/ +#define LV_DRV_INDEV_I2C_RESTART /*i2c_restart()*/ /*Make an I2C restart*/ +#define LV_DRV_INDEV_I2C_WR(data) /*i2c_wr(data)*/ /*Write a byte to the I1C bus*/ +#define LV_DRV_INDEV_I2C_READ(last_read) 0 /*i2c_rd()*/ /*Read a byte from the I2C bud*/ + + +/********************* + * DISPLAY DRIVERS + *********************/ + +extern int monitor_hor_res, monitor_ver_res; + +/*------------------- + * Monitor of PC + *-------------------*/ +#define USE_MONITOR 1 +#if USE_MONITOR +#define MONITOR_HOR_RES monitor_hor_res +#define MONITOR_VER_RES monitor_ver_res +#define MONITOR_ZOOM 1 /* Scale window by this factor (useful when simulating small screens) */ +#define MONITOR_SDL_INCLUDE_PATH /*Eclipse: Visual Studio: */ +#define MONITOR_VIRTUAL_MACHINE 1 /*Different rendering should be used if running in a Virtual machine*/ +#endif + +/*---------------- + * SSD1963 + *--------------*/ +#define USE_SSD1963 0 +#if USE_SSD1963 +#define SSD1963_HOR_RES LV_HOR_RES +#define SSD1963_VER_RES LV_VER_RES +#define SSD1963_HT 531 +#define SSD1963_HPS 43 +#define SSD1963_LPS 8 +#define SSD1963_HPW 10 +#define SSD1963_VT 288 +#define SSD1963_VPS 12 +#define SSD1963_FPS 4 +#define SSD1963_VPW 10 +#define SSD1963_HS_NEG 0 /*Negative hsync*/ +#define SSD1963_VS_NEG 0 /*Negative vsync*/ +#define SSD1963_ORI 0 /*0, 90, 180, 270*/ +#define SSD1963_COLOR_DEPTH 16 +#endif + +/*---------------- + * R61581 + *--------------*/ +#define USE_R61581 0 +#if USE_R61581 != 0 +#define R61581_HOR_RES LV_HOR_RES +#define R61581_VER_RES LV_VER_RES +#define R61581_HSPL 0 /*HSYNC signal polarity*/ +#define R61581_HSL 10 /*HSYNC length (Not Implemented)*/ +#define R61581_HFP 10 /*Horitontal Front poarch (Not Implemented)*/ +#define R61581_HBP 10 /*Horitontal Back poarch (Not Implemented */ +#define R61581_VSPL 0 /*VSYNC signal polarity*/ +#define R61581_VSL 10 /*VSYNC length (Not Implemented)*/ +#define R61581_VFP 8 /*Vertical Front poarch*/ +#define R61581_VBP 8 /*Vertical Back poarch */ +#define R61581_DPL 0 /*DCLK signal polarity*/ +#define R61581_EPL 1 /*ENABLE signal polarity*/ +#define R61581_ORI 0 /*0, 180*/ +#define R61581_LV_COLOR_DEPTH 16 /*Fix 16 bit*/ +#endif + +/*------------------------------ + * ST7565 (Monochrome, low res.) + *-----------------------------*/ +#define USE_ST7565 0 +#if USE_ST7565 != 0 +/*No settings*/ +#endif /*USE_ST7565*/ + +/*----------------------------------------- + * Linux frame buffer device (/dev/fbx) + *-----------------------------------------*/ +#define USE_FBDEV 0 +#if USE_FBDEV != 0 +#define FBDEV_PATH "/dev/fb0" +#endif + +/********************* + * INPUT DEVICES + *********************/ + +/*-------------- + * XPT2046 + *--------------*/ +#define USE_XPT2046 0 +#if USE_XPT2046 != 0 +#define XPT2046_HOR_RES 480 +#define XPT2046_VER_RES 320 +#define XPT2046_X_MIN 200 +#define XPT2046_Y_MIN 200 +#define XPT2046_X_MAX 3800 +#define XPT2046_Y_MAX 3800 +#define XPT2046_AVG 4 +#define XPT2046_INV 0 +#endif + +/*----------------- + * FT5406EE8 + *-----------------*/ +#define USE_FT5406EE8 0 +#if USE_FT5406EE8 +#define FT5406EE8_I2C_ADR 0x38 /*7 bit address*/ +#endif + +/*--------------- + * AD TOUCH + *--------------*/ +#define USE_AD_TOUCH 0 +#if USE_AD_TOUCH != 0 +/*No settings*/ +#endif + + +/*--------------------------------------- + * Mouse or touchpad on PC (using SDL) + *-------------------------------------*/ +#define USE_MOUSE 1 +#if USE_MOUSE +/*No settings*/ +#endif + +/*------------------------------------------- + * Mousewheel as encoder on PC (using SDL) + *------------------------------------------*/ +#define USE_MOUSEWHEEL 1 +#if USE_MOUSEWHEEL +/*No settings*/ +#endif + +/*------------------------------------------------- + * Mouse or touchpad as evdev interface (for Linux based systems) + *------------------------------------------------*/ +#define USE_EVDEV 0 +#if USE_EVDEV +#define EVDEV_NAME "/dev/input/event0" /*You can use the "evtest" Linux tool to get the list of devices and test them*/ +#define SCALE_EVDEV 0 /* Scale input, e.g. if touchscreen resolution does not match display resolution */ +#if SCALE_EVDEV +#define SCALE_EVDEV_HOR_RES (4096) /* Horizontal resolution of touchscreen */ +#define SCALE_EVDEV_VER_RES (4096) /* Vertical resolution of touchscreen */ +#endif +#endif + +/*------------------------------- + * Keyboard of a PC (using SDL) + *------------------------------*/ +#define USE_KEYBOARD 1 +#if USE_KEYBOARD +/*No settings*/ +#endif + +#endif /*LV_DRV_CONF_H*/ + +#endif /*End of "Content enable"*/ diff --git a/lvgl_shell.html b/lvgl_shell.html new file mode 100644 index 0000000..a1d3ca6 --- /dev/null +++ b/lvgl_shell.html @@ -0,0 +1,65 @@ + + + + + + +
+

+ +

+ + {{{ SCRIPT }}} + + diff --git a/main.c b/main.c new file mode 100644 index 0000000..925d673 --- /dev/null +++ b/main.c @@ -0,0 +1,175 @@ + +/** + * @file main + * + */ + +/********************* + * INCLUDES + *********************/ +#include +#include +#define SDL_MAIN_HANDLED /*To fix SDL's "undefined reference to WinMain" issue*/ +#include +#include +#include "lvgl/lvgl.h" +#include "lv_drivers/display/monitor.h" +#include "lv_drivers/indev/mouse.h" +#include "lv_drivers/indev/mousewheel.h" +#include "lv_drivers/indev/keyboard.h" + +#include "src/flow.h" +#include "src/ui/screens.h" + +/********************* + * DEFINES + *********************/ + +/*On OSX SDL needs different handling*/ +#if defined(__APPLE__) && defined(TARGET_OS_MAC) +# if __APPLE__ && TARGET_OS_MAC +#define SDL_APPLE +# endif +#endif + +/********************** + * TYPEDEFS + **********************/ + +/********************** + * STATIC PROTOTYPES + **********************/ +static void hal_init(void); +static int tick_thread(void * data); +static void memory_monitor(lv_timer_t * param); + +/********************** + * STATIC VARIABLES + **********************/ +static lv_disp_t * disp1; + +int monitor_hor_res, monitor_ver_res; + +/********************** + * MACROS + **********************/ + +/********************** + * GLOBAL FUNCTIONS + **********************/ +void do_loop(void *arg); + +int main(int argc, char ** argv) +{ + monitor_hor_res = atoi(argv[1]); + monitor_ver_res = atoi(argv[2]); + printf("Starting with screen resolution of %dx%d px\n", monitor_hor_res, monitor_ver_res); + + /*Initialize LittlevGL*/ + lv_init(); + + /*Initialize the HAL (display, input devices, tick) for LittlevGL*/ + hal_init(); + + /*Init*/ + flowInit(); + + emscripten_set_main_loop_arg(do_loop, NULL, -1, true); +} + +void do_loop(void *arg) +{ + /* Periodically call the lv_task handler. + * It could be done in a timer interrupt or an OS task too.*/ + lv_task_handler(); + + flowTick(); + + SDL_Event event; + + while(SDL_PollEvent(&event)) { + #if USE_MOUSE != 0 + mouse_handler(&event); + #endif + + #if USE_KEYBOARD + keyboard_handler(&event); + #endif + +#if USE_MOUSEWHEEL != 0 + mousewheel_handler(&event); +#endif + } + +} + +/********************** + * STATIC FUNCTIONS + **********************/ + + +/** + * Initialize the Hardware Abstraction Layer (HAL) for the Littlev graphics library + */ +static void hal_init(void) +{ + /* Use the 'monitor' driver which creates window on PC's monitor to simulate a display*/ + monitor_init(); + + /*Create a display buffer*/ + static lv_disp_draw_buf_t disp_buf1; + lv_color_t * buf1_1 = malloc(sizeof(lv_color_t) * monitor_hor_res * monitor_ver_res); + lv_disp_draw_buf_init(&disp_buf1, buf1_1, NULL, monitor_hor_res * monitor_ver_res); + + /*Create a display*/ + static lv_disp_drv_t disp_drv; + lv_disp_drv_init(&disp_drv); /*Basic initialization*/ + disp_drv.draw_buf = &disp_buf1; + disp_drv.flush_cb = monitor_flush; /*Used when `LV_VDB_SIZE != 0` in lv_conf.h (buffered drawing)*/ + disp_drv.hor_res = monitor_hor_res; + disp_drv.ver_res = monitor_ver_res; + disp1 = lv_disp_drv_register(&disp_drv); + + //lv_group_t * g = lv_group_create(); + //lv_group_set_default(g); + + /* Add the mouse as input device + * Use the 'mouse' driver which reads the PC's mouse*/ + mouse_init(); + static lv_indev_drv_t indev_drv_1; + lv_indev_drv_init(&indev_drv_1); /*Basic initialization*/ + indev_drv_1.type = LV_INDEV_TYPE_POINTER; + + /*This function will be called periodically (by the library) to get the mouse position and state*/ + indev_drv_1.read_cb = mouse_read; + lv_indev_t *mouse_indev = lv_indev_drv_register(&indev_drv_1); + + keyboard_init(); + static lv_indev_drv_t indev_drv_2; + lv_indev_drv_init(&indev_drv_2); /*Basic initialization*/ + indev_drv_2.type = LV_INDEV_TYPE_KEYPAD; + indev_drv_2.read_cb = keyboard_read; + lv_indev_t *kb_indev = lv_indev_drv_register(&indev_drv_2); + //lv_indev_set_group(kb_indev, g); + mousewheel_init(); + static lv_indev_drv_t indev_drv_3; + lv_indev_drv_init(&indev_drv_3); /*Basic initialization*/ + indev_drv_3.type = LV_INDEV_TYPE_ENCODER; + indev_drv_3.read_cb = mousewheel_read; + + lv_indev_t * enc_indev = lv_indev_drv_register(&indev_drv_3); + //lv_indev_set_group(enc_indev, g); + + /* Optional: + * Create a memory monitor task which prints the memory usage in periodically.*/ + lv_timer_create(memory_monitor, 3000, NULL); +} + +/** + * Print the memory usage periodically + * @param param + */ +static void memory_monitor(lv_timer_t * param) +{ + (void) param; /*Unused*/ +} diff --git a/mouse_cursor_icon.c b/mouse_cursor_icon.c new file mode 100644 index 0000000..cf82f01 --- /dev/null +++ b/mouse_cursor_icon.c @@ -0,0 +1,104 @@ +#include "lvgl/lvgl.h" + +const uint8_t mouse_cursor_icon_map[] = { +#if LV_COLOR_DEPTH == 1 || LV_COLOR_DEPTH == 8 + /*Pixel format: Alpha 8 bit, Red: 3 bit, Green: 3 bit, Blue: 2 bit*/ + 0x24, 0xb8, 0x24, 0xc8, 0x00, 0x13, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x49, 0xcc, 0xdb, 0xff, 0x49, 0xcc, 0x00, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x49, 0xc8, 0xff, 0xff, 0xff, 0xff, 0x49, 0xe0, 0x00, 0x3b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x49, 0xcb, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0x6d, 0xf3, 0x00, 0x4f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x49, 0xcb, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x92, 0xff, 0x00, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x49, 0xcb, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x92, 0xff, 0x00, 0x90, 0x00, 0x00, 0x00, 0x00, 0xb6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x49, 0xcb, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xb7, 0xff, 0x24, 0xab, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x49, 0xcb, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xdb, 0xff, 0x24, 0xbb, 0x00, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x49, 0xcc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xdb, 0xff, 0x49, 0xd8, 0x00, 0x37, 0x00, 0x00, 0x00, 0x00, + 0x49, 0xcc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x6d, 0xef, 0x00, 0x4f, 0x00, 0x00, + 0x49, 0xcc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x92, 0xff, 0x00, 0x6b, + 0x49, 0xcc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xdb, 0xff, 0x92, 0xf7, 0x92, 0xf8, 0x6e, 0xfb, 0x92, 0xf8, 0x6d, 0xff, 0x00, 0xb3, + 0x49, 0xcc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xdb, 0xff, 0x24, 0xb7, 0x00, 0x1b, 0x00, 0x14, 0x00, 0x13, 0x00, 0x0c, 0x25, 0x07, + 0x49, 0xcc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x6d, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x6e, 0xf0, 0x00, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x49, 0xcc, 0xff, 0xff, 0xff, 0xff, 0x49, 0xd8, 0x00, 0x78, 0x92, 0xfb, 0xff, 0xff, 0xff, 0xff, 0xdb, 0xff, 0x00, 0x8b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x6d, 0xd3, 0xff, 0xff, 0x6d, 0xef, 0x00, 0x34, 0x00, 0x00, 0x49, 0xc7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x6d, 0xdc, 0x00, 0x14, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, + 0x49, 0xe0, 0x6d, 0xff, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x57, 0x92, 0xff, 0xff, 0xff, 0xff, 0xff, 0xb7, 0xff, 0x00, 0x78, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, + 0x00, 0x68, 0x00, 0x4f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x49, 0xd0, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0x6d, 0xd8, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6f, 0xb7, 0xff, 0xff, 0xff, 0x92, 0xff, 0x49, 0xac, 0x00, 0x17, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x25, 0xd7, 0x49, 0xc7, 0x00, 0x47, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +#endif +#if LV_COLOR_DEPTH == 16 && LV_COLOR_16_SWAP == 0 + /*Pixel format: Alpha 8 bit, Red: 5 bit, Green: 6 bit, Blue: 5 bit*/ + 0xc3, 0x18, 0xb8, 0xe4, 0x20, 0xc8, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x49, 0x4a, 0xcc, 0x96, 0xb5, 0xff, 0xc7, 0x39, 0xcc, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xe7, 0x39, 0xc8, 0xbf, 0xff, 0xff, 0xfb, 0xde, 0xff, 0x28, 0x42, 0xe0, 0x00, 0x00, 0x3b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xe7, 0x39, 0xcb, 0x3d, 0xef, 0xff, 0xff, 0xff, 0xfc, 0x3d, 0xef, 0xff, 0xcb, 0x5a, 0xf3, 0x00, 0x00, 0x4f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xe7, 0x39, 0xcb, 0x5d, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xbf, 0xff, 0xff, 0x8e, 0x73, 0xff, 0x00, 0x00, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xe8, 0x41, 0xcb, 0x5d, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x51, 0x8c, 0xff, 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd3, 0x9c, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xe8, 0x41, 0xcb, 0x5d, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x14, 0xa5, 0xff, 0xa2, 0x10, 0xab, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x08, 0x42, 0xcb, 0x5d, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xd7, 0xbd, 0xff, 0x04, 0x21, 0xbb, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x08, 0x42, 0xcc, 0x5d, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x59, 0xce, 0xff, 0xe8, 0x41, 0xd8, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x08, 0x42, 0xcc, 0x5d, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xe6, 0xff, 0xab, 0x5a, 0xef, 0x00, 0x00, 0x4f, 0x00, 0x00, 0x00, + 0x08, 0x42, 0xcc, 0x5d, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xbe, 0xf7, 0xff, 0xaf, 0x7b, 0xff, 0x00, 0x00, 0x6b, + 0x28, 0x42, 0xcc, 0x5d, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7a, 0xd6, 0xff, 0x10, 0x84, 0xf7, 0xae, 0x73, 0xf8, 0x6e, 0x73, 0xfb, 0x8e, 0x73, 0xf8, 0xcb, 0x5a, 0xff, 0x61, 0x08, 0xb3, + 0x28, 0x42, 0xcc, 0x7d, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x59, 0xce, 0xff, 0xa2, 0x10, 0xb7, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x14, 0x00, 0x00, 0x13, 0x00, 0x00, 0x0c, 0x45, 0x29, 0x07, + 0x29, 0x4a, 0xcc, 0x5d, 0xef, 0xff, 0xff, 0xff, 0xff, 0xdb, 0xde, 0xff, 0xec, 0x62, 0xff, 0x1c, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0c, 0x63, 0xf0, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x29, 0x4a, 0xcc, 0xdf, 0xff, 0xff, 0x7d, 0xef, 0xff, 0x49, 0x4a, 0xd8, 0x00, 0x00, 0x78, 0x51, 0x8c, 0xfb, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x38, 0xc6, 0xff, 0x00, 0x00, 0x8b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xcb, 0x5a, 0xd3, 0xdb, 0xde, 0xff, 0xec, 0x62, 0xef, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0xe7, 0x39, 0xc7, 0x5d, 0xef, 0xff, 0xff, 0xff, 0xff, 0xbe, 0xf7, 0xff, 0xaa, 0x52, 0xdc, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0xe8, 0x41, 0xe0, 0xaa, 0x52, 0xff, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x57, 0x72, 0x94, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x96, 0xb5, 0xff, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x61, 0x08, 0x04, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x68, 0x00, 0x00, 0x4f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x69, 0x4a, 0xd0, 0x7d, 0xef, 0xff, 0xff, 0xff, 0xfc, 0xbe, 0xf7, 0xff, 0xaa, 0x52, 0xd8, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe4, 0x20, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6f, 0x75, 0xad, 0xff, 0xbf, 0xff, 0xff, 0x10, 0x84, 0xff, 0x86, 0x31, 0xac, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x41, 0x08, 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x66, 0x31, 0xd7, 0xc7, 0x39, 0xc7, 0x00, 0x00, 0x47, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +#endif +#if LV_COLOR_DEPTH == 16 && LV_COLOR_16_SWAP != 0 + /*Pixel format: Alpha 8 bit, Red: 5 bit, Green: 6 bit, Blue: 5 bit BUT the 2 color bytes are swapped*/ + 0x18, 0xc3, 0xb8, 0x20, 0xe4, 0xc8, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x4a, 0x49, 0xcc, 0xb5, 0x96, 0xff, 0x39, 0xc7, 0xcc, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x39, 0xe7, 0xc8, 0xff, 0xbf, 0xff, 0xde, 0xfb, 0xff, 0x42, 0x28, 0xe0, 0x00, 0x00, 0x3b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x39, 0xe7, 0xcb, 0xef, 0x3d, 0xff, 0xff, 0xff, 0xfc, 0xef, 0x3d, 0xff, 0x5a, 0xcb, 0xf3, 0x00, 0x00, 0x4f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x39, 0xe7, 0xcb, 0xef, 0x5d, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xbf, 0xff, 0x73, 0x8e, 0xff, 0x00, 0x00, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x41, 0xe8, 0xcb, 0xef, 0x5d, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x8c, 0x51, 0xff, 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9c, 0xd3, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x41, 0xe8, 0xcb, 0xef, 0x5d, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xa5, 0x14, 0xff, 0x10, 0xa2, 0xab, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x42, 0x08, 0xcb, 0xef, 0x5d, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xbd, 0xd7, 0xff, 0x21, 0x04, 0xbb, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x42, 0x08, 0xcc, 0xef, 0x5d, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xce, 0x59, 0xff, 0x41, 0xe8, 0xd8, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x42, 0x08, 0xcc, 0xef, 0x5d, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe6, 0xfc, 0xff, 0x5a, 0xab, 0xef, 0x00, 0x00, 0x4f, 0x00, 0x00, 0x00, + 0x42, 0x08, 0xcc, 0xef, 0x5d, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf7, 0xbe, 0xff, 0x7b, 0xaf, 0xff, 0x00, 0x00, 0x6b, + 0x42, 0x28, 0xcc, 0xef, 0x5d, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xd6, 0x7a, 0xff, 0x84, 0x10, 0xf7, 0x73, 0xae, 0xf8, 0x73, 0x6e, 0xfb, 0x73, 0x8e, 0xf8, 0x5a, 0xcb, 0xff, 0x08, 0x61, 0xb3, + 0x42, 0x28, 0xcc, 0xef, 0x7d, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xce, 0x59, 0xff, 0x10, 0xa2, 0xb7, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x14, 0x00, 0x00, 0x13, 0x00, 0x00, 0x0c, 0x29, 0x45, 0x07, + 0x4a, 0x29, 0xcc, 0xef, 0x5d, 0xff, 0xff, 0xff, 0xff, 0xde, 0xdb, 0xff, 0x62, 0xec, 0xff, 0xe7, 0x1c, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x63, 0x0c, 0xf0, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x4a, 0x29, 0xcc, 0xff, 0xdf, 0xff, 0xef, 0x7d, 0xff, 0x4a, 0x49, 0xd8, 0x00, 0x00, 0x78, 0x8c, 0x51, 0xfb, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc6, 0x38, 0xff, 0x00, 0x00, 0x8b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x5a, 0xcb, 0xd3, 0xde, 0xdb, 0xff, 0x62, 0xec, 0xef, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x39, 0xe7, 0xc7, 0xef, 0x5d, 0xff, 0xff, 0xff, 0xff, 0xf7, 0xbe, 0xff, 0x52, 0xaa, 0xdc, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x41, 0xe8, 0xe0, 0x52, 0xaa, 0xff, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x57, 0x94, 0x72, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xb5, 0x96, 0xff, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x08, 0x61, 0x04, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x68, 0x00, 0x00, 0x4f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x4a, 0x69, 0xd0, 0xef, 0x7d, 0xff, 0xff, 0xff, 0xfc, 0xf7, 0xbe, 0xff, 0x52, 0xaa, 0xd8, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0xe4, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6f, 0xad, 0x75, 0xff, 0xff, 0xbf, 0xff, 0x84, 0x10, 0xff, 0x31, 0x86, 0xac, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x08, 0x41, 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x31, 0x66, 0xd7, 0x39, 0xc7, 0xc7, 0x00, 0x00, 0x47, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +#endif +#if LV_COLOR_DEPTH == 32 + 0x19, 0x19, 0x19, 0xb8, 0x1e, 0x1e, 0x1e, 0xc8, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x48, 0x48, 0x48, 0xcc, 0xb2, 0xb2, 0xb2, 0xff, 0x3a, 0x3a, 0x3a, 0xcc, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x0a, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x3b, 0x3b, 0x3b, 0xc8, 0xf6, 0xf6, 0xf6, 0xff, 0xdc, 0xdc, 0xdc, 0xff, 0x43, 0x43, 0x43, 0xe0, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x0a, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x3b, 0x3b, 0x3b, 0xcb, 0xe6, 0xe6, 0xe6, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xe5, 0xe5, 0xe5, 0xff, 0x59, 0x59, 0x59, 0xf3, 0x00, 0x00, 0x00, 0x4f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x3c, 0x3c, 0x3c, 0xcb, 0xe9, 0xe9, 0xe9, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf5, 0xf5, 0xf5, 0xff, 0x72, 0x72, 0x72, 0xff, 0x00, 0x00, 0x00, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x3d, 0x3d, 0x3d, 0xcb, 0xe9, 0xe9, 0xe9, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x8a, 0x8a, 0x8a, 0xff, 0x00, 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x99, 0x99, 0x99, 0x00, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x3e, 0x3e, 0x3e, 0xcb, 0xe9, 0xe9, 0xe9, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xfe, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xa2, 0xa2, 0xa2, 0xff, 0x13, 0x13, 0x13, 0xab, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x3f, 0x3f, 0x3f, 0xcb, 0xe9, 0xe9, 0xe9, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xfe, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xb7, 0xb7, 0xb7, 0xff, 0x1f, 0x1f, 0x1f, 0xbb, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x41, 0x41, 0x41, 0xcc, 0xea, 0xea, 0xea, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xfe, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xca, 0xca, 0xca, 0xff, 0x3d, 0x3d, 0x3d, 0xd8, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x41, 0x41, 0x41, 0xcc, 0xea, 0xea, 0xea, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xde, 0xde, 0xde, 0xff, 0x56, 0x56, 0x56, 0xef, 0x00, 0x00, 0x00, 0x4f, 0x00, 0x00, 0x00, 0x00, + 0x42, 0x42, 0x42, 0xcc, 0xea, 0xea, 0xea, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xfe, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0xf3, 0xf3, 0xff, 0x76, 0x76, 0x76, 0xff, 0x00, 0x00, 0x00, 0x6b, + 0x43, 0x43, 0x43, 0xcc, 0xea, 0xea, 0xea, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xce, 0xce, 0xce, 0xff, 0x80, 0x80, 0x80, 0xf7, 0x74, 0x74, 0x74, 0xf8, 0x6d, 0x6d, 0x6d, 0xfb, 0x72, 0x72, 0x72, 0xf8, 0x57, 0x57, 0x57, 0xff, 0x0c, 0x0c, 0x0c, 0xb3, + 0x44, 0x44, 0x44, 0xcc, 0xeb, 0xeb, 0xeb, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xfb, 0xfb, 0xfb, 0xff, 0xfe, 0xfe, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc9, 0xc9, 0xc9, 0xff, 0x13, 0x13, 0x13, 0xb7, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x0c, 0x29, 0x29, 0x29, 0x07, + 0x45, 0x45, 0x45, 0xcc, 0xe8, 0xe8, 0xe8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xd9, 0xd9, 0xd9, 0xff, 0x5e, 0x5e, 0x5e, 0xff, 0xe2, 0xe2, 0xe2, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x62, 0x62, 0x62, 0xf0, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x45, 0x45, 0x45, 0xcc, 0xf9, 0xf9, 0xf9, 0xff, 0xec, 0xec, 0xec, 0xff, 0x4a, 0x4a, 0x4a, 0xd8, 0x00, 0x00, 0x00, 0x78, 0x8a, 0x8a, 0x8a, 0xfb, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc3, 0xc3, 0xc3, 0xff, 0x00, 0x00, 0x00, 0x8b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x58, 0x58, 0x58, 0xd3, 0xd9, 0xd9, 0xd9, 0xff, 0x5e, 0x5e, 0x5e, 0xef, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x00, 0x3b, 0x3b, 0x3b, 0xc7, 0xe9, 0xe9, 0xe9, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf4, 0xf4, 0xf4, 0xff, 0x54, 0x54, 0x54, 0xdc, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, + 0x3e, 0x3e, 0x3e, 0xe0, 0x54, 0x54, 0x54, 0xff, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x57, 0x8e, 0x8e, 0x8e, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xb0, 0xb0, 0xb0, 0xff, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x0c, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, 0x4f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x4c, 0x4c, 0x4c, 0xd0, 0xec, 0xec, 0xec, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xf4, 0xf4, 0xf4, 0xff, 0x53, 0x53, 0x53, 0xd8, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x1e, 0x1e, 0x00, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6f, 0xab, 0xab, 0xab, 0xff, 0xf6, 0xf6, 0xf6, 0xff, 0x80, 0x80, 0x80, 0xff, 0x31, 0x31, 0x31, 0xac, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x09, 0x09, 0x09, 0x03, 0x02, 0x02, 0x02, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x2e, 0x2e, 0x2e, 0xd7, 0x38, 0x38, 0x38, 0xc7, 0x00, 0x00, 0x00, 0x47, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +#endif +}; + +lv_img_dsc_t mouse_cursor_icon = { + .header.always_zero = 0, + .header.w = 14, + .header.h = 20, + .data_size = 280 * LV_IMG_PX_SIZE_ALPHA_BYTE, + .header.cf = LV_IMG_CF_TRUE_COLOR_ALPHA, + .data = mouse_cursor_icon_map, +}; diff --git a/src/conf/eez/conf.h b/src/conf/eez/conf.h new file mode 100644 index 0000000..b63f41d --- /dev/null +++ b/src/conf/eez/conf.h @@ -0,0 +1,11 @@ +#pragma once + +#include + +#define OPTION_KEYBOARD 0 +#define OPTION_MOUSE 0 +#define OPTION_KEYPAD 0 + +#define CUSTOM_VALUE_TYPES + + diff --git a/src/flow.cpp b/src/flow.cpp new file mode 100644 index 0000000..7793798 --- /dev/null +++ b/src/flow.cpp @@ -0,0 +1,167 @@ +#include +#include + +#if HAS_FLOW_SUPPORT +#include +#include + +#include +#include +#include +#include +#include +#include + +#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 get_screen(currentScreen)[index]; +} + +static const void *getLvglImageByName(const char *name) { + printf("getLvglImageByName %s\n", 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(0); + 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(eez::assets, sizeof(eez::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); + + replacePageHook(1, 0, 0, 0); +#else + 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(get_screen(currentScreen)[0], (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 \ No newline at end of file diff --git a/src/flow.h b/src/flow.h new file mode 100644 index 0000000..0ed0639 --- /dev/null +++ b/src/flow.h @@ -0,0 +1,32 @@ +#pragma once + +#include +#include + +#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 diff --git a/src/ui/actions.c b/src/ui/actions.c new file mode 100644 index 0000000..bd22d2f --- /dev/null +++ b/src/ui/actions.c @@ -0,0 +1,7 @@ +#include + +#include "actions.h" +#include "screens.h" +#include "../flow.h" + +// Define native actions here \ No newline at end of file diff --git a/src/ui/actions.h b/src/ui/actions.h new file mode 100644 index 0000000..cbbb38d --- /dev/null +++ b/src/ui/actions.h @@ -0,0 +1,8 @@ +#ifndef EEZ_LVGL_UI_EVENTS_H +#define EEZ_LVGL_UI_EVENTS_H + +#include "lvgl/lvgl.h" + + + +#endif /*EEZ_LVGL_UI_EVENTS_H*/ \ No newline at end of file diff --git a/src/ui/flow_def.cpp b/src/ui/flow_def.cpp new file mode 100644 index 0000000..fa4358a --- /dev/null +++ b/src/ui/flow_def.cpp @@ -0,0 +1,19 @@ +#include "flow_def.h" + +namespace eez { + +// ASSETS DEFINITION +const uint8_t assets[152] = { + 0x7E, 0x65, 0x65, 0x7A, 0x03, 0x00, 0x06, 0x00, 0x08, 0x01, 0x00, 0x00, 0x6E, 0x24, 0x00, 0x00, + 0x00, 0x28, 0x00, 0x01, 0x00, 0x17, 0x38, 0x0C, 0x00, 0xC0, 0x20, 0x03, 0xE0, 0x01, 0x01, 0x00, + 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x08, 0x00, 0x13, 0x54, 0x08, 0x00, 0x97, 0x58, 0x00, 0x00, + 0x00, 0x02, 0x00, 0x00, 0x00, 0xE0, 0x2C, 0x00, 0x13, 0x5C, 0x08, 0x00, 0x53, 0x68, 0x00, 0x00, + 0x00, 0x90, 0x20, 0x00, 0x13, 0x98, 0x30, 0x00, 0x2F, 0x9C, 0x00, 0x01, 0x00, 0x0F, 0xF6, 0x03, + 0x64, 0x65, 0x66, 0x61, 0x75, 0x6C, 0x74, 0x00, 0xFF, 0xFF, 0x08, 0x42, 0xA0, 0x00, 0x00, 0x00, + 0x10, 0x27, 0x1C, 0x00, 0x00, 0x4C, 0x00, 0x13, 0xC0, 0x4C, 0x00, 0xF3, 0x03, 0xC8, 0x00, 0x00, + 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xCC, 0x00, 0x00, 0x00, 0xD0, 0x00, 0x00, 0x00, 0xD4, 0x00, 0x89, + 0x00, 0x1A, 0xE0, 0x50, 0x00, 0x5F, 0xE8, 0x00, 0x00, 0x00, 0xF8, 0x68, 0x00, 0x00, 0x16, 0x01, + 0x0B, 0x00, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00 +}; + +} // namespace eez diff --git a/src/ui/flow_def.h b/src/ui/flow_def.h new file mode 100644 index 0000000..537f624 --- /dev/null +++ b/src/ui/flow_def.h @@ -0,0 +1,23 @@ +#pragma once + +#include +#include + +#include "lvgl/lvgl.h" + +namespace eez { + +enum ThemesEnum { + THEME_ID_DEFAULT = 0 +}; + +enum ColorsEnum { + COLOR_ID_TRANSPARENT = 65535, + COLOR_ID_COLOR = 0, + COLOR_ID_BACKGROUND_COLOR = 1, + COLOR_ID_CUSTOM_UNDEFINED = 2 +}; + +extern const uint8_t assets[152]; + +} // namespace eez diff --git a/src/ui/fonts.h b/src/ui/fonts.h new file mode 100644 index 0000000..13f1721 --- /dev/null +++ b/src/ui/fonts.h @@ -0,0 +1,8 @@ +#ifndef EEZ_LVGL_UI_FONTS_H +#define EEZ_LVGL_UI_FONTS_H + +#include "lvgl/lvgl.h" + + + +#endif /*EEZ_LVGL_UI_FONTS_H*/ \ No newline at end of file diff --git a/src/ui/images.c b/src/ui/images.c new file mode 100644 index 0000000..64e07ce --- /dev/null +++ b/src/ui/images.c @@ -0,0 +1,4 @@ +#include "images.h" + +const ext_img_desc_t images[0] = { +}; diff --git a/src/ui/images.h b/src/ui/images.h new file mode 100644 index 0000000..b77daae --- /dev/null +++ b/src/ui/images.h @@ -0,0 +1,15 @@ +#ifndef EEZ_LVGL_UI_IMAGES_H +#define EEZ_LVGL_UI_IMAGES_H + +#include "lvgl/lvgl.h" + + +typedef struct _ext_img_desc_t { + const char *name; + const lv_img_dsc_t *img_dsc; +} ext_img_desc_t; + +extern const ext_img_desc_t images[0]; + + +#endif /*EEZ_LVGL_UI_IMAGES_H*/ \ No newline at end of file diff --git a/src/ui/screens.c b/src/ui/screens.c new file mode 100644 index 0000000..287b1af --- /dev/null +++ b/src/ui/screens.c @@ -0,0 +1,58 @@ +#include "screens.h" +#include "images.h" +#include "fonts.h" +#include "actions.h" +#include "../flow.h" + +main_t *create_screen_main() { + main_t *screen = (main_t *)lv_mem_alloc(sizeof(main_t)); + lv_obj_t *obj = lv_obj_create(0); + screen->screen_obj = obj; + lv_obj_set_pos(obj, 0, 0); + lv_obj_set_size(obj, 800, 480); + { + lv_obj_t *parent_obj = obj; + { + // label_1 + lv_obj_t *obj = lv_label_create(parent_obj); + screen->obj_label_1 = obj; + lv_obj_set_pos(obj, 356, 232); + lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT); + lv_label_set_text(obj, "Hello, world!"); + } + } + return screen; +} + +void tick_screen_main(main_t *screen) { +} + + +#include + +typedef screen_t (*create_screen_func_t)(); + +create_screen_func_t create_screen_funcs[] = { + (create_screen_func_t)create_screen_main, +}; + +typedef void (*tick_screen_func_t)(screen_t); + +tick_screen_func_t tick_screen_funcs[] = { + (tick_screen_func_t)tick_screen_main, +}; + +screen_t screens[NUM_SCREENS]; + +screen_t get_screen(int screen_index) { + assert(screen_index >= 0 && screen_index < NUM_SCREENS); + if (!screens[screen_index]) { + screens[screen_index] = create_screen_funcs[screen_index](); + } + return screens[screen_index]; +} + +void tick_screen(int screen_index) { + assert(screen_index >= 0 && screen_index < NUM_SCREENS); + tick_screen_funcs[screen_index](get_screen(screen_index)); +} diff --git a/src/ui/screens.h b/src/ui/screens.h new file mode 100644 index 0000000..bebfcb6 --- /dev/null +++ b/src/ui/screens.h @@ -0,0 +1,35 @@ +#ifndef EEZ_LVGL_UI_SCREENS_H +#define EEZ_LVGL_UI_SCREENS_H + +#include "lvgl/lvgl.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct _main_t { + lv_obj_t *screen_obj; + + lv_obj_t *obj_label_1; +} main_t; + +main_t *create_screen_main(); +void tick_screen_main(main_t *screen); + + +typedef lv_obj_t **screen_t; + +enum { + SCREEN_MAIN, + NUM_SCREENS +}; + +screen_t get_screen(int screen_index); +void tick_screen(int screen_index); + + +#ifdef __cplusplus +} +#endif + +#endif /*EEZ_LVGL_UI_SCREENS_H*/ \ No newline at end of file diff --git a/src/ui/vars.c b/src/ui/vars.c new file mode 100644 index 0000000..9449cc9 --- /dev/null +++ b/src/ui/vars.c @@ -0,0 +1,7 @@ +#include + +#include "vars.h" +#include "screens.h" +#include "../flow.h" + +// Define native variables here \ No newline at end of file diff --git a/src/ui/vars.h b/src/ui/vars.h new file mode 100644 index 0000000..ce8c893 --- /dev/null +++ b/src/ui/vars.h @@ -0,0 +1,8 @@ +#ifndef EEZ_LVGL_UI_VARS_H +#define EEZ_LVGL_UI_VARS_H + +#include + + + +#endif /*EEZ_LVGL_UI_VARS_H*/ \ No newline at end of file diff --git a/ui.eez-project b/ui.eez-project new file mode 100644 index 0000000..a544e6a --- /dev/null +++ b/ui.eez-project @@ -0,0 +1,155 @@ +{ + "objID": "6666cd76-f969-5646-9e7b-e39d750cc7d9", + "settings": { + "objID": "e007d988-9fba-797d-72e9-efc33ca6d05c", + "general": { + "objID": "fd434352-2277-c4a8-e87e-e96cfcbf2305", + "projectVersion": "v3", + "projectType": "lvgl", + "assetsFolder": "./assets", + "imports": [], + "flowSupport": true, + "displayWidth": 800, + "displayHeight": 480 + }, + "build": { + "objID": "72794a43-a0fc-13c2-7eb5-67dd952141a4", + "configurations": [ + { + "objID": "bba0546c-06b8-604d-c43e-ecf1963e7492", + "name": "Default" + } + ], + "files": [ + { + "objID": "05204dce-0fc5-4c81-b733-2ccc8e6c8671", + "fileName": "screens.h", + "template": "#ifndef EEZ_LVGL_UI_SCREENS_H\r\n#define EEZ_LVGL_UI_SCREENS_H\r\n\r\n#include \"lvgl/lvgl.h\"\r\n\r\n#ifdef __cplusplus\r\nextern \"C\" {\r\n#endif\r\n\r\n//${eez-studio LVGL_SCREENS_DECL}\r\n//${eez-studio LVGL_SCREENS_DECL_EXT}\r\n\r\n#ifdef __cplusplus\r\n}\r\n#endif\r\n\r\n#endif /*EEZ_LVGL_UI_SCREENS_H*/" + }, + { + "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}" + }, + { + "objID": "19d3d573-88a3-4550-f4da-753b61d7f0c4", + "fileName": "actions.h", + "template": "#ifndef EEZ_LVGL_UI_EVENTS_H\r\n#define EEZ_LVGL_UI_EVENTS_H\r\n\r\n#include \"lvgl/lvgl.h\"\r\n\r\n//${eez-studio LVGL_ACTIONS_DECL}\r\n\r\n#endif /*EEZ_LVGL_UI_EVENTS_H*/" + }, + { + "objID": "e95514b3-1083-49b9-a4f6-847d4792f050", + "fileName": "vars.h", + "template": "#ifndef EEZ_LVGL_UI_VARS_H\r\n#define EEZ_LVGL_UI_VARS_H\r\n\r\n#include \r\n\r\n//${eez-studio LVGL_VARS_DECL}\r\n\r\n#endif /*EEZ_LVGL_UI_VARS_H*/" + }, + { + "objID": "9c770003-b028-4a8b-9447-fea072e67b3a", + "fileName": "flow_def.h", + "template": "#pragma once\n\n#include \n#include \n\n#include \"lvgl/lvgl.h\"\n\nnamespace eez {\n\n//${eez-studio GUI_THEMES_ENUM}\n\n//${eez-studio GUI_COLORS_ENUM}\n\n//${eez-studio GUI_ASSETS_DECL_COMPRESSED}\n\n} // namespace eez\n" + }, + { + "objID": "0f3ea37c-f0d3-4061-c693-76b52bd9d632", + "fileName": "flow_def.cpp", + "template": "#include \"flow_def.h\"\n\nnamespace eez {\n\n//${eez-studio GUI_ASSETS_DEF_COMPRESSED}\n\n} // namespace eez\n" + }, + { + "objID": "81fa9cb7-33e4-4272-9340-49a50037b327", + "fileName": "images.h", + "template": "#ifndef EEZ_LVGL_UI_IMAGES_H\r\n#define EEZ_LVGL_UI_IMAGES_H\r\n\r\n#include \"lvgl/lvgl.h\"\r\n\r\n//${eez-studio LVGL_IMAGES_DECL}\r\n\r\n#endif /*EEZ_LVGL_UI_IMAGES_H*/" + }, + { + "objID": "5844b3a8-54b7-4bdf-ff04-d052e689328c", + "fileName": "images.c", + "template": "#include \"images.h\"\n\n//${eez-studio LVGL_IMAGES_DEF}" + }, + { + "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*/" + } + ], + "destinationFolder": "src\\ui" + } + }, + "variables": { + "objID": "c6c71e16-53e1-217f-d03b-cef56c6b037a", + "globalVariables": [], + "structures": [], + "enums": [] + }, + "actions": [], + "pages": [ + { + "objID": "4b40eba7-b31a-468a-b887-11dfd0b6637f", + "components": [ + { + "objID": "6b272cb8-48b4-467f-c130-a1edc1f930b7", + "type": "LVGLLabelWidget", + "left": 356, + "top": 232, + "width": 89, + "height": 16, + "customInputs": [], + "customOutputs": [], + "style": { + "objID": "a9bf737e-205d-4003-aae9-0ca3b6710d43", + "inheritFrom": "default" + }, + "timeline": [], + "leftUnit": "px", + "topUnit": "px", + "widthUnit": "content", + "heightUnit": "content", + "children": [], + "flags": "PRESS_LOCK|CLICK_FOCUSABLE|GESTURE_BUBBLE|SNAPPABLE|SCROLLABLE|SCROLL_ELASTIC|SCROLL_MOMENTUM|SCROLL_CHAIN", + "hiddenFlagType": "literal", + "clickableFlagType": "literal", + "scrollbarMode": "auto", + "scrollDirection": "all", + "checkedStateType": "literal", + "disabledStateType": "literal", + "states": "", + "localStyles": { + "objID": "b70b99db-02c2-420a-cbdf-e6366dc84e67" + }, + "eventHandlers": [], + "text": "Hello, world!", + "textType": "literal", + "longMode": "WRAP", + "recolor": false + } + ], + "connectionLines": [], + "localVariables": [], + "name": "Main", + "left": 0, + "top": 0, + "width": 800, + "height": 480, + "lvglLocalStyles": { + "objID": "e85dbd5d-8325-1629-003b-86fd654ae635" + } + } + ], + "fonts": [], + "bitmaps": [], + "colors": [ + { + "objID": "a3333659-ca35-4e6c-e434-d9dd1aa3b7d8", + "name": "color" + }, + { + "objID": "f111d279-a86c-40ff-8739-063e95629d7f", + "name": "background_color" + } + ], + "themes": [ + { + "objID": "728af2e4-0a31-4f5c-b5cf-8fbdc345e872", + "name": "default", + "colors": [ + "#ffffff", + "#404040" + ] + } + ] +} \ No newline at end of file