dmadison / ServoInput

Interrupt-driven servo decoder library for Arduino
GNU Lesser General Public License v3.0
22 stars 10 forks source link

Buffer pulse duration #10

Closed dmadison closed 4 years ago

dmadison commented 4 years ago

Creates a buffered copy of the pulse duration within the base class. This requires 2 extra bytes of storage, but the benefit is that if the pulse duration wanders out of the 'valid' range for any reason the function will return the last known valid pulse rather than the center of the range. If the signal is noisy or ringing this will help keep it steady rather than constantly bouncing back and forth from the range's center.

This changes the default behavior of getPulse() when no signal is detected. It now returns the low end of the range rather than the center. As this modifies a class value, all of the 'get' functions that call getPulse() are no longer const.

This PR also fixes a minor issue with the getBoolean() function that replicated functionality from the getRangeCenter() function.