Gravel watchface compiles
This commit is contained in:
parent
5fb1afd200
commit
bf66e64021
@ -17,6 +17,7 @@
|
||||
#include "displayapp/screens/WatchFaceTerminal.h"
|
||||
#include "displayapp/screens/WatchFaceHorizon.h"
|
||||
#include "displayapp/screens/WatchFaceAccurateWords.h"
|
||||
#include "displayapp/screens/WatchFaceGravel.h"
|
||||
|
||||
namespace Pinetime {
|
||||
namespace Applications {
|
||||
|
@ -59,6 +59,7 @@ namespace Pinetime {
|
||||
CasioStyleG7710,
|
||||
Horizon,
|
||||
AccurateWords,
|
||||
Gravel
|
||||
};
|
||||
|
||||
template <Apps>
|
||||
|
@ -32,6 +32,7 @@ else()
|
||||
set(DEFAULT_WATCHFACE_TYPES "${DEFAULT_WATCHFACE_TYPES}, WatchFace::CasioStyleG7710")
|
||||
set(DEFAULT_WATCHFACE_TYPES "${DEFAULT_WATCHFACE_TYPES}, WatchFace::Horizon")
|
||||
set(DEFAULT_WATCHFACE_TYPES "${DEFAULT_WATCHFACE_TYPES}, WatchFace::AccurateWords")
|
||||
set(DEFAULT_WATCHFACE_TYPES "${DEFAULT_WATCHFACE_TYPES}, WatchFace::Gravel")
|
||||
set(WATCHFACE_TYPES "${DEFAULT_WATCHFACE_TYPES}" CACHE STRING "List of watch faces to build into the firmware")
|
||||
endif()
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
#include "displayapp/screens/WatchFaceGravel.h"
|
||||
|
||||
#include <date/date.h>
|
||||
#include <lvgl/lvgl.h>
|
||||
#include "components/battery/BatteryController.h"
|
||||
#include "components/ble/BleController.h"
|
||||
@ -26,18 +25,16 @@ namespace Style {
|
||||
static constexpr lv_color_t barBackground = LV_COLOR_MAKE(0x38, 0x38, 0x38);
|
||||
}
|
||||
|
||||
WatchFaceGravel::WatchFaceGravel(DisplayApp* app,
|
||||
Controllers::DateTime& dateTimeController,
|
||||
Controllers::Battery& batteryController,
|
||||
WatchFaceGravel::WatchFaceGravel(Controllers::DateTime& dateTimeController,
|
||||
const Controllers::Battery& batteryController,
|
||||
Controllers::Settings& settingsController,
|
||||
Controllers::MotionController& motionController,
|
||||
Controllers::FS& filesystem)
|
||||
: Screen(app),
|
||||
currentDateTime {{}},
|
||||
: currentDateTime {{}},
|
||||
dateTimeController {dateTimeController},
|
||||
batteryController {batteryController},
|
||||
settingsController {settingsController},
|
||||
motionController(motionController) {
|
||||
motionController {motionController} {
|
||||
|
||||
lfs_file f = {};
|
||||
if (filesystem.FileOpen(&f, "/fonts/SquareRegular_72.bin", LFS_O_RDONLY) >= 0) {
|
||||
@ -116,47 +113,36 @@ void WatchFaceGravel::Refresh() {
|
||||
currentDateTime = dateTimeController.CurrentDateTime();
|
||||
|
||||
if (currentDateTime.IsUpdated()) {
|
||||
auto newDateTime = currentDateTime.Get();
|
||||
uint8_t hour = dateTimeController.Hours();
|
||||
uint8_t minute = dateTimeController.Minutes();
|
||||
|
||||
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();
|
||||
|
||||
if (displayedHour != hour || displayedMinute != minute) {
|
||||
displayedHour = hour;
|
||||
displayedMinute = minute;
|
||||
|
||||
if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) {
|
||||
char ampmChar[3] = "AM";
|
||||
if (hour == 0) {
|
||||
hour = 12;
|
||||
} else if (hour == 12) {
|
||||
ampmChar[0] = 'P';
|
||||
} else if (hour > 12) {
|
||||
hour = hour - 12;
|
||||
ampmChar[0] = 'P';
|
||||
}
|
||||
lv_label_set_text(labelTimeAMPM, ampmChar);
|
||||
if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) {
|
||||
char ampmChar[3] = "AM";
|
||||
if (hour == 0) {
|
||||
hour = 12;
|
||||
} else if (hour == 12) {
|
||||
ampmChar[0] = 'P';
|
||||
} else if (hour > 12) {
|
||||
hour = hour - 12;
|
||||
ampmChar[0] = 'P';
|
||||
}
|
||||
|
||||
lv_label_set_text_fmt(labelTime, "%02d:%02d", hour, minute);
|
||||
lv_obj_align_origo(labelTime, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
|
||||
lv_label_set_text(labelTimeAMPM, ampmChar);
|
||||
}
|
||||
|
||||
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());
|
||||
if ((day != currentDay) || (month != currentMonth)) {
|
||||
lv_label_set_text_fmt(labelDate, "%d %s", day, Pinetime::Controllers::DateTime::MonthShortToStringLow(month));
|
||||
lv_label_set_text_fmt(labelTime, "%02d:%02d", hour, minute);
|
||||
lv_obj_align_origo(labelTime, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
|
||||
currentDate = std::chrono::time_point_cast<std::chrono::days>(currentDateTime.Get());
|
||||
if (currentDate.IsUpdated()) {
|
||||
lv_label_set_text_fmt(labelDate, "%d %s", dateTimeController.DayOfWeekShortToString(), dateTimeController.MonthShortToString());
|
||||
}
|
||||
lv_obj_realign(labelDate);
|
||||
}
|
||||
|
||||
stepCount = motionController.NbSteps();
|
||||
motionSensorOk = motionController.IsSensorOk();
|
||||
if (stepCount.IsUpdated() || motionSensorOk.IsUpdated()) {
|
||||
if (stepCount.IsUpdated()) {
|
||||
uint16_t pointCount = refreshStepLinePoints(std::min(stepCount.Get(), settingsController.GetStepsGoal()));
|
||||
lv_line_set_points(stepLine, stepLinePoints.data(), pointCount);
|
||||
}
|
||||
@ -177,6 +163,21 @@ void WatchFaceGravel::Refresh() {
|
||||
}
|
||||
}
|
||||
|
||||
bool WatchFaceGravel::IsAvailable(Pinetime::Controllers::FS& filesystem) {
|
||||
lfs_file file = {};
|
||||
|
||||
if (filesystem.FileOpen(&file, "/fonts/SquareRegular_72.bin", LFS_O_RDONLY) < 0) {
|
||||
return false;
|
||||
}
|
||||
filesystem.FileClose(&file);
|
||||
|
||||
if (filesystem.FileOpen(&file, "/fonts/SquareRegular_20.bin", LFS_O_RDONLY) < 0) {
|
||||
return false;
|
||||
}
|
||||
filesystem.FileClose(&file);
|
||||
return true;
|
||||
}
|
||||
|
||||
void WatchFaceGravel::updateBatteryBar(uint8_t percent) {
|
||||
lv_bar_set_value(batteryBar, percent, LV_ANIM_ON);
|
||||
if (percent >= 70) {
|
||||
@ -188,8 +189,9 @@ void WatchFaceGravel::updateBatteryBar(uint8_t percent) {
|
||||
}
|
||||
}
|
||||
|
||||
void WatchFaceGravel::toggleBatteryChargingAnimation(bool enabled, uint8_t percent) {
|
||||
if (enabled) {
|
||||
void WatchFaceGravel::toggleBatteryChargingAnimation(bool, uint8_t) {
|
||||
//void WatchFaceGravel::toggleBatteryChargingAnimation(bool enabled, uint8_t percent) {
|
||||
/*if (enabled) {
|
||||
lv_obj_set_style_local_bg_color(batteryBar, LV_BAR_PART_INDIC, LV_STATE_DEFAULT, Style::green);
|
||||
lv_anim_del(batteryBar, (lv_anim_exec_xcb_t) lv_bar_set_value);
|
||||
lv_anim_set_exec_cb(&animationBatteryCharging, (lv_anim_exec_xcb_t) lv_bar_set_value);
|
||||
@ -200,7 +202,8 @@ void WatchFaceGravel::toggleBatteryChargingAnimation(bool enabled, uint8_t perce
|
||||
} else {
|
||||
lv_anim_del(batteryBar, (lv_anim_exec_xcb_t) lv_bar_set_value);
|
||||
updateBatteryBar(batteryPercentRemaining.Get());
|
||||
}
|
||||
}*/
|
||||
|
||||
}
|
||||
|
||||
WatchFaceGravel::DrawStop WatchFaceGravel::getDrawEnd(float percent, uint16_t width, uint16_t height) {
|
||||
@ -317,18 +320,3 @@ uint16_t WatchFaceGravel::refreshStepLinePoints(uint32_t stepCount) {
|
||||
|
||||
return currentPointIndex;
|
||||
}
|
||||
|
||||
bool WatchFaceGravel::IsAvailable(Pinetime::Controllers::FS& filesystem) {
|
||||
lfs_file file = {};
|
||||
|
||||
if (filesystem.FileOpen(&file, "/fonts/SquareRegular_72.bin", LFS_O_RDONLY) < 0) {
|
||||
return false;
|
||||
}
|
||||
filesystem.FileClose(&file);
|
||||
|
||||
if (filesystem.FileOpen(&file, "/fonts/SquareRegular_20.bin", LFS_O_RDONLY) < 0) {
|
||||
return false;
|
||||
}
|
||||
filesystem.FileClose(&file);
|
||||
return true;
|
||||
}
|
||||
|
@ -5,9 +5,11 @@
|
||||
#include <cstdint>
|
||||
#include <lvgl/src/lv_core/lv_obj.h>
|
||||
#include <memory>
|
||||
#include "displayapp/Controllers.h"
|
||||
#include "components/ble/BleController.h"
|
||||
#include "components/datetime/DateTimeController.h"
|
||||
#include "displayapp/screens/Screen.h"
|
||||
#include "utility/DirtyValue.h"
|
||||
|
||||
namespace Pinetime {
|
||||
namespace Controllers {
|
||||
@ -21,12 +23,10 @@ namespace Pinetime {
|
||||
|
||||
namespace Applications {
|
||||
namespace Screens {
|
||||
|
||||
class WatchFaceGravel : public Screen {
|
||||
public:
|
||||
WatchFaceGravel(DisplayApp* app,
|
||||
Controllers::DateTime& dateTimeController,
|
||||
Controllers::Battery& batteryController,
|
||||
WatchFaceGravel(Controllers::DateTime& dateTimeController,
|
||||
const Controllers::Battery& batteryController,
|
||||
Controllers::Settings& settingsController,
|
||||
Controllers::MotionController& motionController,
|
||||
Controllers::FS& filesystem);
|
||||
@ -43,11 +43,12 @@ namespace Pinetime {
|
||||
uint8_t currentDay = 0;
|
||||
std::array<lv_point_t, 7> stepLinePoints = {0};
|
||||
|
||||
DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds>> currentDateTime {};
|
||||
DirtyValue<bool> motionSensorOk {};
|
||||
DirtyValue<uint32_t> stepCount {};
|
||||
DirtyValue<uint8_t> batteryPercentRemaining {};
|
||||
DirtyValue<bool> isCharging {};
|
||||
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> batteryPercentRemaining {};
|
||||
Utility::DirtyValue<bool> isCharging {};
|
||||
Utility::DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::days>> currentDate;
|
||||
|
||||
lv_obj_t* labelTime;
|
||||
lv_obj_t* labelTimeAMPM;
|
||||
@ -62,9 +63,9 @@ namespace Pinetime {
|
||||
lv_font_t* font_SquareRegular20 = nullptr;
|
||||
|
||||
Controllers::DateTime& dateTimeController;
|
||||
const Controllers::Battery& batteryController;
|
||||
Controllers::Settings& settingsController;
|
||||
Controllers::MotionController& motionController;
|
||||
Controllers::Battery& batteryController;
|
||||
|
||||
lv_task_t* taskRefresh;
|
||||
|
||||
@ -80,5 +81,23 @@ namespace Pinetime {
|
||||
void toggleBatteryChargingAnimation(bool enabled, uint8_t percent);
|
||||
};
|
||||
}
|
||||
|
||||
template <>
|
||||
struct WatchFaceTraits<WatchFace::Gravel> {
|
||||
static constexpr WatchFace watchFace = WatchFace::Gravel;
|
||||
static constexpr const char* name = "Pebble face";
|
||||
|
||||
static Screens::Screen* Create(AppControllers& controllers) {
|
||||
return new Screens::WatchFaceGravel(controllers.dateTimeController,
|
||||
controllers.batteryController,
|
||||
controllers.settingsController,
|
||||
controllers.motionController,
|
||||
controllers.filesystem);
|
||||
};
|
||||
|
||||
static bool IsAvailable(Pinetime::Controllers::FS& filesystem) {
|
||||
return Screens::WatchFaceGravel::IsAvailable(filesystem);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
BIN
src/resources/fonts/SquareRegular.ttf
Normal file
BIN
src/resources/fonts/SquareRegular.ttf
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user