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 MATCHES "^tviic2d4m")
# 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()

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 MATCHES "^rh850-d1m1a")
    qul_add_target(image_cache ImageModel.cpp QML_PROJECT mcu_image_cache_RH850.qmlproject GENERATE_ENTRYPOINT)
elseif(QUL_PLATFORM MATCHES "^tviic2d4m")
    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()

# 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-evkb-freertos")
        # NXP 1170 needs additional 2*3.6MB for the screen layer
        qul_override_freertos_heap_size(image_cache "8 * 1024 * 1024 + ${cache_size_in_bytes}")
    else()
        qul_override_freertos_heap_size(image_cache "1024 * 1024 + ${cache_size_in_bytes}")
    endif()
endif()

app_target_setup_os(image_cache)