dmadison / ServoInput

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

Pin Change Library #7

Closed dmadison closed 4 years ago

dmadison commented 4 years ago

Adds automatic support for Nico Hood's PinChangeInterrupt library. When imported before ServoInput, any input pins that don't support external interrupts ( digitalPinToInterrupt()) will instead be attached to a pin change interrupt.

I flirted with making this integrated into the library entirely so that the user didn't have to worry about which pins were interrupt-capable, but I'm not a big fan of the external dependency. Plus it creates issues if the user wants to use any pin change interrupt or library with pin change interrupts outside of NicoHood's implementation - regardless of whether or not they're using a ServoInputPin object with pin change interrupts (the vector can't be redefined). It also creates a bit of a mess for cross-platform support, since Nico's library only works for specific AVR chips and doesn't have a way to return a compile-time flag for supported boards.

Instead I'm settling on this: if the user imports Nico's library before ServoInput, the header sets a define and processes pin change interrupts automatically. This also puts the onus on the user to explicitly invoke the PinChange library if they need it.

This PR also refactors the static_assert preprocessor define suppress flag to actually say "SUPPRESS" instead of the more misleading "ENABLE".