C

Qt Quick Ultralite image_cache Example

cmake_minimum_required (VERSION 3.21.1)

project(image_cache VERSION 0.0.1 LANGUAGES C CXX ASM)
if (NOT TARGET Qul::Core)
    find_package(Qul)
endif()

# All photos have the same width, height and format. We display 4 photo slideshow.
# For user convenience we need UL-3093 and also need to clarify UL-3097.
if(QUL_PLATFORM MATCHES "^ek-ra6m3g")
# Two 480x288 RGB332 images fit to the RAM at the same time
# 138240 is decompressed photo size in bytes (QImage) for 8 bits per pixel
math(EXPR cache_size_in_bytes "138240 * 2")
elseif (QUL_PLATFORM STREQUAL "tviic2d4m-baremetal")
# 276480 is decompressed photo size in bytes (QImage) for 16 bits per pixel
math(EXPR cache_size_in_bytes "276480 * 4")
else()
# 552960 is decompressed photo size in bytes (QImage) for 32 bits per pixel
math(EXPR cache_size_in_bytes "552960 * 4")
endif()

# Set FreeRTOS heap size (needed for cache entries)
# STM32F769i has a limited amount of available heap memory in SRAM, but a custom
# memory allocator ensures that images are kept in the larger SDRAM area.
if (QUL_OS STREQUAL "FreeRTOS" AND NOT QUL_PLATFORM MATCHES "^stm32f769i")
    if (QUL_PLATFORM STREQUAL "mimxrt1170-evk-freertos")
        # NXP 1170 needs additional 2*3.6MB for the screen layer
        math(EXPR heap_size "8 * 1024 * 1024 + ${cache_size_in_bytes}")
    else()
        math(EXPR heap_size "1024 * 1024 + ${cache_size_in_bytes}")
    endif()
    add_compile_definitions(configTOTAL_HEAP_SIZE=${heap_size})
endif()

if(QUL_PLATFORM MATCHES "^ek-ra6m3g")
    qul_add_target(image_cache ImageModel.cpp QML_PROJECT mcu_image_cache_ek-ra6m3g.qmlproject GENERATE_ENTRYPOINT)
elseif (QUL_PLATFORM STREQUAL "rh850-d1m1a-baremetal")
    qul_add_target(image_cache ImageModel.cpp QML_PROJECT mcu_image_cache_RH850.qmlproject GENERATE_ENTRYPOINT)
elseif(QUL_PLATFORM STREQUAL "tviic2d4m-baremetal")
    qul_add_target(image_cache ImageModel.cpp QML_PROJECT mcu_image_cache_rgb565.qmlproject GENERATE_ENTRYPOINT)
else()
    qul_add_target(image_cache ImageModel.cpp QML_PROJECT mcu_image_cache.qmlproject GENERATE_ENTRYPOINT)
endif()
app_target_setup_os(image_cache)