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) {
|
||||
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) {
|
||||
lv_disp_trig_activity(nullptr);
|
||||
auto* timer = static_cast<Screens::Timer*>(currentScreen.get());
|
||||
timer->Reset();
|
||||
} else {
|
||||
LoadNewScreen(Apps::Timer, DisplayApp::FullRefreshDirections::Up);
|
||||
timer->SetTimerRinging();
|
||||
}
|
||||
motorController.StartRinging();
|
||||
break;
|
||||
|
@ -106,11 +106,18 @@ void Timer::UpdateMask() {
|
||||
}
|
||||
|
||||
void Timer::Refresh() {
|
||||
if (motorController.IsRinging()) {
|
||||
SetTimerRinging();
|
||||
if (isRinging) {
|
||||
auto secondsElapsed = std::chrono::duration_cast<std::chrono::seconds>(timer.GetTimeRemaining());
|
||||
minuteCounter.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()) {
|
||||
auto secondsRemaining = std::chrono::duration_cast<std::chrono::seconds>(timer.GetTimeRemaining());
|
||||
minuteCounter.SetValue(secondsRemaining.count() / 60);
|
||||
@ -135,6 +142,7 @@ void Timer::SetTimerRunning() {
|
||||
}
|
||||
|
||||
void Timer::SetTimerStopped() {
|
||||
isRinging = false;
|
||||
minuteCounter.ShowControls();
|
||||
secondCounter.ShowControls();
|
||||
lv_label_set_text_static(txtPlayPause, "Start");
|
||||
@ -142,6 +150,7 @@ void Timer::SetTimerStopped() {
|
||||
}
|
||||
|
||||
void Timer::SetTimerRinging() {
|
||||
isRinging = true;
|
||||
minuteCounter.HideControls();
|
||||
secondCounter.HideControls();
|
||||
lv_label_set_text_static(txtPlayPause, "Reset");
|
||||
@ -152,7 +161,7 @@ void Timer::SetTimerRinging() {
|
||||
}
|
||||
|
||||
void Timer::ToggleRunning() {
|
||||
if (motorController.IsRinging()) {
|
||||
if (isRinging) {
|
||||
motorController.StopRinging();
|
||||
Reset();
|
||||
} else if (timer.IsRunning()) {
|
||||
|
@ -22,11 +22,11 @@ namespace Pinetime::Applications {
|
||||
void ToggleRunning();
|
||||
void ButtonPressed();
|
||||
void MaskReset();
|
||||
void SetTimerRinging();
|
||||
|
||||
private:
|
||||
void SetTimerRunning();
|
||||
void SetTimerStopped();
|
||||
void SetTimerRinging();
|
||||
void UpdateMask();
|
||||
Pinetime::Controllers::Timer& timer;
|
||||
Pinetime::Controllers::MotorController& motorController;
|
||||
@ -44,6 +44,7 @@ namespace Pinetime::Applications {
|
||||
Widgets::Counter secondCounter = Widgets::Counter(0, 59, jetbrains_mono_76);
|
||||
|
||||
bool buttonPressing = false;
|
||||
bool isRinging = false;
|
||||
lv_coord_t maskPosition = 0;
|
||||
TickType_t pressTime = 0;
|
||||
TickType_t ringTime = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user