-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(LVGL port): Generate C arrays for images during build process
- Loading branch information
Showing
29 changed files
with
436 additions
and
664 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
components/esp_lvgl_port/examples/touchscreen/main/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
idf_component_register(SRCS "main.c" | ||
INCLUDE_DIRS ".") | ||
|
||
lvgl_port_create_c_image("images/esp_logo.png" "images/" "ARGB8888" "NONE") | ||
lvgl_port_add_images(${COMPONENT_LIB} "images/") |
1 change: 1 addition & 0 deletions
1
components/esp_lvgl_port/examples/touchscreen/main/images/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.c |
Binary file added
BIN
+6.48 KB
components/esp_lvgl_port/examples/touchscreen/main/images/esp_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# lvgl_port_create_c_image | ||
# | ||
# Create a C array of image for using with LVGL | ||
function(lvgl_port_create_c_image image_path output_path color_format compression) | ||
|
||
#Get LVGL version | ||
idf_component_get_property(lvgl_ver lvgl__lvgl COMPONENT_VERSION) | ||
set(LVGL_NAME "lvgl__lvgl") | ||
if(lvgl_ver EQUAL "") | ||
idf_component_get_property(lvgl_ver lvgl COMPONENT_VERSION) | ||
set(LVGL_NAME "lvgl") | ||
endif() | ||
|
||
get_filename_component(image_full_path ${image_path} ABSOLUTE) | ||
get_filename_component(output_full_path ${output_path} ABSOLUTE) | ||
if(NOT EXISTS ${image_full_path}) | ||
message(FATAL_ERROR "Input image (${image_full_path}) not exists!") | ||
endif() | ||
|
||
message(STATUS "Generating C array image: ${image_path}") | ||
|
||
#Create C array image by LVGL version | ||
if(lvgl_ver VERSION_LESS "9.0.0") | ||
if(CONFIG_LV_COLOR_16_SWAP) | ||
set(color_format "RGB565SWAP") | ||
else() | ||
set(color_format "RGB565") | ||
endif() | ||
|
||
execute_process(COMMAND git clone https://github.com/W-Mai/lvgl_image_converter.git "${CMAKE_BINARY_DIR}/lvgl_image_converter") | ||
execute_process(COMMAND git checkout 9174634e9dcc1b21a63668969406897aad650f35 WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/lvgl_image_converter" OUTPUT_QUIET) | ||
execute_process(COMMAND python -m pip install -r "${CMAKE_BINARY_DIR}/lvgl_image_converter/requirements.txt") | ||
execute_process(COMMAND ${PYTHON} "${CMAKE_BINARY_DIR}/lvgl_image_converter/lv_img_conv.py" | ||
-ff C | ||
-f true_color_alpha | ||
-cf ${color_format} | ||
-o ${output_full_path} | ||
${image_full_path}) | ||
else() | ||
idf_component_get_property(lvgl_dir ${LVGL_NAME} COMPONENT_DIR) | ||
get_filename_component(script_path ${lvgl_dir}/scripts/LVGLImage.py ABSOLUTE) | ||
set(lvglimage_py ${PYTHON} ${script_path}) | ||
|
||
#Install dependencies | ||
execute_process(COMMAND python -m pip install pypng lz4) | ||
|
||
execute_process(COMMAND ${lvglimage_py} | ||
--ofmt=C | ||
--cf=${color_format} | ||
--compress=${compression} | ||
-o ${output_full_path} | ||
${image_full_path}) | ||
endif() | ||
|
||
endfunction() | ||
|
||
# lvgl_port_add_images | ||
# | ||
# Add all images to build | ||
function(lvgl_port_add_images component output_path) | ||
#Add images to sources | ||
file(GLOB_RECURSE IMAGE_SOURCES ${output_path}*.c) | ||
target_sources(${component} PRIVATE ${IMAGE_SOURCES}) | ||
idf_build_set_property(COMPILE_OPTIONS "-DLV_LVGL_H_INCLUDE_SIMPLE=1" APPEND) | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.