Skip to content

Commit 4da472b

Browse files
committed
Incorporate LVGL.
1 parent bf9d005 commit 4da472b

File tree

2,072 files changed

+1391799
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,072 files changed

+1391799
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
cmake_minimum_required(VERSION 3.12)
2+
project (lv_emscripten)
3+
4+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -s USE_SDL=2")
5+
6+
include_directories(${PROJECT_SOURCE_DIR})
7+
8+
add_subdirectory(lvgl)
9+
file(GLOB MY_SOURCES "./*.c")
10+
set(SOURCES ${MY_SOURCES})
11+
12+
add_executable(index ${SOURCES} ${INCLUDES})
13+
14+
if(NOT LVGL_CHOSEN_DEMO)
15+
set(LVGL_CHOSEN_DEMO lv_demo_widgets)
16+
endif()
17+
set_source_files_properties(main.c PROPERTIES COMPILE_FLAGS -DCHOSEN_DEMO=${LVGL_CHOSEN_DEMO})
18+
19+
set(CMAKE_EXECUTABLE_SUFFIX ".html")
20+
target_link_libraries(index
21+
lvgl
22+
lvgl_examples
23+
lvgl_demos
24+
lvgl_thorvg
25+
SDL2
26+
)
27+
set_target_properties(index PROPERTIES LINK_FLAGS "--shell-file ${PROJECT_SOURCE_DIR}/lvgl/.devcontainer/lvgl_shell.html -s SINGLE_FILE=1")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
cd build
2+
emcmake cmake ..
3+
emmake make -j$(nproc)
4+
echo "Built succesfully, opening index.html"
5+
code index.html
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"configurations": [
3+
{
4+
"name": "Linux",
5+
"includePath": [
6+
"${workspaceFolder}/**",
7+
"/usr/local/emsdk/upstream/emscripten/cache/sysroot/include/"
8+
],
9+
"defines": [],
10+
"compilerPath": "/usr/bin/clang",
11+
"cStandard": "c17",
12+
"cppStandard": "c++14",
13+
"intelliSenseMode": "linux-clang-x64"
14+
}
15+
],
16+
"version": 4
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
2+
/**
3+
* @file main
4+
*
5+
*/
6+
7+
/*********************
8+
* INCLUDES
9+
*********************/
10+
#include <stdlib.h>
11+
#include <unistd.h>
12+
#define SDL_MAIN_HANDLED /*To fix SDL's "undefined reference to WinMain" issue*/
13+
#include <SDL2/SDL.h>
14+
#include <emscripten.h>
15+
#include "lvgl/lvgl.h"
16+
#include "lvgl/demos/lv_demos.h"
17+
#include "lvgl/examples/lv_examples.h"
18+
19+
/*********************
20+
* DEFINES
21+
*********************/
22+
23+
/*On OSX SDL needs different handling*/
24+
#if defined(__APPLE__) && defined(TARGET_OS_MAC)
25+
# if __APPLE__ && TARGET_OS_MAC
26+
#define SDL_APPLE
27+
# endif
28+
#endif
29+
30+
/**********************
31+
* TYPEDEFS
32+
**********************/
33+
34+
/**********************
35+
* STATIC PROTOTYPES
36+
**********************/
37+
static void hal_init(void);
38+
static int tick_thread(void * data);
39+
static void memory_monitor(lv_timer_t * param);
40+
41+
/**********************
42+
* STATIC VARIABLES
43+
**********************/
44+
static lv_display_t * disp1;
45+
46+
int monitor_hor_res, monitor_ver_res;
47+
48+
/**********************
49+
* MACROS
50+
**********************/
51+
52+
/**********************
53+
* GLOBAL FUNCTIONS
54+
**********************/
55+
void do_loop(void *arg);
56+
57+
/* Allows disabling CHOSEN_DEMO */
58+
static void lv_example_noop(void) {
59+
}
60+
61+
int main(int argc, char ** argv)
62+
{
63+
64+
monitor_hor_res = 800;
65+
monitor_ver_res = 480;
66+
printf("Starting with screen resolution of %dx%d px\n", monitor_hor_res, monitor_ver_res);
67+
68+
/*Initialize LittlevGL*/
69+
lv_init();
70+
71+
/*Initialize the HAL (display, input devices, tick) for LittlevGL*/
72+
hal_init();
73+
74+
lv_demo_widgets();
75+
76+
emscripten_set_main_loop_arg(do_loop, NULL, -1, true);
77+
}
78+
79+
void do_loop(void *arg)
80+
{
81+
/* Periodically call the lv_timer handler.
82+
* It could be done in a timer interrupt or an OS task too.*/
83+
lv_timer_handler();
84+
}
85+
86+
/**********************
87+
* STATIC FUNCTIONS
88+
**********************/
89+
90+
91+
/**
92+
* Initialize the Hardware Abstraction Layer (HAL) for the Littlev graphics library
93+
*/
94+
static void hal_init(void)
95+
{
96+
lv_display_t * disp = lv_sdl_window_create(monitor_hor_res, monitor_ver_res);
97+
98+
lv_group_t * g = lv_group_create();
99+
lv_group_set_default(g);
100+
101+
lv_sdl_mouse_create();
102+
lv_indev_t * mousewheel = lv_sdl_mousewheel_create();
103+
lv_indev_set_group(mousewheel, lv_group_get_default());
104+
105+
lv_indev_t * keyboard = lv_sdl_keyboard_create();
106+
lv_indev_set_group(keyboard, lv_group_get_default());
107+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"files.associations": {
3+
"sdl.h": "c"
4+
}
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"image": "mcr.microsoft.com/devcontainers/universal:2",
3+
"features": {
4+
"ghcr.io/ebaskoro/devcontainer-features/emscripten:1": {}
5+
},
6+
"postCreateCommand": "chmod +x /workspace/lvgl_app/lvgl/.devcontainer/setup.sh; /workspace/lvgl_app/lvgl/.devcontainer/setup.sh",
7+
"postStartCommand": ". /usr/local/emsdk/emsdk_env.sh;",
8+
9+
// Configure tool-specific properties.
10+
"customizations": {
11+
// Configure properties specific to VS Code.
12+
"vscode": {
13+
// Add the IDs of extensions you want installed when the container is created.
14+
"extensions": [
15+
//"searKing.preview-vscode"
16+
"analytic-signal.preview-html"
17+
]
18+
}
19+
},
20+
21+
"hostRequirements": {
22+
"cpus": 4
23+
},
24+
25+
"workspaceMount": "source=${localWorkspaceFolder},target=/workspace/lvgl_app/lvgl,type=bind",
26+
"workspaceFolder": "/workspace/lvgl_app"
27+
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
LV_COLOR_DEPTH 32
2+
LV_MEM_SIZE (1024 * 1024)
3+
LV_DRAW_THREAD_STACK_SIZE (64 * 1024)
4+
LV_USE_MATRIX 1
5+
LV_USE_FLOAT 1
6+
LV_USE_LOTTIE 1
7+
8+
LV_USE_DRAW_SW_COMPLEX_GRADIENTS 1
9+
LV_OBJ_STYLE_CACHE 1
10+
LV_USE_LOG 1
11+
LV_LOG_PRINTF 1
12+
LV_USE_PERF_MONITOR 1
13+
LV_USE_SYSMON 1
14+
15+
LV_USE_ASSERT_MEM_INTEGRITY 1
16+
LV_USE_ASSERT_OBJ 1
17+
LV_USE_ASSERT_STYLE 1
18+
LV_FONT_MONTSERRAT_12 1
19+
LV_FONT_MONTSERRAT_14 1
20+
LV_FONT_MONTSERRAT_16 1
21+
LV_FONT_MONTSERRAT_18 1
22+
LV_FONT_MONTSERRAT_20 1
23+
LV_FONT_MONTSERRAT_22 1
24+
LV_FONT_MONTSERRAT_24 1
25+
LV_FONT_MONTSERRAT_26 1
26+
LV_FONT_MONTSERRAT_28 1
27+
LV_FONT_MONTSERRAT_30 1
28+
LV_FONT_MONTSERRAT_32 1
29+
LV_FONT_MONTSERRAT_34 1
30+
LV_FONT_MONTSERRAT_36 1
31+
LV_FONT_MONTSERRAT_38 1
32+
LV_FONT_MONTSERRAT_40 1
33+
LV_FONT_MONTSERRAT_42 1
34+
LV_FONT_MONTSERRAT_44 1
35+
LV_FONT_MONTSERRAT_46 1
36+
LV_FONT_MONTSERRAT_48 1
37+
LV_FONT_MONTSERRAT_28_COMPRESSED 1
38+
LV_FONT_DEJAVU_16_PERSIAN_HEBREW 1
39+
LV_FONT_SIMSUN_16_CJK 1
40+
LV_FONT_UNSCII_8 1
41+
42+
LV_USE_IMGFONT 1
43+
LV_USE_FS_STDIO 1
44+
LV_FS_STDIO_LETTER 'A'
45+
LV_USE_FS_MEMFS 1
46+
LV_FS_MEMFS_LETTER 'M'
47+
LV_USE_THORVG_INTERNAL 1
48+
LV_USE_LZ4_INTERNAL 1
49+
LV_USE_VECTOR_GRAPHIC 1
50+
LV_USE_TINY_TTF 1
51+
LV_USE_BARCODE 1
52+
LV_USE_QRCODE 1
53+
LV_USE_RLE 1
54+
LV_BIN_DECODER_RAM_LOAD 1
55+
LV_USE_TJPGD 1
56+
LV_USE_BMP 1
57+
LV_USE_LODEPNG 1
58+
LV_USE_SDL 1
59+
60+
LV_USE_DEMO_WIDGETS 1
61+
LV_USE_DEMO_KEYPAD_AND_ENCODER 1
62+
LV_USE_DEMO_BENCHMARK 1
63+
LV_USE_DEMO_RENDER 1
64+
LV_USE_DEMO_STRESS 1
65+
LV_USE_DEMO_MUSIC 1
66+
LV_USE_DEMO_FLEX_LAYOUT 1
67+
LV_USE_DEMO_MULTILANG 1
68+
LV_USE_DEMO_TRANSFORM 1
69+
LV_USE_DEMO_SCROLL 1
70+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/sh
2+
3+
echo ". /usr/local/emsdk/emsdk_env.sh" >> /home/codespace/.bashrc
4+
5+
cd /workspace/lvgl_app
6+
sudo chmod 777 .
7+
mkdir build
8+
mkdir vscode
9+
10+
cd lvgl/.devcontainer
11+
cp __CMakeLists.txt__ ../../CMakeLists.txt
12+
cp __main.c__ ../../main.c
13+
cp __build_all.sh__ ../../build_all.sh
14+
cp __c_cpp_properties.json__ ../../.vscode/c_cpp_properties.json
15+
cp __settings.json__ ../../.vscode/settings.json
16+
touch ../../lv_conf.h
17+
../scripts/generate_lv_conf.py --template ../lv_conf_template.h --config ../../lv_conf.h
18+
19+
chmod +x ../../build_all.sh

plugins/gui/lvgl_static/.gitignore

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
**/*.o
2+
**/*bin
3+
**/*.swp
4+
**/*.swo
5+
**/*.gcda
6+
**/*.gcno
7+
tags
8+
docs/api_doc
9+
scripts/cppcheck_res.txt
10+
scripts/built_in_font/lv_font_*
11+
docs/doxygen_html
12+
docs/xml
13+
docs/examples.md
14+
docs/out_latex
15+
docs/_static/built_lv_examples
16+
docs/LVGL.pdf
17+
docs/env
18+
/docs/examples.rst
19+
/docs/API/
20+
out_html
21+
__pycache__
22+
/emscripten_builder
23+
test_screenshot_error.h
24+
build/
25+
tests/build_*/
26+
tests/report/
27+
tests/wayland_protocols/
28+
.DS_Store
29+
.vscode
30+
.idea
31+
*.bak
32+
tests/test_images/
33+
.vs/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
repos:
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v3.2.0
6+
hooks:
7+
- id: trailing-whitespace
8+
9+
- repo: local
10+
hooks:
11+
# Run astyle over the staged files with c and h extension found in the directories
12+
# listed in the files regex pattern. Ignoring the files in the exclude pattern.
13+
- id: format-source
14+
name: Formatting source files
15+
entry: astyle --options=scripts/code-format.cfg --ignore-exclude-errors
16+
stages: [ commit ]
17+
language: system
18+
pass_filenames: true
19+
verbose: true
20+
files: |
21+
(?x)^(
22+
demos/ |
23+
examples/ |
24+
src/ |
25+
tests/
26+
)
27+
exclude: |
28+
(?x)^(
29+
demos/high_res/fonts/ |
30+
src/libs/ |
31+
src/lv_conf_internal.h |
32+
tests/test_images
33+
)
34+
types_or: ["c", "header"]
35+
- repo: https://github.com/crate-ci/typos
36+
rev: v1.16.20
37+
hooks:
38+
- id: typos
39+
exclude: |
40+
(?x)^(
41+
src/libs/
42+
)

plugins/gui/lvgl_static/.typos.toml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
[files]
2+
extend-exclude = [
3+
".git/",
4+
"docs/_static/css/fontawesome.min.css",
5+
"docs/README_*",
6+
"src/libs/",
7+
"docs/CHANGELOG.rst"
8+
]
9+
ignore-hidden = false
10+
11+
[default]
12+
extend-ignore-re = [
13+
"\\bser[^a-z]",
14+
"\\bfle[^a-z]",
15+
'"Lorem ipsum .*"',
16+
'ACI',
17+
"Nam consectetur",
18+
"U\\+[0-9A-F]{4}",
19+
'\{ "[a-z]+", "[^ -~]+" \},',
20+
"`[0-9a-f]{7} <https://\\S+>`__",
21+
"Rename lv_chart_clear_serie",
22+
"rename LV_ROLLER_MODE_INIFINITE",
23+
"CARD_INFO_SET\\(&img_multilang_avatar_.*\\)",
24+
"ACI\\)",
25+
]
26+
27+
[default.extend-words]
28+
# https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6loca.html
29+
"loca" = "loca"

0 commit comments

Comments
 (0)