From 020a7fd11d1b18fd7ac29ccc00b9c6f6e0cdb17b Mon Sep 17 00:00:00 2001 From: Max Friedrich Date: Sun, 30 Apr 2023 17:03:46 +0200 Subject: Refactor watch face to enum (#1339) change watch face from int to enum --------- Co-authored-by: minacode --- src/displayapp/WatchFaces.h | 14 ++++++++++++++ src/displayapp/screens/Clock.cpp | 15 ++++++++------- src/displayapp/screens/settings/SettingWatchFace.cpp | 7 ++++--- 3 files changed, 26 insertions(+), 10 deletions(-) create mode 100644 src/displayapp/WatchFaces.h (limited to 'src/displayapp') diff --git a/src/displayapp/WatchFaces.h b/src/displayapp/WatchFaces.h new file mode 100644 index 00000000..2982347a --- /dev/null +++ b/src/displayapp/WatchFaces.h @@ -0,0 +1,14 @@ +#pragma once + +namespace Pinetime { + namespace Applications { + enum class WatchFace : uint8_t { + Digital = 0, + Analog = 1, + PineTimeStyle = 2, + Terminal = 3, + Infineat = 4, + CasioStyleG7710 = 5, + }; + } +} diff --git a/src/displayapp/screens/Clock.cpp b/src/displayapp/screens/Clock.cpp index a03dc68b..ce70f23f 100644 --- a/src/displayapp/screens/Clock.cpp +++ b/src/displayapp/screens/Clock.cpp @@ -15,6 +15,7 @@ #include "displayapp/screens/WatchFaceCasioStyleG7710.h" using namespace Pinetime::Applications::Screens; +using namespace Pinetime::Applications; Clock::Clock(Controllers::DateTime& dateTimeController, const Controllers::Battery& batteryController, @@ -33,23 +34,23 @@ Clock::Clock(Controllers::DateTime& dateTimeController, motionController {motionController}, filesystem {filesystem}, screen {[this, &settingsController]() { - switch (settingsController.GetClockFace()) { - case 0: + switch (settingsController.GetWatchFace()) { + case WatchFace::Digital: return WatchFaceDigitalScreen(); break; - case 1: + case WatchFace::Analog: return WatchFaceAnalogScreen(); break; - case 2: + case WatchFace::PineTimeStyle: return WatchFacePineTimeStyleScreen(); break; - case 3: + case WatchFace::Terminal: return WatchFaceTerminalScreen(); break; - case 4: + case WatchFace::Infineat: return WatchFaceInfineatScreen(); break; - case 5: + case WatchFace::CasioStyleG7710: return WatchFaceCasioStyleG7710(); break; } diff --git a/src/displayapp/screens/settings/SettingWatchFace.cpp b/src/displayapp/screens/settings/SettingWatchFace.cpp index 285efa72..5498d067 100644 --- a/src/displayapp/screens/settings/SettingWatchFace.cpp +++ b/src/displayapp/screens/settings/SettingWatchFace.cpp @@ -3,6 +3,7 @@ #include "displayapp/DisplayApp.h" #include "displayapp/screens/Screen.h" #include "components/settings/Settings.h" +#include "displayapp/WatchFaces.h" using namespace Pinetime::Applications::Screens; @@ -47,9 +48,9 @@ std::unique_ptr SettingWatchFace::CreateScreen(unsigned int screenNum) c nScreens, title, symbol, - settingsController.GetClockFace(), - [&settings = settingsController](uint32_t clockFace) { - settings.SetClockFace(clockFace); + static_cast(settingsController.GetWatchFace()), + [&settings = settingsController](uint32_t index) { + settings.SetWatchFace(static_cast(index)); settings.SaveSettings(); }, watchfacesOnThisScreen); -- cgit v1.2.3-70-g09d2