Skip to content

Commit

Permalink
Update Star Trek Watchface to 1.12.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Lennart Jahn committed Apr 8, 2023
1 parent c35a65a commit 6ecf80a
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 39 deletions.
3 changes: 1 addition & 2 deletions src/displayapp/screens/Clock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@ std::unique_ptr<Screen> Clock::WatchFaceCasioStyleG7710() {
}

std::unique_ptr<Screen> Clock::WatchFaceStarTrekScreen() {
return std::make_unique<Screens::WatchFaceStarTrek>(app,
dateTimeController,
return std::make_unique<Screens::WatchFaceStarTrek>(dateTimeController,
batteryController,
bleController,
notificationManager,
Expand Down
31 changes: 11 additions & 20 deletions src/displayapp/screens/WatchFaceStarTrek.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "displayapp/screens/WatchFaceStarTrek.h"

#include <date/date.h>
#include <lvgl/lvgl.h>
#include <cstdio>
#include "displayapp/screens/BatteryIcon.h"
Expand Down Expand Up @@ -33,17 +32,16 @@ using namespace Pinetime::Applications::Screens;
#define COLOR_BLACK lv_color_hex(0x000000)
#define COLOR_WHITE lv_color_hex(0xffffff)

WatchFaceStarTrek::WatchFaceStarTrek(DisplayApp* app,
Controllers::DateTime& dateTimeController,
Controllers::Battery& batteryController,
Controllers::Ble& bleController,
WatchFaceStarTrek::WatchFaceStarTrek(Controllers::DateTime& dateTimeController,
const Controllers::Battery& batteryController,
const Controllers::Ble& bleController,
Controllers::NotificationManager& notificatioManager,
Controllers::Settings& settingsController,
Controllers::HeartRateController& heartRateController,
Controllers::MotionController& motionController,
Controllers::FS& filesystem)
: Screen(app),
currentDateTime {{}},
: currentDateTime {{}},
batteryIcon(false),
dateTimeController {dateTimeController},
batteryController {batteryController},
bleController {bleController},
Expand Down Expand Up @@ -248,19 +246,12 @@ void WatchFaceStarTrek::Refresh() {
currentDateTime = dateTimeController.CurrentDateTime();

if (currentDateTime.IsUpdated()) {
auto newDateTime = currentDateTime.Get();

auto dp = date::floor<date::days>(newDateTime);
auto time = date::make_time(newDateTime - dp);
auto yearMonthDay = date::year_month_day(dp);

auto year = static_cast<int>(yearMonthDay.year());
auto month = static_cast<Pinetime::Controllers::DateTime::Months>(static_cast<unsigned>(yearMonthDay.month()));
auto day = static_cast<unsigned>(yearMonthDay.day());
auto dayOfWeek = static_cast<Pinetime::Controllers::DateTime::Days>(date::weekday(yearMonthDay).iso_encoding());

uint8_t hour = time.hours().count();
uint8_t minute = time.minutes().count();
auto hour = dateTimeController.Hours();
auto minute = dateTimeController.Minutes();
auto year = dateTimeController.Year();
auto month = dateTimeController.Month();
auto dayOfWeek = dateTimeController.DayOfWeek();
auto day = dateTimeController.Day();

if (displayedHour != hour || displayedMinute != minute) {
displayedHour = hour;
Expand Down
32 changes: 16 additions & 16 deletions src/displayapp/screens/WatchFaceStarTrek.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "displayapp/screens/Screen.h"
#include "components/datetime/DateTimeController.h"
#include "components/ble/BleController.h"
#include "utility/DirtyValue.h"

namespace Pinetime {
namespace Controllers {
Expand All @@ -24,10 +25,9 @@ namespace Pinetime {

class WatchFaceStarTrek : public Screen {
public:
WatchFaceStarTrek(DisplayApp* app,
Controllers::DateTime& dateTimeController,
Controllers::Battery& batteryController,
Controllers::Ble& bleController,
WatchFaceStarTrek(Controllers::DateTime& dateTimeController,
const Controllers::Battery& batteryController,
const Controllers::Ble& bleController,
Controllers::NotificationManager& notificatioManager,
Controllers::Settings& settingsController,
Controllers::HeartRateController& heartRateController,
Expand All @@ -48,16 +48,16 @@ namespace Pinetime {
Controllers::DateTime::Days currentDayOfWeek = Pinetime::Controllers::DateTime::Days::Unknown;
uint8_t currentDay = 0;

DirtyValue<uint8_t> batteryPercentRemaining {};
DirtyValue<bool> powerPresent {};
DirtyValue<bool> bleState {};
DirtyValue<bool> bleRadioEnabled {};
DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds>> currentDateTime {};
DirtyValue<bool> motionSensorOk {};
DirtyValue<uint32_t> stepCount {};
DirtyValue<uint8_t> heartbeat {};
DirtyValue<bool> heartbeatRunning {};
DirtyValue<bool> notificationState {};
Utility::DirtyValue<uint8_t> batteryPercentRemaining {};
Utility::DirtyValue<bool> powerPresent {};
Utility::DirtyValue<bool> bleState {};
Utility::DirtyValue<bool> bleRadioEnabled {};
Utility::DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds>> currentDateTime {};
Utility::DirtyValue<bool> motionSensorOk {};
Utility::DirtyValue<uint32_t> stepCount {};
Utility::DirtyValue<uint8_t> heartbeat {};
Utility::DirtyValue<bool> heartbeatRunning {};
Utility::DirtyValue<bool> notificationState {};

lv_obj_t* label_time_hour_1;
lv_obj_t* label_time_hour_10;
Expand Down Expand Up @@ -92,8 +92,8 @@ namespace Pinetime {
BatteryIcon batteryIcon;

Controllers::DateTime& dateTimeController;
Controllers::Battery& batteryController;
Controllers::Ble& bleController;
const Controllers::Battery& batteryController;
const Controllers::Ble& bleController;
Controllers::NotificationManager& notificatioManager;
Controllers::Settings& settingsController;
Controllers::HeartRateController& heartRateController;
Expand Down
3 changes: 2 additions & 1 deletion src/displayapp/screens/settings/SettingWatchFace.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "displayapp/screens/CheckboxList.h"
#include "displayapp/screens/WatchFaceInfineat.h"
#include "displayapp/screens/WatchFaceCasioStyleG7710.h"
#include "displayapp/screens/WatchFaceStarTrek.h"

namespace Pinetime {

Expand Down Expand Up @@ -47,7 +48,7 @@ namespace Pinetime {
{"Terminal", true},
{"Infineat face", Applications::Screens::WatchFaceInfineat::IsAvailable(filesystem)},
{"Casio G7710", Applications::Screens::WatchFaceCasioStyleG7710::IsAvailable(filesystem)},
{"", false},
{"Star Trek", Applications::Screens::WatchFaceStarTrek::IsAvailable(filesystem)},
{"", false}}};
ScreenList<nScreens> screens;
};
Expand Down

0 comments on commit 6ecf80a

Please sign in to comment.