Progress with Accurate words face, but not working yet

This commit is contained in:
Josh 2024-05-09 13:50:02 -04:00
parent 06d93f0b46
commit c25623ae79
3 changed files with 51 additions and 41 deletions

View File

@ -57,7 +57,8 @@ namespace Pinetime {
Terminal,
Infineat,
CasioStyleG7710,
Horizon
Horizon,
AccurateWords,
};
template <Apps>

View File

@ -1,6 +1,5 @@
#include "displayapp/screens/WatchFaceAccurateWords.h"
#include <date/date.h>
#include <lvgl/lvgl.h>
#include <cstdio>
#include "displayapp/screens/NotificationIcon.h"
@ -14,16 +13,14 @@
using namespace Pinetime::Applications::Screens;
WatchFaceAccurateWords::WatchFaceAccurateWords(DisplayApp* app,
Controllers::DateTime& dateTimeController,
Controllers::Battery& batteryController,
Controllers::Ble& bleController,
WatchFaceAccurateWords::WatchFaceAccurateWords(Controllers::DateTime& dateTimeController,
const Controllers::Battery& batteryController,
const Controllers::Ble& bleController,
Controllers::NotificationManager& notificatioManager,
Controllers::Settings& settingsController,
Controllers::HeartRateController& heartRateController,
Controllers::MotionController& motionController)
: Screen(app),
currentDateTime {{}},
: currentDateTime {{}},
dateTimeController {dateTimeController},
notificatioManager {notificatioManager},
settingsController {settingsController},
@ -92,19 +89,13 @@ void WatchFaceAccurateWords::Refresh() {
currentDateTime = dateTimeController.CurrentDateTime();
if (currentDateTime.IsUpdated()) {
auto newDateTime = currentDateTime.Get();
auto year = dateTimeController.Year();
auto month = dateTimeController.Month();
auto day = dateTimeController.Day();
auto dayOfWeek = dateTimeController.DayOfWeek();
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();
uint8_t hour = dateTimeController.Hours();
uint8_t minute = dateTimeController.Minutes();
uint8_t monthInt = static_cast<uint8_t>(month);
uint8_t dayInt = static_cast<uint8_t>(day);
@ -198,7 +189,8 @@ void WatchFaceAccurateWords::Refresh() {
lv_label_set_text_fmt(label_time, "%s", words);
lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_CENTER, 0, -40);
if ((year != currentYear) || (month != currentMonth) || (dayOfWeek != currentDayOfWeek) || (day != currentDay)) {
currentDate = std::chrono::time_point_cast<std::chrono::days>(currentDateTime.Get());
if (currentDate.IsUpdated()) {
// Specific dates have specific names
if (year == 1970) {
lv_label_set_text_fmt(label_date, "New Firmware");
@ -228,11 +220,6 @@ void WatchFaceAccurateWords::Refresh() {
months_array[monthInt]);
}
lv_obj_align(label_date, lv_scr_act(), LV_ALIGN_CENTER, 0, 60);
currentYear = year;
currentMonth = month;
currentDayOfWeek = dayOfWeek;
currentDay = day;
}
}
}
@ -253,7 +240,6 @@ void WatchFaceAccurateWords::Refresh() {
}
stepCount = motionController.NbSteps();
motionSensorOk = motionController.IsSensorOk();
if (stepCount.IsUpdated() || motionSensorOk.IsUpdated()) {
lv_label_set_text_fmt(stepValue, "%lu", stepCount.Get());
lv_obj_realign(stepValue);

View File

@ -8,6 +8,8 @@
#include "components/datetime/DateTimeController.h"
#include "components/ble/BleController.h"
#include "displayapp/widgets/StatusIcons.h"
#include "displayapp/apps/Apps.h"
#include "utility/DirtyValue.h"
namespace Pinetime {
namespace Controllers {
@ -24,10 +26,9 @@ namespace Pinetime {
class WatchFaceAccurateWords : public Screen {
public:
WatchFaceAccurateWords(DisplayApp* app,
Controllers::DateTime& dateTimeController,
Controllers::Battery& batteryController,
Controllers::Ble& bleController,
WatchFaceAccurateWords(Controllers::DateTime& dateTimeController,
const Controllers::Battery& batteryController,
const Controllers::Ble& bleController,
Controllers::NotificationManager& notificatioManager,
Controllers::Settings& settingsController,
Controllers::HeartRateController& heartRateController,
@ -45,17 +46,19 @@ 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 {};
Utility::DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::days>> currentDate;
lv_obj_t* label_time;
lv_obj_t* label_time_ampm;
lv_obj_t* label_date;
@ -75,5 +78,25 @@ namespace Pinetime {
Widgets::StatusIcons statusIcons;
};
}
template <>
struct WatchFaceTraits<WatchFace::AccurateWords> {
static constexpr WatchFace watchFace = WatchFace::AccurateWords;
static constexpr const char* name = "AccurateWords";
static Screens::Screen* Create(AppControllers& controllers) {
return new Screens::WatchFaceAccurateWords (controllers.dateTimeController,
controllers.batteryController,
controllers.bleController,
controllers.notificationManager,
controllers.settingsController,
controllers.heartRateController,
controllers.motionController);
};
static bool IsAvailable(Pinetime::Controllers::FS& ) {
return true;
}
};
}
}