From 7577f09d70b2a9e0ed5605607ac401985f945f78 Mon Sep 17 00:00:00 2001 From: David Madison Date: Thu, 25 Jan 2024 10:49:47 -0500 Subject: [PATCH] Refactor attach and detach to remove 'Interrupt' Having the class functions share the name of the global function was good for intuitiveness, but causes issues on platforms that implement the global 'attachInterrupt' as something other than a function (see #27). Removing 'Interrupt' from the name also makes these functions match their counterparts in the Servo library. --- src/ServoInput.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/ServoInput.h b/src/ServoInput.h index c1d4fd4..d1cb448 100644 --- a/src/ServoInput.h +++ b/src/ServoInput.h @@ -96,14 +96,14 @@ class ServoInputPin : public ServoInputSignal { ServoInputPin::PortRegister = SERVOINPUT_PIN_TO_BASEREG(Pin); #endif pinMode(Pin, INPUT_PULLUP); - attachInterrupt(); + attach(); } ServoInputPin(uint16_t pMin, uint16_t pMax) : ServoInputPin() { ServoInputSignal::setRange(pMin, pMax); } - void attachInterrupt() { + void attach() { #if !defined(SERVOINPUT_NO_INTERRUPTS) // Compile-time check that the selected pin supports interrupts @@ -116,7 +116,7 @@ class ServoInputPin : public ServoInputSignal { // Interrupt attachment, platform support if (digitalPinToInterrupt(Pin) != NOT_AN_INTERRUPT) { // if pin supports external interrupts - ::attachInterrupt(digitalPinToInterrupt(Pin), reinterpret_cast(isr), CHANGE); + attachInterrupt(digitalPinToInterrupt(Pin), reinterpret_cast(isr), CHANGE); } // Interrupt attachment, PinChangeInterrupt @@ -131,13 +131,13 @@ class ServoInputPin : public ServoInputSignal { // because we have no way of checking whether the pin is supported // in hardware vs in the library #else - ::attachInterrupt(digitalPinToInterrupt(Pin), reinterpret_cast(isr), CHANGE); + attachInterrupt(digitalPinToInterrupt(Pin), reinterpret_cast(isr), CHANGE); #endif #endif } - void detachInterrupt() { + void detach() { #if !defined(SERVOINPUT_NO_INTERRUPTS) // Interrupt detachment, with pin checks @@ -145,7 +145,7 @@ class ServoInputPin : public ServoInputSignal { // Interrupt detachment, platform support if (digitalPinToInterrupt(Pin) != NOT_AN_INTERRUPT) { // detach external interrupt - ::detachInterrupt(digitalPinToInterrupt(Pin)); + detachInterrupt(digitalPinToInterrupt(Pin)); } // Interrupt detachment, PinChangeInterrupt @@ -157,7 +157,7 @@ class ServoInputPin : public ServoInputSignal { // Interrupt detachment, no pin checks #else - ::detachInterrupt(digitalPinToInterrupt(Pin)); + detachInterrupt(digitalPinToInterrupt(Pin)); #endif #endif }