diff options
| author | Riku Isokoski <riksu9000@gmail.com> | 2021-07-19 13:26:12 (GMT) |
|---|---|---|
| committer | Riku Isokoski <riksu9000@gmail.com> | 2021-07-19 13:26:12 (GMT) |
| commit | 97c761a5c74994ea1d9bef9c14e6e24afb9b4be2 (patch) | |
| tree | 11bbbe45fa4e1557cc5e3b7da08c1c380741c9c2 /src/displayapp/screens/StopWatch.cpp | |
| parent | 57b339707861c5688f5d432f1506a99df6bb0fce (diff) | |
Refresh rework
Diffstat (limited to 'src/displayapp/screens/StopWatch.cpp')
| -rw-r--r-- | src/displayapp/screens/StopWatch.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/displayapp/screens/StopWatch.cpp b/src/displayapp/screens/StopWatch.cpp index f4db5d6..74b49db 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, 20, 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; } |
