Skip to content

Commit

Permalink
Incorporate LVGL.
Browse files Browse the repository at this point in the history
  • Loading branch information
gabordemooij committed Feb 19, 2025
1 parent bf9d005 commit 4da472b
Show file tree
Hide file tree
Showing 2,072 changed files with 1,391,799 additions and 0 deletions.
27 changes: 27 additions & 0 deletions plugins/gui/lvgl_static/.devcontainer/__CMakeLists.txt__
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
cmake_minimum_required(VERSION 3.12)
project (lv_emscripten)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -s USE_SDL=2")

include_directories(${PROJECT_SOURCE_DIR})

add_subdirectory(lvgl)
file(GLOB MY_SOURCES "./*.c")
set(SOURCES ${MY_SOURCES})

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
lvgl_thorvg
SDL2
)
set_target_properties(index PROPERTIES LINK_FLAGS "--shell-file ${PROJECT_SOURCE_DIR}/lvgl/.devcontainer/lvgl_shell.html -s SINGLE_FILE=1")
5 changes: 5 additions & 0 deletions plugins/gui/lvgl_static/.devcontainer/__build_all.sh__
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cd build
emcmake cmake ..
emmake make -j$(nproc)
echo "Built succesfully, opening index.html"
code index.html
17 changes: 17 additions & 0 deletions plugins/gui/lvgl_static/.devcontainer/__c_cpp_properties.json__
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"/usr/local/emsdk/upstream/emscripten/cache/sysroot/include/"
],
"defines": [],
"compilerPath": "/usr/bin/clang",
"cStandard": "c17",
"cppStandard": "c++14",
"intelliSenseMode": "linux-clang-x64"
}
],
"version": 4
}
107 changes: 107 additions & 0 deletions plugins/gui/lvgl_static/.devcontainer/__main.c__
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@

/**
* @file main
*
*/

/*********************
* INCLUDES
*********************/
#include <stdlib.h>
#include <unistd.h>
#define SDL_MAIN_HANDLED /*To fix SDL's "undefined reference to WinMain" issue*/
#include <SDL2/SDL.h>
#include <emscripten.h>
#include "lvgl/lvgl.h"
#include "lvgl/demos/lv_demos.h"
#include "lvgl/examples/lv_examples.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_display_t * disp1;

int monitor_hor_res, monitor_ver_res;

/**********************
* MACROS
**********************/

/**********************
* GLOBAL FUNCTIONS
**********************/
void do_loop(void *arg);

/* Allows disabling CHOSEN_DEMO */
static void lv_example_noop(void) {
}

int main(int argc, char ** argv)
{

monitor_hor_res = 800;
monitor_ver_res = 480;
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();

lv_demo_widgets();

emscripten_set_main_loop_arg(do_loop, NULL, -1, true);
}

void do_loop(void *arg)
{
/* Periodically call the lv_timer handler.
* It could be done in a timer interrupt or an OS task too.*/
lv_timer_handler();
}

/**********************
* STATIC FUNCTIONS
**********************/


/**
* Initialize the Hardware Abstraction Layer (HAL) for the Littlev graphics library
*/
static void hal_init(void)
{
lv_display_t * disp = lv_sdl_window_create(monitor_hor_res, monitor_ver_res);

lv_group_t * g = lv_group_create();
lv_group_set_default(g);

lv_sdl_mouse_create();
lv_indev_t * mousewheel = lv_sdl_mousewheel_create();
lv_indev_set_group(mousewheel, lv_group_get_default());

lv_indev_t * keyboard = lv_sdl_keyboard_create();
lv_indev_set_group(keyboard, lv_group_get_default());
}
5 changes: 5 additions & 0 deletions plugins/gui/lvgl_static/.devcontainer/__settings.json__
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"files.associations": {
"sdl.h": "c"
}
}
28 changes: 28 additions & 0 deletions plugins/gui/lvgl_static/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"image": "mcr.microsoft.com/devcontainers/universal:2",
"features": {
"ghcr.io/ebaskoro/devcontainer-features/emscripten:1": {}
},
"postCreateCommand": "chmod +x /workspace/lvgl_app/lvgl/.devcontainer/setup.sh; /workspace/lvgl_app/lvgl/.devcontainer/setup.sh",
"postStartCommand": ". /usr/local/emsdk/emsdk_env.sh;",

// Configure tool-specific properties.
"customizations": {
// Configure properties specific to VS Code.
"vscode": {
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
//"searKing.preview-vscode"
"analytic-signal.preview-html"
]
}
},

"hostRequirements": {
"cpus": 4
},

"workspaceMount": "source=${localWorkspaceFolder},target=/workspace/lvgl_app/lvgl,type=bind",
"workspaceFolder": "/workspace/lvgl_app"

}
70 changes: 70 additions & 0 deletions plugins/gui/lvgl_static/.devcontainer/lv_conf.defaults
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
LV_COLOR_DEPTH 32
LV_MEM_SIZE (1024 * 1024)
LV_DRAW_THREAD_STACK_SIZE (64 * 1024)
LV_USE_MATRIX 1
LV_USE_FLOAT 1
LV_USE_LOTTIE 1

