Horizon watch face compiles

This commit is contained in:
Josh 2024-05-09 11:24:05 -04:00
parent ef696cadd5
commit dc45d845c2
3 changed files with 17 additions and 27 deletions

View File

@ -10,11 +10,11 @@
using namespace Pinetime::Applications::Screens;
WatchFaceHorizon::WatchFaceHorizon(Controllers::DateTime& dateTimeController,
Controllers::Battery& batteryController,
const Controllers::Battery& batteryController,
Controllers::Settings& settingsController,
Controllers::MotionController& motionController,
Controllers::FS& filesystem)
currentDateTime {{}},
: currentDateTime {{}},
dateTimeController {dateTimeController},
batteryController {batteryController},
settingsController {settingsController},
@ -144,21 +144,12 @@ WatchFaceHorizon::~WatchFaceHorizon() {
}
void WatchFaceHorizon::Refresh() {
currentDateTime = dateTimeController.CurrentDateTime();
currentDateTime = std::chrono::time_point_cast<std::chrono::seconds>(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 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());
int64_t hour = time.hours().count();
int64_t minute = time.minutes().count();
uint8_t hour = dateTimeController.Hours();
uint8_t minute = dateTimeController.Minutes();
uint8_t day = dateTimeController.Day();
char minutesChar[3];
sprintf(minutesChar, "%02d", static_cast<int>(minute));
@ -167,6 +158,7 @@ void WatchFaceHorizon::Refresh() {
int displayHour = hour;
// Account for 12-hour time
if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) {
if (hour < 12) {
if (hour == 0) {
@ -214,7 +206,8 @@ void WatchFaceHorizon::Refresh() {
}
// Date has updated
if ((month != currentMonth) || (dayOfWeek != currentDayOfWeek) || (day != currentDay)) {
currentDate = std::chrono::time_point_cast<std::chrono::days>(currentDateTime.Get());
if (currentDate.IsUpdated()) {
lv_label_set_text_fmt(labelDayOfWeek, "%s", dateTimeController.DayOfWeekShortToString());
lv_label_set_text_fmt(labelMonth, "%s", dateTimeController.MonthShortToString());
lv_label_set_text_fmt(labelDate, "%d", day);
@ -222,10 +215,6 @@ void WatchFaceHorizon::Refresh() {
lv_obj_realign(labelDayOfWeek);
lv_obj_realign(labelMonth);
lv_obj_realign(labelDate);
currentMonth = month;
currentDayOfWeek = dayOfWeek;
currentDay = day;
}
}
@ -238,8 +227,7 @@ void WatchFaceHorizon::Refresh() {
// Set step count
stepCount = motionController.NbSteps();
motionSensorOk = motionController.IsSensorOk();
if (stepCount.IsUpdated() || motionSensorOk.IsUpdated()) {
if (stepCount.IsUpdated()) {
lv_label_set_text_fmt(stepValue, "%lu", stepCount.Get());
lv_obj_realign(stepValue);
}

View File

@ -23,7 +23,7 @@ namespace Pinetime {
class WatchFaceHorizon : public Screen {
public:
WatchFaceHorizon(Controllers::DateTime& dateTimeController,
Controllers::Battery& batteryController,
const Controllers::Battery& batteryController,
Controllers::Settings& settingsController,
Controllers::MotionController& motionController,
Controllers::FS& fs);
@ -41,6 +41,7 @@ namespace Pinetime {
Pinetime::Controllers::DateTime::Months currentMonth = Pinetime::Controllers::DateTime::Months::Unknown;
Pinetime::Controllers::DateTime::Days currentDayOfWeek = Pinetime::Controllers::DateTime::Days::Unknown;
uint8_t currentDay = 0;
Utility::DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::days>> currentDate;
Utility::DirtyValue<uint8_t> batteryPercentRemaining {};
Utility::DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds>> currentDateTime {};
@ -73,7 +74,7 @@ namespace Pinetime {
lv_obj_t* stepValue;
Controllers::DateTime& dateTimeController;
Controllers::Battery& batteryController;
const Controllers::Battery& batteryController;
Controllers::Settings& settingsController;
Controllers::MotionController& motionController;
@ -92,16 +93,16 @@ namespace Pinetime {
static constexpr WatchFace watchFace = WatchFace::Horizon;
static constexpr const char* name = "Horizon";
static Screens::Screen* Create(AppControllers& controllers) {
static Screens::Screen* Create;/*(AppControllers& controllers) {
return new Screens::WatchFaceHorizon(controllers.dateTimeController,
controllers.batteryController,
controllers.settingsController,
controllers.motionController,
controllers.filesystem);
};
};*/
static bool IsAvailable(Pinetime::Controllers::FS& filesystem) {
return Screens::WatchFaceInfineat::IsAvailable(filesystem);
return Screens::WatchFaceHorizon::IsAvailable(filesystem);
}
};
}

View File

@ -11,6 +11,7 @@
#include "displayapp/screens/CheckboxList.h"
#include "displayapp/screens/WatchFaceInfineat.h"
#include "displayapp/screens/WatchFaceCasioStyleG7710.h"
#include "displayapp/screens/WatchFaceHorizon.h"
namespace Pinetime {