C

Qt Quick Ultralite Thermostat Demo

cmake_minimum_required (VERSION 3.15)

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

string(TOLOWER ${QUL_PLATFORM} QUL_PLATFORM_LOWERCASE)

set(UNIT_SYSTEM "metric" CACHE STRING "Thermostat Demo Unit System")

# Set FreeRTOS heap size to 1.5 MB (needed for stats view)
if (OS STREQUAL "FreeRTOS")
    add_compile_definitions(configTOTAL_HEAP_SIZE=1572864)
endif()

set(COMMON_QML_FILES
    thermo.qml TopBar.qml BottomBar.qml PlacesView.qml Card.qml CardRow.qml PowerSwitch.qml
    ScheduleView.qml RoomSchedule.qml StatsView.qml RoomView.qml RoomControlButton.qml
    AnimatedDigit.qml WeatherStatus.qml ThermoView.qml
    TimeIntervalSlider.qml TimeIntervalSliderHandle.qml FanControlButton.qml LanguageDialog.qml
    LanguageButton.qml)
set(MODULE_QML_FILES
    imports/Thermo/ColorStyle.qml
    imports/Thermo/Rooms.qml
    imports/Thermo/Room.qml)

qul_add_target(thermo_small)

qul_add_resource(thermo_small
    BASE small
    FILES
        small/qt-logo.png
        small/JAPAN.png
        small/temp-down-pressed.png
        small/switch-handle.png
        small/popup-bg.png
        small/scrollbar-temperature-track.png
        small/radiobutton-checked-pressed.png
        small/digitMaskBottom.png
        small/switch-i.png
        small/btn-bg-big-on.png
        small/radiobutton-pressed.png
        small/pressed-bg-up.png
        small/selected.png
        small/eco-on.png
        small/streamer-on-small.png
        small/page-indicator.png
        small/jog-off.png
        small/status-small.png
        small/dryer-on-small.png
        small/dryer-on.png
        small/close.png
        small/auto-card.png
        small/toggle-year.png
        small/eco-on-small.png
        small/separator-line.png
        small/radiobutton-checked.png
        small/streamer-on.png
        small/btn-bg-down.png
        small/slider-handle.png
        small/thermo-handle.png
        small/switch-bg.png
        small/pressed-bg-down.png
        small/auto-on.png
        small/place-back.png
        small/UK.png
        small/radiobutton.png
        small/baseline-arrow-back.png
        small/digitMaskTop.png
        small/switch-o.png
        small/power-on.png
        small/temp-up-pressed.png
        small/btn-bg-big-off.png
        small/toggle-month.png
        small/jog.png
        small/GERMANY.png
        small/change-language.png
        small/scrollbar-off-track.png
        small/weather/w_06.png
        small/weather/w_01.png
        small/weather/w_02.png
        small/weather/w_07.png
        small/weather/w_05.png
        small/weather/w_04.png
        small/weather/w_03.png
)

qul_add_resource(thermo_small
    FILES
        images/inner-circle.png
        images/card-back-topleft.png
        images/card-back-bottomleft.png
        images/card-back-topright.png
        images/card-back-bottomright.png
)

if(QUL_PLATFORM_LOWERCASE MATCHES "^stm32" AND IAR)
    # For stm32f7508 together with IAR compiler there is a performance issue with
    # blending the 1 pixel width background. To avoid blending the full
    # background image is included.
    qul_add_resource(thermo_small
        BASE small
        FILES
            small/main-bg-full.png
    )
    set(ADDITIONAL_QML_FILES_SMALL "small/stm32_iar/BackgroundImage.qml")
    set(ADDITIONAL_QML_FILES_BIG "BackgroundImage.qml")
else()
    qul_add_resource(thermo_small
        BASE small
        FILES
            small/main-bg.png
    )
    list(APPEND COMMON_QML_FILES "BackgroundImage.qml")
endif()

qul_target_qml_sources(thermo_small ${COMMON_QML_FILES} ${ADDITIONAL_QML_FILES_SMALL})

qul_add_qml_module(thermo_small_module
    URI Thermo
    QML_FILES
        ${MODULE_QML_FILES}
        small/Theme.qml
        ${UNIT_SYSTEM}/Units.qml
    OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/thermo_small_module
)
qul_add_resource(thermo_small_module
    BASE small
    FILES
        small/fan-off.png
        small/fan-off-small.png
        small/fan-1-on.png
        small/fan-1-on-small.png
        small/fan-2-on.png
        small/fan-2-on-small.png
        small/fan-3-on.png
        small/fan-3-on-small.png
        small/fan-4-on.png
        small/fan-4-on-small.png
)

set_target_properties(thermo_small PROPERTIES QUL_DEFAULT_FONT_FAMILY "Roboto")
set_property(TARGET thermo_small APPEND PROPERTY QUL_FONTS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/fonts)

if(QUL_PLATFORM_LOWERCASE MATCHES "^ek-ra6m3g")
    qul_add_qml_module(thermo_configuration_small_module
        URI ThermoConfiguration
        QML_FILES
            static/StatsContents.qml
            static/Configuration.qml
        OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/thermo_configuration_small_module
    )

    qul_add_resource(thermo_configuration_small_module
        BASE small
        FILES
            small/stats-month.png
            small/stats-year.png
    )

    target_link_libraries(thermo_configuration_small_module thermo_small_module)
