Skip to content

Commit 7ade442

Browse files
committed
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
1 parent 06c4d1f commit 7ade442

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,13 @@ if(BUILD_RESOURCES)
316316
endif()
317317
endif()
318318

319+
# check if AlarmController.h needs FileSystem member
320+
file(STRINGS "${InfiniTime_DIR}/src/components/alarm/AlarmController.h" alarmControllerFileSystemEntries REGEX "Controllers::FS")
321+
if(NOT alarmControllerFileSystemEntries STREQUAL "")
322+
message(STATUS "detected AlarmController.h using 'Controllers::FS'")
323+
set_source_files_properties(main.cpp PROPERTIES COMPILE_DEFINITIONS ALARMCONTROLLER_NEEDS_FS)
324+
endif()
325+
319326
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
320327
# Special case for SDL2 dependency, goal is to find a config that exports SDL2::SDL2 target
321328
# libsdl2-dev has a `sdl2-config.cmake` that doesn't export this, but vcpkg does..

main.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,11 @@ Pinetime::Controllers::MotionController motionController;
354354
Pinetime::Controllers::TimerController timerController;
355355
#endif
356356

357+
#if defined(ALARMCONTROLLER_NEEDS_FS)
358+
Pinetime::Controllers::AlarmController alarmController {dateTimeController, fs};
359+
#else
357360
Pinetime::Controllers::AlarmController alarmController {dateTimeController};
361+
#endif
358362
Pinetime::Controllers::TouchHandler touchHandler;
359363
Pinetime::Controllers::ButtonHandler buttonHandler;
360364
Pinetime::Controllers::BrightnessController brightnessController {};

0 commit comments

Comments
 (0)