From 56799d27d0a8250a933d873ff78e4b815aaec80e Mon Sep 17 00:00:00 2001 From: Josh Date: Tue, 7 May 2024 03:37:09 +0000 Subject: [PATCH 1/2] stopwatch: disable laps at maxLapCount --- src/displayapp/screens/StopWatch.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/displayapp/screens/StopWatch.cpp b/src/displayapp/screens/StopWatch.cpp index f0359da4..c649f793 100644 --- a/src/displayapp/screens/StopWatch.cpp +++ b/src/displayapp/screens/StopWatch.cpp @@ -88,19 +88,21 @@ void StopWatch::SetInterfacePaused() { lv_obj_set_style_local_bg_color(btnPlayPause, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Colors::blue); lv_label_set_text_static(txtPlayPause, Symbols::play); lv_label_set_text_static(txtStopLap, Symbols::stop); + lv_obj_set_state(btnStopLap, LV_STATE_DEFAULT); + lv_obj_set_state(txtStopLap, LV_STATE_DEFAULT); } void StopWatch::SetInterfaceRunning() { lv_obj_set_state(time, LV_STATE_DEFAULT); lv_obj_set_state(msecTime, LV_STATE_DEFAULT); lv_obj_set_style_local_bg_color(btnPlayPause, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Colors::bgAlt); - lv_obj_set_style_local_bg_color(btnStopLap, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Colors::bgAlt); + lv_obj_set_style_local_bg_color(btnStopLap, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, (lapsDone == maxLapCount) ? Colors::bgDark : Colors::bgAlt); lv_label_set_text_static(txtPlayPause, Symbols::pause); lv_label_set_text_static(txtStopLap, Symbols::lapsFlag); - lv_obj_set_state(btnStopLap, LV_STATE_DEFAULT); - lv_obj_set_state(txtStopLap, LV_STATE_DEFAULT); + lv_obj_set_state(btnStopLap, (lapsDone == maxLapCount) ? LV_STATE_DISABLED : LV_STATE_DEFAULT); + lv_obj_set_state(txtStopLap, (lapsDone == maxLapCount) ? LV_STATE_DISABLED : LV_STATE_DEFAULT); } void StopWatch::SetInterfaceStopped() { @@ -192,6 +194,11 @@ void StopWatch::stopLapBtnEventHandler() { if (currentState == States::Running) { lv_label_set_text(lapText, ""); lapsDone = std::min(lapsDone + 1, maxLapCount); + if (lapsDone == maxLapCount) { + // lv_obj_set_style_local_bg_color(btnStopLap, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Colors::bgDark); + lv_obj_set_state(btnStopLap, LV_STATE_DISABLED); + lv_obj_set_state(txtStopLap, LV_STATE_DISABLED); + } for (int i = lapsDone - displayedLaps; i < lapsDone; i++) { if (i < 0) { lv_label_ins_text(lapText, LV_LABEL_POS_LAST, "\n"); From effced8bda7ab61fd38a88ec26c06f568409957d Mon Sep 17 00:00:00 2001 From: Josh Date: Tue, 7 May 2024 03:38:17 +0000 Subject: [PATCH 2/2] stopwatch: disable laps at maxLapCount --- src/displayapp/screens/StopWatch.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/displayapp/screens/StopWatch.cpp b/src/displayapp/screens/StopWatch.cpp index c649f793..d1ef89f2 100644 --- a/src/displayapp/screens/StopWatch.cpp +++ b/src/displayapp/screens/StopWatch.cpp @@ -195,7 +195,6 @@ void StopWatch::stopLapBtnEventHandler() { lv_label_set_text(lapText, ""); lapsDone = std::min(lapsDone + 1, maxLapCount); if (lapsDone == maxLapCount) { - // lv_obj_set_style_local_bg_color(btnStopLap, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Colors::bgDark); lv_obj_set_state(btnStopLap, LV_STATE_DISABLED); lv_obj_set_state(txtStopLap, LV_STATE_DISABLED); }