@@ -74,9 +74,9 @@ uint32_t IRsend::calcUSecPeriod(uint32_t hz, bool use_offset) {
74
74
(1000000UL + hz / 2 ) / hz; // The equiv of round(1000000/hz).
75
75
// Apply the offset and ensure we don't result in a <= 0 value.
76
76
if (use_offset)
77
- return std::max (( uint32_t ) 1 , period + periodOffset);
77
+ return std::max (static_cast < uint32_t >( 1 ) , period + periodOffset);
78
78
else
79
- return std::max (( uint32_t ) 1 , period);
79
+ return std::max (static_cast < uint32_t >( 1 ) , period);
80
80
}
81
81
82
82
// / Set the output frequency modulation and duty cycle.
@@ -174,14 +174,16 @@ uint16_t IRsend::mark(uint16_t usec) {
174
174
ledOn ();
175
175
// Calculate how long we should pulse on for.
176
176
// e.g. Are we to close to the end of our requested mark time (usec)?
177
- _delayMicroseconds (std::min ((uint32_t )onTimePeriod, usec - elapsed));
177
+ _delayMicroseconds (std::min (static_cast <uint32_t >(onTimePeriod),
178
+ usec - elapsed));
178
179
ledOff ();
179
180
counter++;
180
181
if (elapsed + onTimePeriod >= usec)
181
182
return counter; // LED is now off & we've passed our allotted time.
182
183
// Wait for the lesser of the rest of the duty cycle, or the time remaining.
183
184
_delayMicroseconds (
184
- std::min (usec - elapsed - onTimePeriod, (uint32_t )offTimePeriod));
185
+ std::min (usec - elapsed - onTimePeriod,
186
+ static_cast <uint32_t >(offTimePeriod)));
185
187
elapsed = usecTimer.elapsed (); // Update & recache the actual elapsed time.
186
188
}
187
189
return counter;
@@ -214,7 +216,7 @@ int8_t IRsend::calibrate(uint16_t hz) {
214
216
uint32_t timeTaken = usecTimer.elapsed (); // Record the time it took.
215
217
// While it shouldn't be necessary, assume at least 1 pulse, to avoid a
216
218
// divide by 0 situation.
217
- pulses = std::max (pulses, ( uint16_t ) 1U );
219
+ pulses = std::max (pulses, static_cast < uint16_t >( 1U ) );
218
220
uint32_t calcPeriod = calcUSecPeriod (hz); // e.g. @38kHz it should be 26us.
219
221
// Assuming 38kHz for the example calculations:
220
222
// In a 65535us pulse, we should have 2520.5769 pulses @ 26us periods.
0 commit comments