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.
This commit is contained in:
Reinhold Gschweicher 2021-09-13 22:33:21 +02:00
parent 3eb73774a3
commit 63477fc096

View File

@ -78,7 +78,7 @@ Metronome::~Metronome() {
void Metronome::Refresh() { void Metronome::Refresh() {
if (metronomeStarted) { 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; startTime += 60 * configTICK_RATE_HZ / bpm;
counter--; counter--;
if (counter == 0) { if (counter == 0) {