summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorReinhold Gschweicher <pyro4hell@gmail.com>2021-09-13 22:33:21 +0200
committerReinhold Gschweicher <pyro4hell@gmail.com>2021-09-16 10:47:09 +0200
commit63477fc09616b5f7df0af17dd5d990a760ba2ae4 (patch)
tree0371432de9b7be8ceb926cfb7f59361c8cd39bc7 /src
parent3eb73774a39e255cd4b5de76441a59f1525a989c (diff)
Fix unsigned/signed comparison warning in Metronome.cpp
`xTaskGetTickCount()` returns a `TickType_t`, which is defined as an `uint32_t`. This is compared to the `bpm` variable, which is a `int16_t` in the range of 40 to 220 as defined in the constructor. ```cpp lv_arc_set_range(bpmArc, 40, 220); ``` Just assume that `bpm` is greater than 0, as this would result in a divison by zero or negative values, which would unintentionally underflow to a very large number.
Diffstat (limited to 'src')
-rw-r--r--src/displayapp/screens/Metronome.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/displayapp/screens/Metronome.cpp b/src/displayapp/screens/Metronome.cpp
index 884a4a51..52cb8519 100644
--- a/src/displayapp/screens/Metronome.cpp
+++ b/src/displayapp/screens/Metronome.cpp
@@ -78,7 +78,7 @@ Metronome::~Metronome() {
void Metronome::Refresh() {
if (metronomeStarted) {
- if (xTaskGetTickCount() - startTime > 60 * configTICK_RATE_HZ / bpm) {
+ if (xTaskGetTickCount() - startTime > 60u * configTICK_RATE_HZ / static_cast<uint16_t>(bpm)) {
startTime += 60 * configTICK_RATE_HZ / bpm;
counter--;
if (counter == 0) {