Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Update image loading method (BSP-577) #428

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build-applications.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
run: |
. ${IDF_PATH}/export.sh
pip install idf-component-manager==1.* ruamel.yaml idf-build-apps==2.4.3 --upgrade
pip install --upgrade idf-component-manager==1.* ruamel.yaml idf-build-apps==2.4.3 pypng lz4

echo "Files changed: ${ALL_CHANGED_FILES}"
idf-build-apps find --modified-files "${ALL_CHANGED_FILES}"
Expand Down
1 change: 0 additions & 1 deletion examples/display/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@
# CMakeLists in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.5)

set(COMPONENTS main) # "Trim" the build. Include the minimal set of components; main and anything it depends on.
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(display)
15 changes: 12 additions & 3 deletions examples/display/main/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
idf_component_register(SRCS "display_main.c" "lvgl_demo_ui.c"
INCLUDE_DIRS ".")

lvgl_port_create_c_image("images/esp_logo.png" "images/gen/" "ARGB8888" "NONE")
lvgl_port_create_c_image("images/esp_text.png" "images/gen/" "ARGB8888" "NONE")
lvgl_port_add_images(${COMPONENT_LIB} "images/gen/")
spiffs_create_partition_assets(
storage
"./images"
FLASH_IN_PROJECT
MMAP_FILE_SUPPORT_FORMAT ".png"
MMAP_SUPPORT_RAW
MMAP_RAW_COLOR_FORMAT "ARGB8888"
)

idf_component_get_property(lib espressif__esp_lv_fs COMPONENT_LIB)
target_compile_options(${lib} PRIVATE -Wno-incompatible-pointer-types -Wno-implicit-function-declaration)

39 changes: 38 additions & 1 deletion examples/display/main/display_main.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: CC0-1.0
*/
Expand All @@ -9,11 +9,48 @@
#include "lvgl.h"
#include "esp_log.h"

#include "esp_lv_fs.h"
#include "mmap_generate_images.h"

extern void example_lvgl_demo_ui(lv_obj_t *scr);

static const char *TAG = "display";

esp_err_t example_mount_fs(void)
{
esp_err_t ret;
esp_lv_fs_handle_t fs_drive_handle;
mmap_assets_handle_t mmap_drive_handle;

const mmap_assets_config_t asset_cfg = {
.partition_label = "storage",
.max_files = MMAP_IMAGES_FILES,
.checksum = MMAP_IMAGES_CHECKSUM,
.flags = {.mmap_enable = true}
};
ret = mmap_assets_new(&asset_cfg, &mmap_drive_handle);
if (ret != ESP_OK) {
ESP_LOGE(TAG, "Failed to initialize %s", "storage");
return ret;
}

fs_cfg_t filesystem_cfg;
filesystem_cfg.fs_letter = 'A';
filesystem_cfg.fs_assets = mmap_drive_handle;
filesystem_cfg.fs_nums = MMAP_IMAGES_FILES;

ret = esp_lv_fs_desc_init(&filesystem_cfg, &fs_drive_handle);
if (ret != ESP_OK) {
ESP_LOGE(TAG, "Failed to initialize FS for %s", "storage");
return ret;
}
return ESP_OK;
}

void app_main(void)
{
bsp_display_start();
example_mount_fs();

ESP_LOGI("example", "Display LVGL animation");
bsp_display_lock(0);
Expand Down
2 changes: 2 additions & 0 deletions examples/display/main/idf_component.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ dependencies:
esp_wrover_kit:
version: "*"
override_path: "../../../bsp/esp_wrover_kit"
esp_mmap_assets: "1.*"
esp_lv_fs: "0.1.*"
4 changes: 2 additions & 2 deletions examples/display/main/lvgl_demo_ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ static void anim_timer_cb(lv_timer_t *timer)

// Create new image and make it transparent
img_text = lv_img_create(scr);
lv_img_set_src(img_text, &esp_text);
lv_img_set_src(img_text, "A:esp_text.bin");
lv_obj_set_style_img_opa(img_text, 0, 0);
}

