InfiniTime/doc/watchfaces.md

54 lines
2.6 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Adapting old watchfaces:
- When resolving conflicts, delete clock.h/.cpp, keep both in CMakeLists.cpp, accept current in SettingWatchFace.cpp, and keep both if there are any changes in fonts.
- Add entry to WatchFace enum in displayapp/apps/Apps.h.in
- Remove `DisplayApp* app` param from constructor in .h and .cpp and remove Screen(app) from initializer list on constructor in .cpp
- Add const to batteryController and bleController is present in constructor params and in private members in .h
- In .cpp, remove `#include <date/date.h>` and convert calls to get time to format like in working watch faces. For example:
```cpp
auto newDateTime = currentDateTime.Get();
auto dp = date::floor<date::days>(newDateTime);
auto time = date::make_time(newDateTime - dp);
uint8_t hour = time.hours().count();
uint8_t minute = time.minutes().count();
```
with
```cpp
    uint8_t hour = dateTimeController.Hours();
    uint8_t minute = dateTimeController.Minutes();
```
, add
```cpp
Utility::DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::days>> currentDate;
```
to .h
- Remove `motionSensorOk = motionController.IsSensorOk();` and reference to `motionSensorOk` in following if
- In .h add `#include "utility/DirtyValue.h"` and replace all `DirtyValue<>` vars with `Utility::DirtyValue<>`
- Add WatchFaceTraits:
``` cpp
template <>
struct WatchFaceTraits<WatchFace::Digital> {
static constexpr WatchFace watchFace = WatchFace::Digital;
static constexpr const char* name = "Digital face";
static Screens::Screen* Create(AppControllers& controllers) {
return new Screens::WatchFaceDigital(controllers.dateTimeController,
controllers.batteryController,
controllers.bleController,
controllers.notificationManager,
controllers.settingsController,
controllers.heartRateController,
controllers.motionController,                                             controllers.filesystem
*controllers.weatherController);
};
      static bool IsAvailable(Pinetime::Controllers::FS& filesystem) {
        return Screens::WatchFaceCasioStyleG7710::IsAvailable(filesystem);
      }
};
```
modify as necesary.
- Add include to UserApps.h: `#include "displayapp/screens/WatchFace---.h"`
- Add to displayapp/apps/CMakeLists.txt