C
Qt Quick Ultralite Thermostat Demo
cmake_minimum_required (VERSION 3.21.1)
project(thermo VERSION 0.0.1 LANGUAGES C CXX ASM)
if (NOT TARGET Qul::Core)
find_package(Qul)
endif()
qul_add_target(thermo_small src/os/${QUL_OS_LOWERCASE}/main.cpp)
set(UNIT_SYSTEM "metric" CACHE STRING "Thermostat Demo Unit System")
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 StatsContents.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)
if(QUL_PLATFORM MATCHES "^ek-ra6m3g")
set(ANIM_CONFIG "static" CACHE STRING "Thermostat Demo Animation Configuration")
else()
set(ANIM_CONFIG "dynamic" CACHE STRING "Thermostat Demo Animation Configuration")
endif()
if(QUL_PLATFORM MATCHES "^ek-ra6m3g")
set(FONT_ENGINE "Static" CACHE STRING "Thermostat Demo Font Engine")
else()
set(FONT_ENGINE "Spark" CACHE STRING "Thermostat Demo Font Engine")
endif()
if(FONT_ENGINE STREQUAL "Static")
set(TRANSLATION_FILES
thermo.de_DE.ts
thermo.ja_JP.ts)
set(DEFAULT_FONT_FAMILY "Roboto")
set(FONT_FILES
NotoSansArabic-Regular.ttf
NotoSansJP-Regular.otf
NotoSansThai-Regular.ttf
Roboto-Regular.ttf
)
else()
set(TRANSLATION_FILES
thermo.de_DE.ts
thermo.hi_IN.ts
thermo.ja_JP.ts
thermo.ar_EG.ts
thermo.th_TH.ts)
set(DEFAULT_FONT_FAMILY "regular")
set(FONT_FILES
ThermoDemoFontmap.fmp
)
endif()
list(TRANSFORM FONT_FILES PREPEND ${CMAKE_CURRENT_SOURCE_DIR}/fonts/)
qul_add_resource(thermo_small
BASE ${FONT_ENGINE}FE/+small
FILES
${FONT_ENGINE}FE/+small/popup-bg.png
)
# NXP RT1064 has 4M of flash. Enable QUL_RESOURCE_COMPRESSION to accomodate resources into limited flash space of NXP RT1064
if (QUL_PLATFORM STREQUAL "mimxrt1064-evk-baremetal" OR QUL_PLATFORM STREQUAL "mimxrt1064-evk-freertos")
qul_set_maximum_resource_cache_size(thermo_small CACHE_SIZE 1048576)
set(QUL_DEFAULT_RESOURCE_CACHE_POLICY "OnDemand")
set(QUL_DEFAULT_RESOURCE_COMPRESSION ON)
endif()
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/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/EGYPT.png
+small/THAILAND.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/stats-month.png
+small/stats-year.png
+small/INDIA.png
+small/top-bar-shadow.png
)
qul_add_resource(thermo_small
BASE "weather/+small"
PREFIX "weather"
FILES
weather/+small/w_06.png
weather/+small/w_01.png
weather/+small/w_02.png
weather/+small/w_07.png
weather/+small/w_05.png
weather/+small/w_04.png
weather/+small/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
)
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 "${DEFAULT_FONT_FAMILY}"
QUL_FONT_ENGINE "${FONT_ENGINE}"
QUL_FONT_FILES "${FONT_FILES}"
)
if(FONT_ENGINE STREQUAL "Spark")
if(QUL_PLATFORM MATCHES "^stm32")
# Enable preallocation of the spark heap to ensure it ends up in SDRAM
set_target_properties(thermo_small
PROPERTIES
QUL_FONT_HEAP_SIZE 100000)
elseif(QUL_PLATFORM MATCHES "^ek-ra6m3g")
set_target_properties(thermo_small
PROPERTIES
QUL_FONT_HEAP_SIZE 24000
QUL_FONT_CACHE_SIZE 100000)
endif()
endif()
if (QUL_PLATFORM STREQUAL "mimxrt1050-evk-freertos" OR QUL_PLATFORM STREQUAL "mimxrt1064-evk-freertos")
# default FreeRTOS heap size 256k
math(EXPR heap_size "2148 * 1024")
add_compile_definitions(configTOTAL_HEAP_SIZE=${heap_size})
endif()
qul_add_qml_module(thermo_configuration_small_module
URI ThermoConfiguration
QML_FILES
fonts/${FONT_ENGINE}/FontConfiguration.qml
${ANIM_CONFIG}/Configuration.qml
OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/thermo_configuration_small_module
)
qul_target_embed_translations(thermo_configuration_small_module ${TRANSLATION_FILES})
qul_target_embed_translations(thermo_small_module ${TRANSLATION_FILES})
qul_target_embed_translations(thermo_small ${TRANSLATION_FILES})
if(QUL_PLATFORM MATCHES "^stm32h7")
math(EXPR text_cache_size "32 * 1024")
target_compile_definitions(thermo_small PRIVATE APP_TEXT_CACHE_SIZE=${text_cache_size})
endif()
target_link_libraries(thermo_small PRIVATE thermo_configuration_small_module thermo_small_module Qul::ControlsTemplates)
app_target_setup_os(thermo_small)
# FIXME: the if below should be changed to
# if (NOT "thermo_big" IN_LIST QUL_PLATFORM_EXCLUDED_DEMOS)
# Assets currently too big for devices (except stm32s)
if(QUL_PLATFORM STREQUAL "qt" OR QUL_PLATFORM MATCHES "^stm32f7" OR QUL_PLATFORM MATCHES "^stm32f4")
qul_add_target(thermo_big src/os/${QUL_OS_LOWERCASE}/main.cpp)
qul_add_resource(thermo_big
BASE ${FONT_ENGINE}FE/+big
FILES
${FONT_ENGINE}FE/+big/popup-bg.png
)
if(QUL_PLATFORM MATCHES "^stm32f4")
math(EXPR text_cache_size "48 * 1024")
target_compile_definitions(thermo_big PRIVATE APP_TEXT_CACHE_SIZE=${text_cache_size})
endif()
if(QUL_PLATFORM MATCHES "^stm32f7")
math(EXPR text_cache_size "64 * 1024")
target_compile_definitions(thermo_big PRIVATE APP_TEXT_CACHE_SIZE=${text_cache_size})
if (QUL_OS STREQUAL "FreeRTOS")
# 200 kB is the default heap size for STM32F769i, but we need to add
# space for the text cache as well
math(EXPR heap_size "200 * 1024 + ${text_cache_size}")
add_compile_definitions(configTOTAL_HEAP_SIZE=${heap_size})
endif()
endif()
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/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/auto-on.png
+big/place-back.png
+big/UK.png
+big/EGYPT.png
+big/THAILAND.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/stats-month.png
+big/stats-year.png
+big/INDIA.png
+big/top-bar-shadow.png
)
qul_add_resource(thermo_big
BASE "weather/+big"
PREFIX "weather"
FILES
weather/+big/w_06.png
weather/+big/w_01.png
weather/+big/w_02.png
weather/+big/w_07.png
weather/+big/w_05.png
weather/+big/w_04.png
weather/+big/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 "${DEFAULT_FONT_FAMILY}"
QUL_FONT_ENGINE "${FONT_ENGINE}"
QUL_FONT_FILES "${FONT_FILES}"
)
if(FONT_ENGINE STREQUAL "Spark" AND QUL_PLATFORM MATCHES "^stm32")
# Enable preallocation of the spark heap to ensure it ends up in SDRAM
set_target_properties(thermo_big
PROPERTIES
QUL_FONT_HEAP_SIZE 100000)
endif()
qul_add_qml_module(thermo_configuration_big_module
URI ThermoConfiguration
QML_FILES
fonts/${FONT_ENGINE}/FontConfiguration.qml
${ANIM_CONFIG}/Configuration.qml
OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/thermo_configuration_big_module
)
qul_target_embed_translations(thermo_configuration_big_module ${TRANSLATION_FILES})
qul_target_embed_translations(thermo_big_module ${TRANSLATION_FILES})
qul_target_embed_translations(thermo_big ${TRANSLATION_FILES})
target_link_libraries(thermo_big PRIVATE thermo_configuration_big_module thermo_big_module Qul::ControlsTemplates)
app_target_setup_os(thermo_big)
endif()
if (QUL_BUILD_QMLPROJECT_DEMOS)
if(QUL_PLATFORM MATCHES "^ek-ra6m3g")
qul_add_target(thermo_small_qmlproject
src/os/${QUL_OS_LOWERCASE}/main.cpp
QML_PROJECT
qmlproject/thermo_ek-ra6m3g.qmlproject
SELECTORS small
)
elseif (QUL_PLATFORM STREQUAL "mimxrt1064-evk-baremetal" OR QUL_PLATFORM STREQUAL "mimxrt1064-evk-freertos")
qul_add_target(thermo_small_qmlproject
src/os/${QUL_OS_LOWERCASE}/main.cpp
QML_PROJECT
qmlproject/thermo_small_mimxrt1064.qmlproject
SELECTORS small
)
else()
qul_add_target(thermo_small_qmlproject
src/os/${QUL_OS_LOWERCASE}/main.cpp
QML_PROJECT
qmlproject/thermo.qmlproject
SELECTORS small
)
endif()
if (QUL_PLATFORM STREQUAL "mimxrt1050-evk-freertos" OR QUL_PLATFORM STREQUAL "mimxrt1064-evk-freertos")
# default FreeRTOS heap size 256k
math(EXPR heap_size "2048 * 1024")
add_compile_definitions(configTOTAL_HEAP_SIZE=${heap_size})
endif()
if(QUL_PLATFORM MATCHES "^stm32h7")
math(EXPR text_cache_size "32 * 1024")
target_compile_definitions(thermo_small_qmlproject PRIVATE APP_TEXT_CACHE_SIZE=${text_cache_size})
endif()
app_target_setup_os(thermo_small_qmlproject)
# FIXME: the if below should be changed to
# if (NOT "thermo_big" IN_LIST QUL_PLATFORM_EXCLUDED_DEMOS)
# Assets currently too big for devices (except stm32s)
if(QUL_PLATFORM STREQUAL "qt" OR QUL_PLATFORM MATCHES "^stm32f7" OR QUL_PLATFORM MATCHES "^stm32f4")
qul_add_target(thermo_big_qmlproject
src/os/${QUL_OS_LOWERCASE}/main.cpp
QML_PROJECT
qmlproject/thermo.qmlproject
SELECTORS big)
if(QUL_PLATFORM MATCHES "^stm32f4")
math(EXPR text_cache_size "48 * 1024")
target_compile_definitions(thermo_big_qmlproject PRIVATE APP_TEXT_CACHE_SIZE=${text_cache_size})
endif()
if(QUL_PLATFORM MATCHES "^stm32f7")
math(EXPR text_cache_size "64 * 1024")
target_compile_definitions(thermo_big_qmlproject PRIVATE APP_TEXT_CACHE_SIZE=${text_cache_size})
if (QUL_OS STREQUAL "FreeRTOS")
# 200 kB is the default heap size for STM32F769i, but we need to add
# space for the text cache as well
math(EXPR heap_size "200 * 1024 + ${text_cache_size}")
add_compile_definitions(configTOTAL_HEAP_SIZE=${heap_size})
endif()
endif()
app_target_setup_os(thermo_big_qmlproject)
endif()
endif()