timer: Stop buzzing after 10 seconds
Also reset timer after 1 minute.
This commit is contained in:
parent
f4c35f0883
commit
58db582294
@ -266,12 +266,15 @@ void DisplayApp::Refresh() {
|
|||||||
if (state != States::Running) {
|
if (state != States::Running) {
|
||||||
PushMessageToSystemTask(System::Messages::GoToRunning);
|
PushMessageToSystemTask(System::Messages::GoToRunning);
|
||||||
}
|
}
|
||||||
|
// Load timer app if not loaded
|
||||||
|
if (currentApp != Apps::Timer) {
|
||||||
|
LoadNewScreen(Apps::Timer, DisplayApp::FullRefreshDirections::Up);
|
||||||
|
}
|
||||||
|
// Once loaded, set the timer to ringing mode
|
||||||
if (currentApp == Apps::Timer) {
|
if (currentApp == Apps::Timer) {
|
||||||
lv_disp_trig_activity(nullptr);
|
lv_disp_trig_activity(nullptr);
|
||||||
auto* timer = static_cast<Screens::Timer*>(currentScreen.get());
|
auto* timer = static_cast<Screens::Timer*>(currentScreen.get());
|
||||||
timer->Reset();
|
timer->SetTimerRinging();
|
||||||
} else {
|
|
||||||
LoadNewScreen(Apps::Timer, DisplayApp::FullRefreshDirections::Up);
|
|
||||||
}
|
}
|
||||||
motorController.StartRinging();
|
motorController.StartRinging();
|
||||||
break;
|
break;
|
||||||
|
@ -106,11 +106,18 @@ void Timer::UpdateMask() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Timer::Refresh() {
|
void Timer::Refresh() {
|
||||||
if (motorController.IsRinging()) {
|
if (isRinging) {
|
||||||
SetTimerRinging();
|
|
||||||
auto secondsElapsed = std::chrono::duration_cast<std::chrono::seconds>(timer.GetTimeRemaining());
|
auto secondsElapsed = std::chrono::duration_cast<std::chrono::seconds>(timer.GetTimeRemaining());
|
||||||
minuteCounter.SetValue(secondsElapsed.count() / 60);
|
minuteCounter.SetValue(secondsElapsed.count() / 60);
|
||||||
secondCounter.SetValue(secondsElapsed.count() % 60);
|
secondCounter.SetValue(secondsElapsed.count() % 60);
|
||||||
|
// Stop buzzing after 10 seconds, but continue the counter
|
||||||
|
if (motorController.IsRinging() && secondsElapsed.count() > 10) {
|
||||||
|
motorController.StopRinging();
|
||||||
|
}
|
||||||
|
// Reset timer after 1 minute
|
||||||
|
if (secondsElapsed.count() > 60) {
|
||||||
|
Reset();
|
||||||
|
}
|
||||||
} else if (timer.IsRunning()) {
|
} else if (timer.IsRunning()) {
|
||||||
auto secondsRemaining = std::chrono::duration_cast<std::chrono::seconds>(timer.GetTimeRemaining());
|
auto secondsRemaining = std::chrono::duration_cast<std::chrono::seconds>(timer.GetTimeRemaining());
|
||||||
minuteCounter.SetValue(secondsRemaining.count() / 60);
|
minuteCounter.SetValue(secondsRemaining.count() / 60);
|
||||||
@ -135,6 +142,7 @@ void Timer::SetTimerRunning() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Timer::SetTimerStopped() {
|
void Timer::SetTimerStopped() {
|
||||||
|
isRinging = false;
|
||||||
minuteCounter.ShowControls();
|
minuteCounter.ShowControls();
|
||||||
secondCounter.ShowControls();
|
secondCounter.ShowControls();
|
||||||
lv_label_set_text_static(txtPlayPause, "Start");
|
lv_label_set_text_static(txtPlayPause, "Start");
|
||||||
@ -142,6 +150,7 @@ void Timer::SetTimerStopped() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Timer::SetTimerRinging() {
|
void Timer::SetTimerRinging() {
|
||||||
|
isRinging = true;
|
||||||
minuteCounter.HideControls();
|
minuteCounter.HideControls();
|
||||||
secondCounter.HideControls();
|
secondCounter.HideControls();
|
||||||
lv_label_set_text_static(txtPlayPause, "Reset");
|
lv_label_set_text_static(txtPlayPause, "Reset");
|
||||||
@ -152,7 +161,7 @@ void Timer::SetTimerRinging() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Timer::ToggleRunning() {
|
void Timer::ToggleRunning() {
|
||||||
if (motorController.IsRinging()) {
|
if (isRinging) {
|
||||||
motorController.StopRinging();
|
motorController.StopRinging();
|
||||||
Reset();
|
Reset();
|
||||||
} else if (timer.IsRunning()) {
|
} else if (timer.IsRunning()) {
|
||||||
|
@ -22,11 +22,11 @@ namespace Pinetime::Applications {
|
|||||||
void ToggleRunning();
|
void ToggleRunning();
|
||||||
void ButtonPressed();
|
void ButtonPressed();
|
||||||
void MaskReset();
|
void MaskReset();
|
||||||
|
void SetTimerRinging();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void SetTimerRunning();
|
void SetTimerRunning();
|
||||||
void SetTimerStopped();
|
void SetTimerStopped();
|
||||||
void SetTimerRinging();
|
|
||||||
void UpdateMask();
|
void UpdateMask();
|
||||||
Pinetime::Controllers::Timer& timer;
|
Pinetime::Controllers::Timer& timer;
|
||||||
Pinetime::Controllers::MotorController& motorController;
|
Pinetime::Controllers::MotorController& motorController;
|
||||||
@ -44,6 +44,7 @@ namespace Pinetime::Applications {
|
|||||||
Widgets::Counter secondCounter = Widgets::Counter(0, 59, jetbrains_mono_76);
|
Widgets::Counter secondCounter = Widgets::Counter(0, 59, jetbrains_mono_76);
|
||||||
|
|
||||||
bool buttonPressing = false;
|
bool buttonPressing = false;
|
||||||
|
bool isRinging = false;
|
||||||
lv_coord_t maskPosition = 0;
|
lv_coord_t maskPosition = 0;
|
||||||
TickType_t pressTime = 0;
|
TickType_t pressTime = 0;
|
||||||
TickType_t ringTime = 0;
|
TickType_t ringTime = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user