Refactor watch face to enum (#1339)

change watch face from int to enum

---------

Co-authored-by: minacode <minamoto9@web.de>
This commit is contained in:
Max Friedrich 2023-04-30 17:03:46 +02:00 committed by GitHub
parent 5f19f689f9
commit 020a7fd11d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 34 additions and 16 deletions

View File

@ -604,6 +604,7 @@ set(INCLUDE_FILES
displayapp/screens/ApplicationList.h displayapp/screens/ApplicationList.h
displayapp/screens/CheckboxList.h displayapp/screens/CheckboxList.h
displayapp/Apps.h displayapp/Apps.h
displayapp/WatchFaces.h
displayapp/screens/Notifications.h displayapp/screens/Notifications.h
displayapp/screens/HeartRate.h displayapp/screens/HeartRate.h
displayapp/screens/Metronome.h displayapp/screens/Metronome.h

View File

@ -3,6 +3,7 @@
#include <bitset> #include <bitset>
#include "components/brightness/BrightnessController.h" #include "components/brightness/BrightnessController.h"
#include "components/fs/FS.h" #include "components/fs/FS.h"
#include "displayapp/WatchFaces.h"
namespace Pinetime { namespace Pinetime {
namespace Controllers { namespace Controllers {
@ -61,15 +62,15 @@ namespace Pinetime {
void Init(); void Init();
void SaveSettings(); void SaveSettings();
void SetClockFace(uint8_t face) { void SetWatchFace(Pinetime::Applications::WatchFace face) {
if (face != settings.clockFace) { if (face != settings.watchFace) {
settingsChanged = true; settingsChanged = true;
} }
settings.clockFace = face; settings.watchFace = face;
}; };
uint8_t GetClockFace() const { Pinetime::Applications::WatchFace GetWatchFace() const {
return settings.clockFace; return settings.watchFace;
}; };
void SetChimeOption(ChimesOption chimeOption) { void SetChimeOption(ChimesOption chimeOption) {
@ -276,7 +277,7 @@ namespace Pinetime {
ClockType clockType = ClockType::H24; ClockType clockType = ClockType::H24;
Notification notificationStatus = Notification::On; Notification notificationStatus = Notification::On;
uint8_t clockFace = 0; Pinetime::Applications::WatchFace watchFace = Pinetime::Applications::WatchFace::Digital;
ChimesOption chimesOption = ChimesOption::None; ChimesOption chimesOption = ChimesOption::None;
PineTimeStyle PTS; PineTimeStyle PTS;

View File

@ -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,
};
}
}

View File

@ -15,6 +15,7 @@
#include "displayapp/screens/WatchFaceCasioStyleG7710.h" #include "displayapp/screens/WatchFaceCasioStyleG7710.h"
using namespace Pinetime::Applications::Screens; using namespace Pinetime::Applications::Screens;
using namespace Pinetime::Applications;
Clock::Clock(Controllers::DateTime& dateTimeController, Clock::Clock(Controllers::DateTime& dateTimeController,
const Controllers::Battery& batteryController, const Controllers::Battery& batteryController,
@ -33,23 +34,23 @@ Clock::Clock(Controllers::DateTime& dateTimeController,
motionController {motionController}, motionController {motionController},
filesystem {filesystem}, filesystem {filesystem},
screen {[this, &settingsController]() { screen {[this, &settingsController]() {
switch (settingsController.GetClockFace()) { switch (settingsController.GetWatchFace()) {
case 0: case WatchFace::Digital:
return WatchFaceDigitalScreen(); return WatchFaceDigitalScreen();
break; break;
case 1: case WatchFace::Analog:
return WatchFaceAnalogScreen(); return WatchFaceAnalogScreen();
break; break;
case 2: case WatchFace::PineTimeStyle:
return WatchFacePineTimeStyleScreen(); return WatchFacePineTimeStyleScreen();
break; break;
case 3: case WatchFace::Terminal:
return WatchFaceTerminalScreen(); return WatchFaceTerminalScreen();
break; break;
case 4: case WatchFace::Infineat:
return WatchFaceInfineatScreen(); return WatchFaceInfineatScreen();
break; break;
case 5: case WatchFace::CasioStyleG7710:
return WatchFaceCasioStyleG7710(); return WatchFaceCasioStyleG7710();
break; break;
} }

View File

@ -3,6 +3,7 @@
#include "displayapp/DisplayApp.h" #include "displayapp/DisplayApp.h"
#include "displayapp/screens/Screen.h" #include "displayapp/screens/Screen.h"
#include "components/settings/Settings.h" #include "components/settings/Settings.h"
#include "displayapp/WatchFaces.h"
using namespace Pinetime::Applications::Screens; using namespace Pinetime::Applications::Screens;
@ -47,9 +48,9 @@ std::unique_ptr<Screen> SettingWatchFace::CreateScreen(unsigned int screenNum) c
nScreens, nScreens,
title, title,
symbol, symbol,
settingsController.GetClockFace(), static_cast<uint32_t>(settingsController.GetWatchFace()),
[&settings = settingsController](uint32_t clockFace) { [&settings = settingsController](uint32_t index) {
settings.SetClockFace(clockFace); settings.SetWatchFace(static_cast<WatchFace>(index));
settings.SaveSettings(); settings.SaveSettings();
}, },
watchfacesOnThisScreen); watchfacesOnThisScreen);