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, Terminal,
Infineat, Infineat,
CasioStyleG7710, CasioStyleG7710,
Horizon Horizon,
AccurateWords,
}; };
template <Apps> template <Apps>

View File

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

View File

@ -8,6 +8,8 @@
#include "components/datetime/DateTimeController.h" #include "components/datetime/DateTimeController.h"
#include "components/ble/BleController.h" #include "components/ble/BleController.h"
#include "displayapp/widgets/StatusIcons.h" #include "displayapp/widgets/StatusIcons.h"
#include "displayapp/apps/Apps.h"
#include "utility/DirtyValue.h"
namespace Pinetime { namespace Pinetime {
namespace Controllers { namespace Controllers {
@ -24,10 +26,9 @@ namespace Pinetime {
class WatchFaceAccurateWords : public Screen { class WatchFaceAccurateWords : public Screen {
public: public:
WatchFaceAccurateWords(DisplayApp* app, WatchFaceAccurateWords(Controllers::DateTime& dateTimeController,
Controllers::DateTime& dateTimeController, const Controllers::Battery& batteryController,
Controllers::Battery& batteryController, const Controllers::Ble& bleController,
Controllers::Ble& bleController,
Controllers::NotificationManager& notificatioManager, Controllers::NotificationManager& notificatioManager,
Controllers::Settings& settingsController, Controllers::Settings& settingsController,
Controllers::HeartRateController& heartRateController, Controllers::HeartRateController& heartRateController,
@ -45,16 +46,18 @@ namespace Pinetime {
Controllers::DateTime::Days currentDayOfWeek = Pinetime::Controllers::DateTime::Days::Unknown; Controllers::DateTime::Days currentDayOfWeek = Pinetime::Controllers::DateTime::Days::Unknown;
uint8_t currentDay = 0; uint8_t currentDay = 0;
DirtyValue<uint8_t> batteryPercentRemaining {}; Utility::DirtyValue<uint8_t> batteryPercentRemaining {};
DirtyValue<bool> powerPresent {}; Utility::DirtyValue<bool> powerPresent {};
DirtyValue<bool> bleState {}; Utility::DirtyValue<bool> bleState {};
DirtyValue<bool> bleRadioEnabled {}; Utility::DirtyValue<bool> bleRadioEnabled {};
DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds>> currentDateTime {}; Utility::DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds>> currentDateTime {};
DirtyValue<bool> motionSensorOk {}; Utility::DirtyValue<bool> motionSensorOk {};
DirtyValue<uint32_t> stepCount {}; Utility::DirtyValue<uint32_t> stepCount {};
DirtyValue<uint8_t> heartbeat {}; Utility::DirtyValue<uint8_t> heartbeat {};
DirtyValue<bool> heartbeatRunning {}; Utility::DirtyValue<bool> heartbeatRunning {};
DirtyValue<bool> notificationState {}; 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;
lv_obj_t* label_time_ampm; lv_obj_t* label_time_ampm;
@ -75,5 +78,25 @@ namespace Pinetime {
Widgets::StatusIcons statusIcons; 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;
}
};
} }
} }