Skip to content

Commit

Permalink
Conditionally pass Controllers::FS to AlarmController to support save…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
NeroBurner committed Sep 19, 2024
1 parent 06c4d1f commit 26395a4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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..
Expand Down
4 changes: 4 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {};
Expand Down

0 comments on commit 26395a4

Please sign in to comment.