aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorflu0r1ne <flu0r1ne@flu0r1ne.net>2023-07-13 13:03:59 -0500
committerflu0r1ne <flu0r1ne@flu0r1ne.net>2023-07-13 13:03:59 -0500
commit0c39f286f6125ecc98e9216443d98a011b17a8c1 (patch)
tree53727a2f1dbd132087fe9c066152c9aefd4b2fdb /src
parentef27c1d222eeb953a625954be8e54b0bf5f92e53 (diff)
downloadfreqtimer-web-0c39f286f6125ecc98e9216443d98a011b17a8c1.tar.xz
freqtimer-web-0c39f286f6125ecc98e9216443d98a011b17a8c1.zip
Fix counter to show overtime value when preset, offer reset before a clear when a counter is incremented
Diffstat (limited to 'src')
-rw-r--r--src/controllers/timer_view.cpp5
-rw-r--r--src/models/counter.cpp4
-rw-r--r--src/models/counter.hpp2
-rw-r--r--src/view/index.html2
4 files changed, 9 insertions, 4 deletions
diff --git a/src/controllers/timer_view.cpp b/src/controllers/timer_view.cpp
index 28abd5c..841d7f7 100644
--- a/src/controllers/timer_view.cpp
+++ b/src/controllers/timer_view.cpp
@@ -68,6 +68,7 @@ class TimerView {
}
_update_clear_reset_btn_label();
+ _update_clear_reset_btn();
}
/*
@@ -89,6 +90,8 @@ class TimerView {
_counters[counter_num].inc();
_update_counter(counter_num);
+
+ _update_clear_reset_btn_label();
}
void handle_timer_update() {
@@ -181,7 +184,7 @@ class TimerView {
}
bool _clear_reset_btn_clears() const {
- return _timer.has_preset() and !_timer.started();
+ return _timer.has_preset() and !_timer.started() and (_counters[0].cnt() == 0 && _counters[1].cnt() == 0);
}
void _update_clear_reset_btn_label() {
diff --git a/src/models/counter.cpp b/src/models/counter.cpp
index 4855c24..1b6315d 100644
--- a/src/models/counter.cpp
+++ b/src/models/counter.cpp
@@ -16,11 +16,11 @@ double FreqCounter::overtime_rate() const {
}
std::string FreqCounter::display_value() const {
- if(_cnt == UINT32_MAX) {
+ if(_overtime_cnt == UINT32_MAX) {
return "ERR";
}
- return std::to_string(_cnt);
+ return std::to_string(_overtime_cnt);
}
void FreqCounter::inc() {
diff --git a/src/models/counter.hpp b/src/models/counter.hpp
index d1b68fc..fa9e1c5 100644
--- a/src/models/counter.hpp
+++ b/src/models/counter.hpp
@@ -18,6 +18,8 @@ class FreqCounter {
uint32_t cnt() const { return _cnt; }
+ uint32_t overtime_cnt() const { return _overtime_cnt; }
+
[[nodiscard]] double rate() const;
[[nodiscard]] double overtime_rate() const;
diff --git a/src/view/index.html b/src/view/index.html
index 9c567af..b92cc6d 100644
--- a/src/view/index.html
+++ b/src/view/index.html
@@ -140,7 +140,7 @@
class="btn btn-danger btn-llg w-100"
id="clear-reset-btn"
onclick="timer_view.handle_clear_reset();"
- >Clear</button>
+ >Reset</button>
<button
class="btn btn-success btn-llg w-100"
id="start-stop-btn"