summaryrefslogtreecommitdiff
path: root/src/displayapp/screens/StopWatch.cpp
diff options
context:
space:
mode:
authorJF002 <JF002@users.noreply.github.com>2021-08-28 16:39:48 +0200
committerGitHub <noreply@github.com>2021-08-28 16:39:48 +0200
commit2870d3ae6c00f127883e6cedecda328994b0fec7 (patch)
tree75c4b96ace962cbb965c2bdd0dd11137b471c5ac /src/displayapp/screens/StopWatch.cpp
parentfab49f8557ef8ff38fe4f607e33b18fb5a1aeb9a (diff)
parentc2fae47391f02b515c8d85a00ae1b7190bcd30a0 (diff)
Merge pull request #497 from Riksu9000/refresh_rework
Rework Refresh
Diffstat (limited to 'src/displayapp/screens/StopWatch.cpp')
-rw-r--r--src/displayapp/screens/StopWatch.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/displayapp/screens/StopWatch.cpp b/src/displayapp/screens/StopWatch.cpp
index e3db6299..9b27a89d 100644
--- a/src/displayapp/screens/StopWatch.cpp
+++ b/src/displayapp/screens/StopWatch.cpp
@@ -48,7 +48,6 @@ static void stop_lap_event_handler(lv_obj_t* obj, lv_event_t event) {
StopWatch::StopWatch(DisplayApp* app, System::SystemTask& systemTask)
: Screen(app),
systemTask {systemTask},
- running {true},
currentState {States::Init},
startTime {},
oldTimeElapsed {},
@@ -101,9 +100,12 @@ StopWatch::StopWatch(DisplayApp* app, System::SystemTask& systemTask)
lv_obj_set_style_local_text_color(lapTwoText, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_YELLOW);
lv_obj_align(lapTwoText, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 50, 55);
lv_label_set_text(lapTwoText, "");
+
+ taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
}
StopWatch::~StopWatch() {
+ lv_task_del(taskRefresh);
systemTask.PushMessage(Pinetime::System::Messages::EnableSleeping);
lv_obj_clean(lv_scr_act());
}
@@ -149,7 +151,7 @@ void StopWatch::pause() {
systemTask.PushMessage(Pinetime::System::Messages::EnableSleeping);
}
-bool StopWatch::Refresh() {
+void StopWatch::Refresh() {
if (currentState == States::Running) {
timeElapsed = calculateDelta(startTime, xTaskGetTickCount());
currentTimeSeparated = convertTicksToTimeSegments((oldTimeElapsed + timeElapsed));
@@ -157,7 +159,6 @@ bool StopWatch::Refresh() {
lv_label_set_text_fmt(time, "%02d:%02d", currentTimeSeparated.mins, currentTimeSeparated.secs);
lv_label_set_text_fmt(msecTime, "%02d", currentTimeSeparated.hundredths);
}
- return running;
}
void StopWatch::playPauseBtnEventHandler(lv_event_t event) {
@@ -196,8 +197,7 @@ void StopWatch::stopLapBtnEventHandler(lv_event_t event) {
bool StopWatch::OnButtonPushed() {
if (currentState == States::Running) {
pause();
- } else {
- running = false;
+ return true;
}
- return true;
+ return false;
}