else()
    qul_add_qml_module(thermo_configuration_small_module
        URI ThermoConfiguration
        QML_FILES
            dynamic/StatsContents.qml
            dynamic/Configuration.qml
        OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/thermo_configuration_small_module
    )

    target_link_libraries(thermo_configuration_small_module thermo_small_module Qul::QuickUltraliteCharts)
endif()

qul_target_embed_translations(thermo_configuration_small_module thermo.de_DE.ts thermo.ja_JP.ts)
qul_target_embed_translations(thermo_small_module thermo.de_DE.ts thermo.ja_JP.ts)
qul_target_embed_translations(thermo_small thermo.de_DE.ts thermo.ja_JP.ts)

target_link_libraries(thermo_small thermo_configuration_small_module thermo_small_module Qul::QuickUltraliteTemplates)
app_target_setup_os(thermo_small)
app_target_default_entrypoint(thermo_small thermo)

# FIXME: the if below should be changed to
# if (NOT "thermo_big" IN_LIST EXCLUDED_DEMOS)
# Assets currently too big for devices (except stm32s)
if(QUL_PLATFORM STREQUAL "Qt" OR QUL_PLATFORM_LOWERCASE MATCHES "^stm32f7" OR QUL_PLATFORM_LOWERCASE MATCHES "^stm32f4")
    qul_add_target(thermo_big)

    qul_add_resource(thermo_big
        BASE big
        FILES
            big/qt-logo.png
            big/JAPAN.png
            big/temp-down-pressed.png
            big/switch-handle.png
            big/popup-bg.png
            big/scrollbar-temperature-track.png
            big/radiobutton-checked-pressed.png
            big/digitMaskBottom.png
            big/switch-i.png
            big/btn-bg-big-on.png
            big/radiobutton-pressed.png
            big/pressed-bg-up.png
            big/selected.png
            big/eco-on.png
            big/streamer-on-small.png
            big/page-indicator.png
            big/jog-off.png
            big/status-small.png
            big/dryer-on-small.png
            big/dryer-on.png
            big/close.png
            big/auto-card.png
            big/toggle-year.png
            big/eco-on-small.png
            big/separator-line.png
            big/radiobutton-checked.png
            big/streamer-on.png
            big/radiobutton-disabled.png
            big/btn-bg-down.png
            big/slider-handle.png
            big/thermo-handle.png
            big/switch-bg.png
            big/pressed-bg-down.png
            big/main-bg.png
            big/auto-on.png
            big/place-back.png
            big/UK.png
            big/radiobutton.png
            big/baseline-arrow-back.png
            big/digitMaskTop.png
            big/switch-o.png
            big/power-on.png
            big/temp-up-pressed.png
            big/btn-bg-big-off.png
            big/toggle-month.png
            big/jog.png
            big/GERMANY.png
            big/change-language.png
            big/scrollbar-off-track.png
            big/weather/w_06.png
            big/weather/w_01.png
            big/weather/w_02.png
            big/weather/w_07.png
            big/weather/w_05.png
            big/weather/w_04.png
            big/weather/w_03.png
    )

    qul_add_resource(thermo_big
        FILES
            images/inner-circle.png
            images/card-back-topleft.png
            images/card-back-bottomleft.png
            images/card-back-topright.png
            images/card-back-bottomright.png
    )

    qul_target_qml_sources(thermo_big ${COMMON_QML_FILES} ${ADDITIONAL_QML_FILES_BIG})

    qul_add_qml_module(thermo_big_module
        URI Thermo
        QML_FILES
            ${MODULE_QML_FILES}
            big/Theme.qml
            ${UNIT_SYSTEM}/Units.qml
        OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/thermo_big_module
    )
    qul_add_resource(thermo_big_module
        BASE big
        FILES
            big/fan-off.png
            big/fan-off-small.png
            big/fan-1-on.png
            big/fan-1-on-small.png
            big/fan-2-on.png
            big/fan-2-on-small.png
            big/fan-3-on.png
            big/fan-3-on-small.png
            big/fan-4-on.png
            big/fan-4-on-small.png
    )

    set_target_properties(thermo_big PROPERTIES QUL_DEFAULT_FONT_FAMILY "Roboto")
    set_property(TARGET thermo_big APPEND PROPERTY QUL_FONTS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/fonts)

    qul_add_qml_module(thermo_configuration_big_module
        URI ThermoConfiguration
        QML_FILES
            dynamic/StatsContents.qml
            dynamic/Configuration.qml
        OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/thermo_configuration_big_module
    )

    qul_target_embed_translations(thermo_configuration_big_module thermo.de_DE.ts thermo.ja_JP.ts)
    qul_target_embed_translations(thermo_big_module thermo.de_DE.ts thermo.ja_JP.ts)
    qul_target_embed_translations(thermo_big thermo.de_DE.ts thermo.ja_JP.ts)

    target_link_libraries(thermo_configuration_big_module thermo_big_module Qul::QuickUltraliteCharts)

    target_link_libraries(thermo_big thermo_configuration_big_module thermo_big_module Qul::QuickUltraliteTemplates)
    app_target_setup_os(thermo_big)
    app_target_default_entrypoint(thermo_big thermo)
endif()

include(test_automation/test_automation.cmake OPTIONAL)