mirror of
https://github.com/InfiniTimeOrg/InfiniTime.git
synced 2024-10-22 23:21:53 +02:00
Compare commits
5 commits
2707bf73bf
...
9186e7dea1
Author | SHA1 | Date | |
---|---|---|---|
9186e7dea1 | |||
3fa9dbbac7 | |||
66930a55f5 | |||
c936a80863 | |||
8c18106bf1 |
|
@ -11,7 +11,7 @@ void Timer::StartTimer(std::chrono::milliseconds duration) {
|
||||||
xTimerStart(timer, 0);
|
xTimerStart(timer, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::chrono::milliseconds Timer::GetTimeRemaining() {
|
std::chrono::milliseconds Timer::GetTimeRemaining() const {
|
||||||
if (IsRunning()) {
|
if (IsRunning()) {
|
||||||
TickType_t remainingTime = xTimerGetExpiryTime(timer) - xTaskGetTickCount();
|
TickType_t remainingTime = xTimerGetExpiryTime(timer) - xTaskGetTickCount();
|
||||||
return std::chrono::milliseconds(remainingTime * 1000 / configTICK_RATE_HZ);
|
return std::chrono::milliseconds(remainingTime * 1000 / configTICK_RATE_HZ);
|
||||||
|
@ -23,6 +23,6 @@ void Timer::StopTimer() {
|
||||||
xTimerStop(timer, 0);
|
xTimerStop(timer, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Timer::IsRunning() {
|
bool Timer::IsRunning() const {
|
||||||
return (xTimerIsTimerActive(timer) == pdTRUE);
|
return (xTimerIsTimerActive(timer) == pdTRUE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,9 +15,9 @@ namespace Pinetime {
|
||||||
|
|
||||||
void StopTimer();
|
void StopTimer();
|
||||||
|
|
||||||
std::chrono::milliseconds GetTimeRemaining();
|
std::chrono::milliseconds GetTimeRemaining() const;
|
||||||
|
|
||||||
bool IsRunning();
|
bool IsRunning() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TimerHandle_t timer;
|
TimerHandle_t timer;
|
||||||
|
|
|
@ -505,6 +505,7 @@ void DisplayApp::LoadScreen(Apps app, DisplayApp::FullRefreshDirections directio
|
||||||
batteryController,
|
batteryController,
|
||||||
bleController,
|
bleController,
|
||||||
dateTimeController,
|
dateTimeController,
|
||||||
|
timer,
|
||||||
filesystem,
|
filesystem,
|
||||||
std::move(apps));
|
std::move(apps));
|
||||||
} break;
|
} break;
|
||||||
|
@ -558,7 +559,8 @@ void DisplayApp::LoadScreen(Apps app, DisplayApp::FullRefreshDirections directio
|
||||||
brightnessController,
|
brightnessController,
|
||||||
motorController,
|
motorController,
|
||||||
settingsController,
|
settingsController,
|
||||||
bleController);
|
bleController,
|
||||||
|
timer);
|
||||||
break;
|
break;
|
||||||
case Apps::Settings:
|
case Apps::Settings:
|
||||||
currentScreen = std::make_unique<Screens::Settings>(this, settingsController);
|
currentScreen = std::make_unique<Screens::Settings>(this, settingsController);
|
||||||
|
|
|
@ -22,6 +22,7 @@ ApplicationList::ApplicationList(DisplayApp* app,
|
||||||
const Pinetime::Controllers::Battery& batteryController,
|
const Pinetime::Controllers::Battery& batteryController,
|
||||||
const Pinetime::Controllers::Ble& bleController,
|
const Pinetime::Controllers::Ble& bleController,
|
||||||
Controllers::DateTime& dateTimeController,
|
Controllers::DateTime& dateTimeController,
|
||||||
|
Controllers::Timer& timer,
|
||||||
Pinetime::Controllers::FS& filesystem,
|
Pinetime::Controllers::FS& filesystem,
|
||||||
std::array<Tile::Applications, UserAppTypes::Count>&& apps)
|
std::array<Tile::Applications, UserAppTypes::Count>&& apps)
|
||||||
: app {app},
|
: app {app},
|
||||||
|
@ -29,6 +30,7 @@ ApplicationList::ApplicationList(DisplayApp* app,
|
||||||
batteryController {batteryController},
|
batteryController {batteryController},
|
||||||
bleController {bleController},
|
bleController {bleController},
|
||||||
dateTimeController {dateTimeController},
|
dateTimeController {dateTimeController},
|
||||||
|
timer {timer},
|
||||||
filesystem {filesystem},
|
filesystem {filesystem},
|
||||||
apps {std::move(apps)},
|
apps {std::move(apps)},
|
||||||
screens {app, settingsController.GetAppMenu(), CreateScreenList(), Screens::ScreenListModes::UpDown} {
|
screens {app, settingsController.GetAppMenu(), CreateScreenList(), Screens::ScreenListModes::UpDown} {
|
||||||
|
@ -60,5 +62,6 @@ std::unique_ptr<Screen> ApplicationList::CreateScreen(unsigned int screenNum) co
|
||||||
batteryController,
|
batteryController,
|
||||||
bleController,
|
bleController,
|
||||||
dateTimeController,
|
dateTimeController,
|
||||||
pageApps);
|
pageApps,
|
||||||
|
timer);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ namespace Pinetime {
|
||||||
const Pinetime::Controllers::Battery& batteryController,
|
const Pinetime::Controllers::Battery& batteryController,
|
||||||
const Pinetime::Controllers::Ble& bleController,
|
const Pinetime::Controllers::Ble& bleController,
|
||||||
Controllers::DateTime& dateTimeController,
|
Controllers::DateTime& dateTimeController,
|
||||||
|
Pinetime::Controllers::Timer& timer,
|
||||||
Pinetime::Controllers::FS& filesystem,
|
Pinetime::Controllers::FS& filesystem,
|
||||||
std::array<Tile::Applications, UserAppTypes::Count>&& apps);
|
std::array<Tile::Applications, UserAppTypes::Count>&& apps);
|
||||||
~ApplicationList() override;
|
~ApplicationList() override;
|
||||||
|
@ -33,6 +34,7 @@ namespace Pinetime {
|
||||||
const Pinetime::Controllers::Battery& batteryController;
|
const Pinetime::Controllers::Battery& batteryController;
|
||||||
const Pinetime::Controllers::Ble& bleController;
|
const Pinetime::Controllers::Ble& bleController;
|
||||||
Controllers::DateTime& dateTimeController;
|
Controllers::DateTime& dateTimeController;
|
||||||
|
Pinetime::Controllers::Timer& timer;
|
||||||
Pinetime::Controllers::FS& filesystem;
|
Pinetime::Controllers::FS& filesystem;
|
||||||
std::array<Tile::Applications, UserAppTypes::Count> apps;
|
std::array<Tile::Applications, UserAppTypes::Count> apps;
|
||||||
|
|
||||||
|
|
|
@ -30,8 +30,9 @@ Tile::Tile(uint8_t screenID,
|
||||||
const Controllers::Battery& batteryController,
|
const Controllers::Battery& batteryController,
|
||||||
const Controllers::Ble& bleController,
|
const Controllers::Ble& bleController,
|
||||||
Controllers::DateTime& dateTimeController,
|
Controllers::DateTime& dateTimeController,
|
||||||
std::array<Applications, 6>& applications)
|
std::array<Applications, 6>& applications,
|
||||||
: app {app}, dateTimeController {dateTimeController}, pageIndicator(screenID, numScreens), statusIcons(batteryController, bleController) {
|
Controllers::Timer& timer)
|
||||||
|
: app {app}, dateTimeController {dateTimeController}, pageIndicator(screenID, numScreens), statusIcons(batteryController, bleController, timer) {
|
||||||
|
|
||||||
settingsController.SetAppMenu(screenID);
|
settingsController.SetAppMenu(screenID);
|
||||||
|
|
||||||
|
@ -83,7 +84,7 @@ Tile::Tile(uint8_t screenID,
|
||||||
btnm1->user_data = this;
|
btnm1->user_data = this;
|
||||||
lv_obj_set_event_cb(btnm1, event_handler);
|
lv_obj_set_event_cb(btnm1, event_handler);
|
||||||
|
|
||||||
taskUpdate = lv_task_create(lv_update_task, 5000, LV_TASK_PRIO_MID, this);
|
taskUpdate = lv_task_create(lv_update_task, 500, LV_TASK_PRIO_MID, this);
|
||||||
|
|
||||||
UpdateScreen();
|
UpdateScreen();
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,8 @@ namespace Pinetime {
|
||||||
const Controllers::Battery& batteryController,
|
const Controllers::Battery& batteryController,
|
||||||
const Controllers::Ble& bleController,
|
const Controllers::Ble& bleController,
|
||||||
Controllers::DateTime& dateTimeController,
|
Controllers::DateTime& dateTimeController,
|
||||||
std::array<Applications, 6>& applications);
|
std::array<Applications, 6>& applications,
|
||||||
|
Controllers::Timer& timer);
|
||||||
|
|
||||||
~Tile() override;
|
~Tile() override;
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ using namespace Pinetime::Applications::Screens;
|
||||||
WatchFaceDigital::WatchFaceDigital(Controllers::DateTime& dateTimeController,
|
WatchFaceDigital::WatchFaceDigital(Controllers::DateTime& dateTimeController,
|
||||||
const Controllers::Battery& batteryController,
|
const Controllers::Battery& batteryController,
|
||||||
const Controllers::Ble& bleController,
|
const Controllers::Ble& bleController,
|
||||||
|
const Controllers::Timer& timer,
|
||||||
Controllers::NotificationManager& notificationManager,
|
Controllers::NotificationManager& notificationManager,
|
||||||
Controllers::Settings& settingsController,
|
Controllers::Settings& settingsController,
|
||||||
Controllers::HeartRateController& heartRateController,
|
Controllers::HeartRateController& heartRateController,
|
||||||
|
@ -30,7 +31,7 @@ WatchFaceDigital::WatchFaceDigital(Controllers::DateTime& dateTimeController,
|
||||||
heartRateController {heartRateController},
|
heartRateController {heartRateController},
|
||||||
motionController {motionController},
|
motionController {motionController},
|
||||||
weatherService {weatherService},
|
weatherService {weatherService},
|
||||||
statusIcons(batteryController, bleController) {
|
statusIcons(batteryController, bleController, timer) {
|
||||||
|
|
||||||
statusIcons.Create();
|
statusIcons.Create();
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ namespace Pinetime {
|
||||||
class NotificationManager;
|
class NotificationManager;
|
||||||
class HeartRateController;
|
class HeartRateController;
|
||||||
class MotionController;
|
class MotionController;
|
||||||
|
class Timer;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Applications {
|
namespace Applications {
|
||||||
|
@ -30,6 +31,7 @@ namespace Pinetime {
|
||||||
WatchFaceDigital(Controllers::DateTime& dateTimeController,
|
WatchFaceDigital(Controllers::DateTime& dateTimeController,
|
||||||
const Controllers::Battery& batteryController,
|
const Controllers::Battery& batteryController,
|
||||||
const Controllers::Ble& bleController,
|
const Controllers::Ble& bleController,
|
||||||
|
const Controllers::Timer& timer,
|
||||||
Controllers::NotificationManager& notificationManager,
|
Controllers::NotificationManager& notificationManager,
|
||||||
Controllers::Settings& settingsController,
|
Controllers::Settings& settingsController,
|
||||||
Controllers::HeartRateController& heartRateController,
|
Controllers::HeartRateController& heartRateController,
|
||||||
|
@ -84,6 +86,7 @@ namespace Pinetime {
|
||||||
return new Screens::WatchFaceDigital(controllers.dateTimeController,
|
return new Screens::WatchFaceDigital(controllers.dateTimeController,
|
||||||
controllers.batteryController,
|
controllers.batteryController,
|
||||||
controllers.bleController,
|
controllers.bleController,
|
||||||
|
controllers.timer,
|
||||||
controllers.notificationManager,
|
controllers.notificationManager,
|
||||||
controllers.settingsController,
|
controllers.settingsController,
|
||||||
controllers.heartRateController,
|
controllers.heartRateController,
|
||||||
|
|
|
@ -33,13 +33,14 @@ QuickSettings::QuickSettings(Pinetime::Applications::DisplayApp* app,
|
||||||
Controllers::BrightnessController& brightness,
|
Controllers::BrightnessController& brightness,
|
||||||
Controllers::MotorController& motorController,
|
Controllers::MotorController& motorController,
|
||||||
Pinetime::Controllers::Settings& settingsController,
|
Pinetime::Controllers::Settings& settingsController,
|
||||||
const Controllers::Ble& bleController)
|
const Controllers::Ble& bleController,
|
||||||
|
const Controllers::Timer& timer)
|
||||||
: app {app},
|
: app {app},
|
||||||
dateTimeController {dateTimeController},
|
dateTimeController {dateTimeController},
|
||||||
brightness {brightness},
|
brightness {brightness},
|
||||||
motorController {motorController},
|
motorController {motorController},
|
||||||
settingsController {settingsController},
|
settingsController {settingsController},
|
||||||
statusIcons(batteryController, bleController) {
|
statusIcons(batteryController, bleController, timer) {
|
||||||
|
|
||||||
statusIcons.Create();
|
statusIcons.Create();
|
||||||
|
|
||||||
|
@ -118,7 +119,7 @@ QuickSettings::QuickSettings(Pinetime::Applications::DisplayApp* app,
|
||||||
lv_obj_set_style_local_text_font(lbl_btn, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_sys_48);
|
lv_obj_set_style_local_text_font(lbl_btn, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_sys_48);
|
||||||
lv_label_set_text_static(lbl_btn, Symbols::settings);
|
lv_label_set_text_static(lbl_btn, Symbols::settings);
|
||||||
|
|
||||||
taskUpdate = lv_task_create(lv_update_task, 5000, LV_TASK_PRIO_MID, this);
|
taskUpdate = lv_task_create(lv_update_task, 500, LV_TASK_PRIO_MID, this);
|
||||||
|
|
||||||
UpdateScreen();
|
UpdateScreen();
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,8 @@ namespace Pinetime {
|
||||||
Controllers::BrightnessController& brightness,
|
Controllers::BrightnessController& brightness,
|
||||||
Controllers::MotorController& motorController,
|
Controllers::MotorController& motorController,
|
||||||
Pinetime::Controllers::Settings& settingsController,
|
Pinetime::Controllers::Settings& settingsController,
|
||||||
const Controllers::Ble& bleController);
|
const Controllers::Ble& bleController,
|
||||||
|
const Controllers::Timer& timer);
|
||||||
|
|
||||||
~QuickSettings() override;
|
~QuickSettings() override;
|
||||||
|
|
||||||
|
|
|
@ -3,11 +3,22 @@
|
||||||
|
|
||||||
using namespace Pinetime::Applications::Widgets;
|
using namespace Pinetime::Applications::Widgets;
|
||||||
|
|
||||||
StatusIcons::StatusIcons(const Controllers::Battery& batteryController, const Controllers::Ble& bleController)
|
StatusIcons::StatusIcons(const Controllers::Battery& batteryController, const Controllers::Ble& bleController, const Controllers::Timer& timer)
|
||||||
: batteryIcon(true), batteryController {batteryController}, bleController {bleController} {
|
: batteryIcon(true), batteryController {batteryController}, bleController {bleController}, timer {timer} {
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatusIcons::Create() {
|
void StatusIcons::Create() {
|
||||||
|
timerIcon = lv_label_create(lv_scr_act(), nullptr);
|
||||||
|
lv_label_set_text_static(timerIcon, Screens::Symbols::hourGlass);
|
||||||
|
lv_obj_set_style_local_text_color(timerIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x999999));
|
||||||
|
lv_obj_align(timerIcon, lv_scr_act(), LV_ALIGN_IN_TOP_MID, -32, 0);
|
||||||
|
|
||||||
|
timeRemaining = lv_label_create(lv_scr_act(), nullptr);
|
||||||
|
lv_obj_set_style_local_text_color(timeRemaining, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x999999));
|
||||||
|
lv_label_set_text(timeRemaining, "00:00");
|
||||||
|
lv_obj_align(timeRemaining, nullptr, LV_ALIGN_IN_TOP_MID, 10, 0);
|
||||||
|
|
||||||
|
|
||||||
container = lv_cont_create(lv_scr_act(), nullptr);
|
container = lv_cont_create(lv_scr_act(), nullptr);
|
||||||
lv_cont_set_layout(container, LV_LAYOUT_ROW_TOP);
|
lv_cont_set_layout(container, LV_LAYOUT_ROW_TOP);
|
||||||
lv_cont_set_fit(container, LV_FIT_TIGHT);
|
lv_cont_set_fit(container, LV_FIT_TIGHT);
|
||||||
|
@ -26,6 +37,20 @@ void StatusIcons::Create() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatusIcons::Update() {
|
void StatusIcons::Update() {
|
||||||
|
if (timer.IsRunning()) {
|
||||||
|
auto secondsRemaining = std::chrono::duration_cast<std::chrono::seconds>(timer.GetTimeRemaining());
|
||||||
|
|
||||||
|
uint8_t minutes = secondsRemaining.count() / 60;
|
||||||
|
uint8_t seconds = secondsRemaining.count() % 60;
|
||||||
|
lv_label_set_text_fmt(timeRemaining, "%02d:%02d", minutes, seconds);
|
||||||
|
|
||||||
|
lv_obj_set_hidden(timeRemaining, false);
|
||||||
|
lv_obj_set_hidden(timerIcon, false);
|
||||||
|
} else {
|
||||||
|
lv_obj_set_hidden(timeRemaining, true);
|
||||||
|
lv_obj_set_hidden(timerIcon, true);
|
||||||
|
}
|
||||||
|
|
||||||
powerPresent = batteryController.IsPowerPresent();
|
powerPresent = batteryController.IsPowerPresent();
|
||||||
if (powerPresent.IsUpdated()) {
|
if (powerPresent.IsUpdated()) {
|
||||||
lv_obj_set_hidden(batteryPlug, !powerPresent.Get());
|
lv_obj_set_hidden(batteryPlug, !powerPresent.Get());
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace Pinetime {
|
||||||
namespace Widgets {
|
namespace Widgets {
|
||||||
class StatusIcons {
|
class StatusIcons {
|
||||||
public:
|
public:
|
||||||
StatusIcons(const Controllers::Battery& batteryController, const Controllers::Ble& bleController);
|
StatusIcons(const Controllers::Battery& batteryController, const Controllers::Ble& bleController, const Controllers::Timer& timer);
|
||||||
void Align();
|
void Align();
|
||||||
void Create();
|
void Create();
|
||||||
|
|
||||||
|
@ -27,12 +27,15 @@ namespace Pinetime {
|
||||||
Screens::BatteryIcon batteryIcon;
|
Screens::BatteryIcon batteryIcon;
|
||||||
const Pinetime::Controllers::Battery& batteryController;
|
const Pinetime::Controllers::Battery& batteryController;
|
||||||
const Controllers::Ble& bleController;
|
const Controllers::Ble& bleController;
|
||||||
|
const Controllers::Timer& timer;
|
||||||
|
|
||||||
Utility::DirtyValue<uint8_t> batteryPercentRemaining {};
|
Utility::DirtyValue<uint8_t> batteryPercentRemaining {};
|
||||||
Utility::DirtyValue<bool> powerPresent {};
|
Utility::DirtyValue<bool> powerPresent {};
|
||||||
Utility::DirtyValue<bool> bleState {};
|
Utility::DirtyValue<bool> bleState {};
|
||||||
Utility::DirtyValue<bool> bleRadioEnabled {};
|
Utility::DirtyValue<bool> bleRadioEnabled {};
|
||||||
|
|
||||||
|
lv_obj_t* timerIcon;
|
||||||
|
lv_obj_t* timeRemaining;
|
||||||
lv_obj_t* bleIcon;
|
lv_obj_t* bleIcon;
|
||||||
lv_obj_t* batteryPlug;
|
lv_obj_t* batteryPlug;
|
||||||
lv_obj_t* container;
|
lv_obj_t* container;
|
||||||
|
|
Loading…
Reference in a new issue