summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/displayapp/screens/Timer.cpp16
-rw-r--r--src/displayapp/screens/Timer.h17
2 files changed, 22 insertions, 11 deletions
diff --git a/src/displayapp/screens/Timer.cpp b/src/displayapp/screens/Timer.cpp
index 459d5f6..1b2144c 100644
--- a/src/displayapp/screens/Timer.cpp
+++ b/src/displayapp/screens/Timer.cpp
@@ -13,7 +13,8 @@ void Timer::btnEventHandler(lv_obj_t* obj, lv_event_t event) {
void Timer::Stop() {
int32_t secondsRemaining = timerController.GetSecondsRemaining();
- if (timerController.IsOvertime()) {
+ bool ot = timerController.IsOvertime();
+ if (ot) {
minutesToSet = 0;
secondsToSet = 0;
secondsRemaining = 0;
@@ -23,6 +24,9 @@ void Timer::Stop() {
}
timerController.StopTimer();
RefreshRunning();
+ if (ot) {
+ setTimeTextColor(LV_COLOR_RED);
+ }
}
Timer::Timer(DisplayApp* app, Controllers::TimerController& timerController)
@@ -75,16 +79,20 @@ void Timer::Refresh() {
}
}
+void Timer::setTimeTextColor(lv_color_t color) {
+ lv_obj_set_style_local_text_color(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color);
+}
+
void Timer::RefreshRunning() {
if (timerController.IsRunning()) {
if (timerController.IsOvertime()) {
- lv_obj_set_style_local_text_color(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_RED);
+ setTimeTextColor(LV_COLOR_RED);
} else {
- lv_obj_set_style_local_text_color(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_LIME);
+ setTimeTextColor(LV_COLOR_LIME);
}
lv_label_set_text_static(txtPlayPause, Symbols::pause);
} else {
- lv_obj_set_style_local_text_color(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
+ setTimeTextColor(LV_COLOR_GRAY);
lv_label_set_text_static(txtPlayPause, Symbols::play);
CreateButtons();
}
diff --git a/src/displayapp/screens/Timer.h b/src/displayapp/screens/Timer.h
index 3f6d782..9a2362a 100644
--- a/src/displayapp/screens/Timer.h
+++ b/src/displayapp/screens/Timer.h
@@ -40,37 +40,40 @@ namespace Pinetime::Applications::Screens {
} else {
minutesToSet++;
}
- lv_label_set_text_fmt(time, "%02d:%02d", minutesToSet, secondsToSet);
-
+ goto setlabel;
} else if (obj == btnMinutesDown) {
if (minutesToSet == 0) {
minutesToSet = 59;
} else {
minutesToSet--;
}
- lv_label_set_text_fmt(time, "%02d:%02d", minutesToSet, secondsToSet);
-
+ goto setlabel;
} else if (obj == btnSecondsUp) {
if (secondsToSet >= 59) {
secondsToSet = 0;
} else {
secondsToSet++;
}
- lv_label_set_text_fmt(time, "%02d:%02d", minutesToSet, secondsToSet);
-
+ goto setlabel;
} else if (obj == btnSecondsDown) {
if (secondsToSet == 0) {
secondsToSet = 59;
} else {
secondsToSet--;
}
- lv_label_set_text_fmt(time, "%02d:%02d", minutesToSet, secondsToSet);
+ goto setlabel;
}
+ return;
+ setlabel:
+ setTimeTextColor(LV_COLOR_GRAY);
+ lv_label_set_text_fmt(time, "%02d:%02d", minutesToSet, secondsToSet);
}
}
}
}
+ void setTimeTextColor(lv_color_t color);
+
inline void CreateButtons() {
if (btnMinutesUp != nullptr) {
return;