diff options
| author | Jean-François Milants <jf@codingfield.com> | 2023-12-10 18:35:19 +0100 |
|---|---|---|
| committer | JF <JF002@users.noreply.github.com> | 2023-12-21 20:49:22 +0100 |
| commit | 39bc166e549e8ccae75468aa2dd3613d51f54e27 (patch) | |
| tree | f4f995bf75e1a8e6bd9db9d1e84b225f3c53d686 /src/displayapp/DisplayApp.cpp | |
| parent | a544da9ed174bc184176ae50bedda5dd51c06021 (diff) | |
Watch face selection at build time
Watch faces can now be selected at buid time. It's implemented in a similar way than the selection of user apps, using a list of watch face description that is generated at build time (consteval, constexpr)
Diffstat (limited to 'src/displayapp/DisplayApp.cpp')
| -rw-r--r-- | src/displayapp/DisplayApp.cpp | 48 |
1 files changed, 22 insertions, 26 deletions
diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp index 98be6324..3b34d7b8 100644 --- a/src/displayapp/DisplayApp.cpp +++ b/src/displayapp/DisplayApp.cpp @@ -11,7 +11,6 @@ #include "components/motion/MotionController.h" #include "components/motor/MotorController.h" #include "displayapp/screens/ApplicationList.h" -#include "displayapp/screens/Clock.h" #include "displayapp/screens/FirmwareUpdate.h" #include "displayapp/screens/FirmwareValidation.h" #include "displayapp/screens/InfiniPaint.h" @@ -435,17 +434,17 @@ void DisplayApp::LoadScreen(Apps app, DisplayApp::FullRefreshDirections directio filesystem, std::move(apps)); } break; - case Apps::Clock: - currentScreen = std::make_unique<Screens::Clock>(dateTimeController, - batteryController, - bleController, - notificationManager, - settingsController, - heartRateController, - motionController, - systemTask->nimble().weather(), - filesystem); - break; + case Apps::Clock: { + const auto* watchFace = + std::find_if(userWatchFaces.begin(), userWatchFaces.end(), [this](const WatchFaceDescription& watchfaceDescription) { + return watchfaceDescription.watchFace == settingsController.GetWatchFace(); + }); + if (watchFace != userWatchFaces.end()) + currentScreen.reset(watchFace->create(controllers)); + else { + currentScreen.reset(userWatchFaces[0].create(controllers)); + } + } break; case Apps::Error: currentScreen = std::make_unique<Screens::Error>(bootError); break; @@ -489,9 +488,14 @@ void DisplayApp::LoadScreen(Apps app, DisplayApp::FullRefreshDirections directio case Apps::Settings: currentScreen = std::make_unique<Screens::Settings>(this, settingsController); break; - case Apps::SettingWatchFace: - currentScreen = std::make_unique<Screens::SettingWatchFace>(this, settingsController, filesystem); - break; + case Apps::SettingWatchFace: { + std::array<Screens::CheckboxList::Item, UserWatchFaceTypes::Count> items; + int i = 0; + for (const auto& userWatchFace : userWatchFaces) { + items[i++] = Screens::CheckboxList::Item {userWatchFace.name, userWatchFace.isAvailable(controllers.filesystem)}; + } + currentScreen = std::make_unique<Screens::SettingWatchFace>(this, std::move(items), settingsController, filesystem); + } break; case Apps::SettingTimeFormat: currentScreen = std::make_unique<Screens::SettingTimeFormat>(settingsController); break; @@ -536,18 +540,10 @@ void DisplayApp::LoadScreen(Apps app, DisplayApp::FullRefreshDirections directio const auto* d = std::find_if(userApps.begin(), userApps.end(), [app](const AppDescription& appDescription) { return appDescription.app == app; }); - if (d != userApps.end()) + if (d != userApps.end()) { currentScreen.reset(d->create(controllers)); - else { - currentScreen = std::make_unique<Screens::Clock>(dateTimeController, - batteryController, - bleController, - notificationManager, - settingsController, - heartRateController, - motionController, - systemTask->nimble().weather(), - filesystem); + } else { + currentScreen.reset(userWatchFaces[0].create(controllers)); } break; } |
