From 39bc166e549e8ccae75468aa2dd3613d51f54e27 Mon Sep 17 00:00:00 2001 From: Jean-François Milants Date: Sun, 10 Dec 2023 18:35:19 +0100 Subject: 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) --- src/displayapp/UserApps.h | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'src/displayapp/UserApps.h') diff --git a/src/displayapp/UserApps.h b/src/displayapp/UserApps.h index 0ed9d602..cb6d5779 100644 --- a/src/displayapp/UserApps.h +++ b/src/displayapp/UserApps.h @@ -7,7 +7,12 @@ #include "displayapp/screens/Twos.h" #include "displayapp/screens/Tile.h" #include "displayapp/screens/ApplicationList.h" -#include "displayapp/screens/Clock.h" +#include "displayapp/screens/WatchFaceDigital.h" +#include "displayapp/screens/WatchFaceAnalog.h" +#include "displayapp/screens/WatchFaceCasioStyleG7710.h" +#include "displayapp/screens/WatchFaceInfineat.h" +#include "displayapp/screens/WatchFacePineTimeStyle.h" +#include "displayapp/screens/WatchFaceTerminal.h" namespace Pinetime { namespace Applications { @@ -21,16 +26,34 @@ namespace Pinetime { Screens::Screen* (*create)(AppControllers& controllers); }; + struct WatchFaceDescription { + WatchFace watchFace; + const char* name; + Screens::Screen* (*create)(AppControllers& controllers); + bool (*isAvailable)(Controllers::FS& fileSystem); + }; + template consteval AppDescription CreateAppDescription() { return {AppTraits::app, AppTraits::icon, &AppTraits::Create}; } + template + consteval WatchFaceDescription CreateWatchFaceDescription() { + return {WatchFaceTraits::watchFace, WatchFaceTraits::name, &WatchFaceTraits::Create, &WatchFaceTraits::IsAvailable}; + } + template