LV_USE_DRAW_SW_COMPLEX_GRADIENTS 1
LV_OBJ_STYLE_CACHE 1
LV_USE_LOG 1
LV_LOG_PRINTF 1
LV_USE_PERF_MONITOR 1
LV_USE_SYSMON 1

LV_USE_ASSERT_MEM_INTEGRITY 1
LV_USE_ASSERT_OBJ 1
LV_USE_ASSERT_STYLE 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_28_COMPRESSED 1
LV_FONT_DEJAVU_16_PERSIAN_HEBREW 1
LV_FONT_SIMSUN_16_CJK 1
LV_FONT_UNSCII_8 1

LV_USE_IMGFONT 1
LV_USE_FS_STDIO 1
LV_FS_STDIO_LETTER 'A'
LV_USE_FS_MEMFS 1
LV_FS_MEMFS_LETTER 'M'
LV_USE_THORVG_INTERNAL 1
LV_USE_LZ4_INTERNAL 1
LV_USE_VECTOR_GRAPHIC 1
LV_USE_TINY_TTF 1
LV_USE_BARCODE 1
LV_USE_QRCODE 1
LV_USE_RLE 1
LV_BIN_DECODER_RAM_LOAD 1
LV_USE_TJPGD 1
LV_USE_BMP 1
LV_USE_LODEPNG 1
LV_USE_SDL 1

LV_USE_DEMO_WIDGETS 1
LV_USE_DEMO_KEYPAD_AND_ENCODER 1
LV_USE_DEMO_BENCHMARK 1
LV_USE_DEMO_RENDER 1
LV_USE_DEMO_STRESS 1
LV_USE_DEMO_MUSIC 1
LV_USE_DEMO_FLEX_LAYOUT 1
LV_USE_DEMO_MULTILANG 1
LV_USE_DEMO_TRANSFORM 1
LV_USE_DEMO_SCROLL 1

19 changes: 19 additions & 0 deletions plugins/gui/lvgl_static/.devcontainer/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh

echo ". /usr/local/emsdk/emsdk_env.sh" >> /home/codespace/.bashrc

cd /workspace/lvgl_app
sudo chmod 777 .
mkdir build
mkdir vscode

cd lvgl/.devcontainer
cp __CMakeLists.txt__ ../../CMakeLists.txt
cp __main.c__ ../../main.c
cp __build_all.sh__ ../../build_all.sh
cp __c_cpp_properties.json__ ../../.vscode/c_cpp_properties.json
cp __settings.json__ ../../.vscode/settings.json
touch ../../lv_conf.h
../scripts/generate_lv_conf.py --template ../lv_conf_template.h --config ../../lv_conf.h

chmod +x ../../build_all.sh
33 changes: 33 additions & 0 deletions plugins/gui/lvgl_static/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
**/*.o
**/*bin
**/*.swp
**/*.swo
**/*.gcda
**/*.gcno
tags
docs/api_doc
scripts/cppcheck_res.txt
scripts/built_in_font/lv_font_*
docs/doxygen_html
docs/xml
docs/examples.md
docs/out_latex
docs/_static/built_lv_examples
docs/LVGL.pdf
docs/env
/docs/examples.rst
/docs/API/
out_html
__pycache__
/emscripten_builder
test_screenshot_error.h
build/
tests/build_*/
tests/report/
tests/wayland_protocols/
.DS_Store
.vscode
.idea
*.bak
tests/test_images/
.vs/
42 changes: 42 additions & 0 deletions plugins/gui/lvgl_static/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: trailing-whitespace

- repo: local
hooks:
# Run astyle over the staged files with c and h extension found in the directories
# listed in the files regex pattern. Ignoring the files in the exclude pattern.
- id: format-source
name: Formatting source files
entry: astyle --options=scripts/code-format.cfg --ignore-exclude-errors
stages: [ commit ]
language: system
pass_filenames: true
verbose: true
files: |
(?x)^(
demos/ |
examples/ |
src/ |
tests/
)
exclude: |
(?x)^(
demos/high_res/fonts/ |
src/libs/ |
src/lv_conf_internal.h |
tests/test_images
)
types_or: ["c", "header"]
- repo: https://github.com/crate-ci/typos
rev: v1.16.20
hooks:
- id: typos
exclude: |
(?x)^(
src/libs/
)
29 changes: 29 additions & 0 deletions plugins/gui/lvgl_static/.typos.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[files]
extend-exclude = [
".git/",
"docs/_static/css/fontawesome.min.css",
"docs/README_*",
"src/libs/",
"docs/CHANGELOG.rst"
]
ignore-hidden = false

[default]
extend-ignore-re = [
"\\bser[^a-z]",
"\\bfle[^a-z]",
'"Lorem ipsum .*"',
'ACI',
"Nam consectetur",
"U\\+[0-9A-F]{4}",
'\{ "[a-z]+", "[^ -~]+" \},',
"`[0-9a-f]{7} <https://\\S+>`__",
"Rename lv_chart_clear_serie",
"rename LV_ROLLER_MODE_INIFINITE",
"CARD_INFO_SET\\(&img_multilang_avatar_.*\\)",
"ACI\\)",
]

[default.extend-words]
# https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6loca.html
"loca" = "loca"
Loading

0 comments on commit 4da472b

Please sign in to comment.