Expand All @@ -78,7 +78,7 @@ void example_lvgl_demo_ui(lv_obj_t *scr)
{
// Create image
img_logo = lv_img_create(scr);
lv_img_set_src(img_logo, &esp_logo);
lv_img_set_src(img_logo, "A:esp_logo.bin");
lv_obj_center(img_logo);

// Create arcs
Expand Down
22 changes: 22 additions & 0 deletions examples/display/main/mmap_generate_images.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/

/**
* @file
* @brief This file was generated by esp_mmap_assets, don't modify it
*/

#pragma once

#include "esp_mmap_assets.h"

#define MMAP_IMAGES_FILES 2
#define MMAP_IMAGES_CHECKSUM 0xC382

enum MMAP_IMAGES_LISTS {
MMAP_IMAGES_ESP_LOGO_BIN = 0, /*!< esp_logo.bin */
MMAP_IMAGES_ESP_TEXT_BIN = 1, /*!< esp_text.bin */
};
6 changes: 6 additions & 0 deletions examples/display/partitions.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Name, Type, SubType, Offset, Size, Flags
# Note: if you change the phy_init or app partition offset, make sure to change the offset in Kconfig.projbuild
nvs, data, nvs, 0x9000, 0x6000,
phy_init, data, phy, 0xf000, 0x1000,
factory, app, factory, 0x10000, 1M,
storage, data, spiffs, 0x110000,0x2f0000,
1 change: 1 addition & 0 deletions examples/display/sdkconfig.bsp.esp-box
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_ESP_DEFAULT_CPU_FREQ_240=y
CONFIG_LV_SPRINTF_CUSTOM=y
# CONFIG_LV_BUILD_EXAMPLES is not set
CONFIG_PARTITION_TABLE_CUSTOM=y

## LVGL8 ##
CONFIG_LV_USE_PERF_MONITOR=y
Expand Down
1 change: 1 addition & 0 deletions examples/display/sdkconfig.bsp.esp-box-3
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_ESP_DEFAULT_CPU_FREQ_240=y
CONFIG_LV_SPRINTF_CUSTOM=y
# CONFIG_LV_BUILD_EXAMPLES is not set
CONFIG_PARTITION_TABLE_CUSTOM=y

## LVGL8 ##
CONFIG_LV_USE_PERF_MONITOR=y
Expand Down
1 change: 1 addition & 0 deletions examples/display/sdkconfig.bsp.esp-box-lite
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_ESP_DEFAULT_CPU_FREQ_240=y
CONFIG_LV_SPRINTF_CUSTOM=y
# CONFIG_LV_BUILD_EXAMPLES is not set
CONFIG_PARTITION_TABLE_CUSTOM=y

## LVGL8 ##
CONFIG_LV_USE_PERF_MONITOR=y
Expand Down
1 change: 1 addition & 0 deletions examples/display/sdkconfig.bsp.esp32_c3_lcdkit
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_ESP_DEFAULT_CPU_FREQ_240=y
CONFIG_LV_SPRINTF_CUSTOM=y
# CONFIG_LV_BUILD_EXAMPLES is not set
CONFIG_PARTITION_TABLE_CUSTOM=y

## LVGL8 ##
CONFIG_LV_USE_PERF_MONITOR=y
Expand Down
1 change: 1 addition & 0 deletions examples/display/sdkconfig.bsp.esp32_p4_function_ev_board
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ CONFIG_SPIRAM=y
CONFIG_SPIRAM_MODE_HEX=y
CONFIG_SPIRAM_SPEED_200M=y
CONFIG_IDF_EXPERIMENTAL_FEATURES=y
CONFIG_PARTITION_TABLE_CUSTOM=y

## LVGL8 ##
CONFIG_LV_MEM_SIZE_KILOBYTES=48
Expand Down
1 change: 1 addition & 0 deletions examples/display/sdkconfig.bsp.esp32_s2_kaluga_kit
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_ESP_DEFAULT_CPU_FREQ_240=y
CONFIG_LV_SPRINTF_CUSTOM=y
# CONFIG_LV_BUILD_EXAMPLES is not set
CONFIG_PARTITION_TABLE_CUSTOM=y

## LVGL8 ##
CONFIG_LV_USE_PERF_MONITOR=y
Expand Down
1 change: 1 addition & 0 deletions examples/display/sdkconfig.bsp.esp32_s3_eye
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ CONFIG_LV_SPRINTF_CUSTOM=y
CONFIG_BSP_DISPLAY_LVGL_TICK=5
CONFIG_BSP_DISPLAY_LVGL_MAX_SLEEP=500
# CONFIG_LV_BUILD_EXAMPLES is not set
CONFIG_PARTITION_TABLE_CUSTOM=y

## LVGL8 ##
CONFIG_LV_USE_PERF_MONITOR=y
Expand Down
1 change: 1 addition & 0 deletions examples/display/sdkconfig.bsp.esp32_s3_korvo_2
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_ESP_DEFAULT_CPU_FREQ_240=y
CONFIG_LV_SPRINTF_CUSTOM=y
# CONFIG_LV_BUILD_EXAMPLES is not set
CONFIG_PARTITION_TABLE_CUSTOM=y

## LVGL8 ##
CONFIG_LV_USE_PERF_MONITOR=y
Expand Down
1 change: 1 addition & 0 deletions examples/display/sdkconfig.bsp.esp32_s3_lcd_ev_board
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ CONFIG_BSP_LCD_RGB_BOUNCE_BUFFER_MODE=y
CONFIG_BSP_DISPLAY_LVGL_AVOID_TEAR=y
CONFIG_BSP_DISPLAY_LVGL_DIRECT_MODE=y
CONFIG_LV_ATTRIBUTE_FAST_MEM_USE_IRAM=y
CONFIG_PARTITION_TABLE_CUSTOM=y

## LVGL8 ##
CONFIG_LV_USE_PERF_MONITOR=y
Expand Down
1 change: 1 addition & 0 deletions examples/display/sdkconfig.bsp.esp32_s3_usb_otg
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_ESP_DEFAULT_CPU_FREQ_240=y
CONFIG_LV_SPRINTF_CUSTOM=y
# CONFIG_LV_BUILD_EXAMPLES is not set
CONFIG_PARTITION_TABLE_CUSTOM=y

## LVGL8 ##
CONFIG_LV_USE_PERF_MONITOR=y
Expand Down
1 change: 1 addition & 0 deletions examples/display/sdkconfig.bsp.esp_wrover_kit
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_ESP_DEFAULT_CPU_FREQ_240=y
CONFIG_LV_SPRINTF_CUSTOM=y
# CONFIG_LV_BUILD_EXAMPLES is not set
CONFIG_PARTITION_TABLE_CUSTOM=y

## LVGL8 ##
CONFIG_LV_USE_PERF_MONITOR=y
Expand Down
1 change: 1 addition & 0 deletions examples/display/sdkconfig.bsp.m5dial
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
CONFIG_IDF_TARGET="esp32s3"
CONFIG_ESPTOOLPY_FLASHMODE_QIO=y
CONFIG_ESPTOOLPY_FLASHSIZE_8MB=y
CONFIG_PARTITION_TABLE_CUSTOM=y

## LVGL8 ##
CONFIG_LV_USE_PERF_MONITOR=y
Expand Down
1 change: 1 addition & 0 deletions examples/display/sdkconfig.bsp.m5stack_core_2
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
CONFIG_IDF_TARGET="esp32"
CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y
CONFIG_ESP_DEFAULT_CPU_FREQ_240=y
CONFIG_PARTITION_TABLE_CUSTOM=y

## LVGL8 ##
CONFIG_LV_USE_PERF_MONITOR=y
Expand Down
1 change: 1 addition & 0 deletions examples/display/sdkconfig.bsp.m5stack_core_s3
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ CONFIG_IDF_TARGET="esp32s3"
CONFIG_ESPTOOLPY_FLASHMODE_QIO=y
CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y
CONFIG_CODEC_I2C_BACKWARD_COMPATIBLE=n
CONFIG_PARTITION_TABLE_CUSTOM=y

## LVGL8 ##
CONFIG_LV_USE_PERF_MONITOR=y
Expand Down
1 change: 1 addition & 0 deletions examples/display/sdkconfig.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_ESP_DEFAULT_CPU_FREQ_240=y
CONFIG_LV_SPRINTF_CUSTOM=y
# CONFIG_LV_BUILD_EXAMPLES is not set
CONFIG_PARTITION_TABLE_CUSTOM=y

## LVGL8 ##
CONFIG_LV_USE_PERF_MONITOR=y
Expand Down
Loading