Skip to content

Commit

Permalink
ESP32-C3: Work around for some C3 specific compiler issues.
Browse files Browse the repository at this point in the history
Seems the experimental Arduino support for the ESP32-C3 is a bit more finiky than the other environments.
Work around those issues by forcing the compiler to chose the correct std::min() & std::max() routines by casting the arguments.

Fixes #1695
  • Loading branch information
crankyoldgit committed Dec 6, 2021
1 parent 0f2ff14 commit 7f0b176
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/IRrecv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1079,7 +1079,7 @@ uint32_t IRrecv::ticksLow(const uint32_t usecs, const uint8_t tolerance,
// max() used to ensure the result can't drop below 0 before the cast.
return ((uint32_t)std::max(
(int32_t)(usecs * (1.0 - _validTolerance(tolerance) / 100.0) - delta),
0));
(int32_t)0));
}

/// Calculate the upper bound of the nr. of ticks.
Expand Down Expand Up @@ -1162,7 +1162,8 @@ bool IRrecv::matchAtLeast(uint32_t measured, uint32_t desired,
// We really should never get a value of 0, except as the last value
// in the buffer. If that is the case, then assume infinity and return true.
if (measured == 0) return true;
return measured >= ticksLow(std::min(desired, MS_TO_USEC(params.timeout)),
return measured >= ticksLow(std::min(desired,
(uint32_t)MS_TO_USEC(params.timeout)),
tolerance, delta);
}

Expand Down

0 comments on commit 7f0b176

Please sign in to comment.