aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/displayapp/screens/StopWatch.cpp15
-rw-r--r--src/displayapp/screens/StopWatch.h3
2 files changed, 12 insertions, 6 deletions
diff --git a/src/displayapp/screens/StopWatch.cpp b/src/displayapp/screens/StopWatch.cpp
index 506a317b..fffedcc3 100644
--- a/src/displayapp/screens/StopWatch.cpp
+++ b/src/displayapp/screens/StopWatch.cpp
@@ -15,7 +15,7 @@ namespace {
const int secs = (timeElapsedSecs) % 60;
const int mins = (timeElapsedSecs / 60) % 60;
const int hours = (timeElapsedSecs / 60) / 60;
- return TimeSeparated {hours, mins, secs, hundredths};
+ return TimeSeparated {hours, mins, secs, hundredths, timeElapsedSecs};
}
void PlayPauseEventHandler(lv_obj_t* obj, lv_event_t event) {
@@ -145,11 +145,14 @@ void StopWatch::DisplayCleared() {
void StopWatch::RenderTime() {
TimeSeparated elapsedTime = ConvertTicksToTimeSegments(stopWatchController.GetElapsedTime());
- SetHoursVisible(elapsedTime.hours != 0);
- if (!hoursVisible) {
- lv_label_set_text_fmt(time, "%02d:%02d", elapsedTime.mins, elapsedTime.secs);
- } else {
- lv_label_set_text_fmt(time, "%02d:%02d:%02d", elapsedTime.hours, elapsedTime.mins, elapsedTime.secs);
+ renderedSeconds = elapsedTime.epochSecs;
+ if (renderedSeconds.IsUpdated()) {
+ SetHoursVisible(elapsedTime.hours != 0);
+ if (!hoursVisible) {
+ lv_label_set_text_fmt(time, "%02d:%02d", elapsedTime.mins, elapsedTime.secs);
+ } else {
+ lv_label_set_text_fmt(time, "%02d:%02d:%02d", elapsedTime.hours, elapsedTime.mins, elapsedTime.secs);
+ }
}
lv_label_set_text_fmt(msecTime, "%02d", elapsedTime.hundredths);
}
diff --git a/src/displayapp/screens/StopWatch.h b/src/displayapp/screens/StopWatch.h
index 51920f8b..249eec84 100644
--- a/src/displayapp/screens/StopWatch.h
+++ b/src/displayapp/screens/StopWatch.h
@@ -7,6 +7,7 @@
#include "systemtask/SystemTask.h"
#include "systemtask/WakeLock.h"
#include "Symbols.h"
+#include "utility/DirtyValue.h"
namespace Pinetime::Applications {
namespace Screens {
@@ -16,6 +17,7 @@ namespace Pinetime::Applications {
int mins;
int secs;
int hundredths;
+ int epochSecs;
};
class StopWatch : public Screen {
@@ -47,6 +49,7 @@ namespace Pinetime::Applications {
int displayedLaps = 3;
lv_obj_t *time, *msecTime, *btnPlayPause, *btnStopLap, *txtPlayPause, *txtStopLap;
lv_obj_t* lapText;
+ Utility::DirtyValue<TickType_t> renderedSeconds;
bool hoursVisible = false;
lv_task_t* taskRefresh;