From 7ade4425c43b4446af7d07d4014c5c60cf838652 Mon Sep 17 00:00:00 2001 From: Reinhold Gschweicher Date: Thu, 19 Sep 2024 20:59:44 +0200 Subject: [PATCH] Conditionally pass Controllers::FS to AlarmController to support save to file Support for InfiniTimeOrg/InfiniTime#1367 which is a rebase/improvement of InfiniTimeOrg/InfiniTime#1333 by @ght The PR adds saving and restoring alarm state to the SPI NOR flash. So the AlarmController needs the FileSystem-controller to work. To support both the current `main` branch and the "save-alarm-to-file" PR pass the Filesystem controller conditionally, only if `Controller::FS` is mentioned in the `AlarmController.h` file --- CMakeLists.txt | 7 +++++++ main.cpp | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5136220..c41bdcf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -316,6 +316,13 @@ if(BUILD_RESOURCES) endif() endif() +# check if AlarmController.h needs FileSystem member +file(STRINGS "${InfiniTime_DIR}/src/components/alarm/AlarmController.h" alarmControllerFileSystemEntries REGEX "Controllers::FS") +if(NOT alarmControllerFileSystemEntries STREQUAL "") + message(STATUS "detected AlarmController.h using 'Controllers::FS'") + set_source_files_properties(main.cpp PROPERTIES COMPILE_DEFINITIONS ALARMCONTROLLER_NEEDS_FS) +endif() + list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") # Special case for SDL2 dependency, goal is to find a config that exports SDL2::SDL2 target # libsdl2-dev has a `sdl2-config.cmake` that doesn't export this, but vcpkg does.. diff --git a/main.cpp b/main.cpp index 1f22066..f410c73 100644 --- a/main.cpp +++ b/main.cpp @@ -354,7 +354,11 @@ Pinetime::Controllers::MotionController motionController; Pinetime::Controllers::TimerController timerController; #endif +#if defined(ALARMCONTROLLER_NEEDS_FS) +Pinetime::Controllers::AlarmController alarmController {dateTimeController, fs}; +#else Pinetime::Controllers::AlarmController alarmController {dateTimeController}; +#endif Pinetime::Controllers::TouchHandler touchHandler; Pinetime::Controllers::ButtonHandler buttonHandler; Pinetime::Controllers::BrightnessController brightnessController {};