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)
This commit is contained in:
Jean-François Milants
2023-12-10 18:35:19 +01:00
committed by JF
parent a544da9ed1
commit 39bc166e54
16 changed files with 216 additions and 259 deletions

View File

@@ -19,7 +19,10 @@ namespace Pinetime {
class SettingWatchFace : public Screen {
public:
SettingWatchFace(DisplayApp* app, Pinetime::Controllers::Settings& settingsController, Pinetime::Controllers::FS& filesystem);
SettingWatchFace(DisplayApp* app,
std::array<Screens::CheckboxList::Item, UserWatchFaceTypes::Count>&& watchfaceItems,
Pinetime::Controllers::Settings& settingsController,
Pinetime::Controllers::FS& filesystem);
~SettingWatchFace() override;
bool OnTouchEvent(TouchEvents event) override;
@@ -29,26 +32,16 @@ namespace Pinetime {
auto CreateScreenList() const;
std::unique_ptr<Screen> CreateScreen(unsigned int screenNum) const;
static constexpr int settingsPerScreen = 4;
std::array<Screens::CheckboxList::Item, UserWatchFaceTypes::Count> watchfaceItems;
static constexpr int nScreens = UserWatchFaceTypes::Count > 0 ? (UserWatchFaceTypes ::Count - 1) / settingsPerScreen + 1 : 1;
Controllers::Settings& settingsController;
Pinetime::Controllers::FS& filesystem;
static constexpr const char* title = "Watch face";
static constexpr const char* symbol = Symbols::home;
static constexpr int settingsPerScreen = 4;
// Increment this when more space is needed
static constexpr int nScreens = 2;
std::array<Screens::CheckboxList::Item, settingsPerScreen * nScreens> watchfaces {
{{"Digital face", true},
{"Analog face", true},
{"PineTimeStyle", true},
{"Terminal", true},
{"Infineat face", Applications::Screens::WatchFaceInfineat::IsAvailable(filesystem)},
{"Casio G7710", Applications::Screens::WatchFaceCasioStyleG7710::IsAvailable(filesystem)},
{"", false},
{"", false}}};
ScreenList<nScreens> screens;
};
}