evert-arias / EasyButton

Arduino library for debouncing momentary contact switches, detect press, release, long press and sequences with event definitions and callbacks.
https://easybtn.earias.me
MIT License
445 stars 62 forks source link

nrf52 'NOT_AN_INTERRUPT' was not declared in this scope #50

Open packetloss69 opened 3 years ago

packetloss69 commented 3 years ago

Hi there. Issue: When using EasyButton > 1.02 compilation failure with Adafruit nrf52 BSP Using https://github.com/adafruit/Adafruit_nRF52_Arduino BSP.

Arduino 1.8.13 nrf52 BSP versions affected 0.70 - 0.21.0 (All)

Works on all versions: Easybutton 1.0.2 Fails: 1.1.0 up to and including 2.0.1

Error produced: C:\Users\User\Documents\Arduino\libraries\EasyButton\src\EasyButton.cpp: In member function bool EasyButton::supportsInterrupt(): C:\Users\User\Documents\Arduino\libraries\EasyButton\src\EasyButton.cpp:139:41: error: NOT_AN_INTERRUPT was not declared in this scope 139 | return (digitalPinToInterrupt(_pin) != NOT_AN_INTERRUPT);

Error compiling for board Nordic nRF52840DK (PCA10056).

in EasyButton.cpp: bool EasyButton::supportsInterrupt() { return (digitalPinToInterrupt(_pin) != NOT_AN_INTERRUPT); }

references: C:\Users\User\AppData\Local\Arduino15\packages\adafruit\hardware\nrf52\0.21.0\cores\nRF5\Arduino.h

contains

#define digitalPinToInterrupt(P) ( P )

Any ideas?

Edited: Compiles after adding to EasyButton.h #define NOT_AN_INTERRUPT -1

Is this a vaild workaround as it seems NOT_AN_INTERRUPT -1 is Arduino 1.6 Legacy?

CSC-Sendance commented 1 year ago

A valid workaround for this that also avoids issues stemming from copying the whole library or trying to update it is including the macro via buildflag: -DNOT_AN_INTERRUPT=-1`

If you are using platformio, edit your platformio.ini 's build variant to include:

build_flags = 
    -DNOT_AN_INTERRUPT=-1 ;
jonfroehlich commented 1 year ago

Just confirming that this is still an issue with Adafruit Feather nRF52840, Arduino IDE 2.0.3, and EasyButton Version 2.0.1.

c:\Users\jonf\Documents\Arduino\libraries\EasyButton\src\EasyButton.cpp: In member function 'bool EasyButton::supportsInterrupt()':
c:\Users\jonf\Documents\Arduino\libraries\EasyButton\src\EasyButton.cpp:99:41: error: 'NOT_AN_INTERRUPT' was not declared in this scope
   99 |  return (digitalPinToInterrupt(_pin) != NOT_AN_INTERRUPT);

I'm not using interrupts with buttons so I added #define NOT_AN_INTERRUPT -1 to the top of EasyButton.h and that solved it.