I’m trying to attach an interrupt to the WKP/A7 pin so that I can put my Photon into a deep sleep after being idle for a few minutes, but can have it function normally when its awake.
I’m trying to use a library that I wrote, and I’ve included the ISR as a method in the library (it sets a pending bit to true for the service loop to handle), but I get the dreaded blinky oragne light as soon as the attachInterrupt() function is called. I put together a simplified version of what I’m trying to do, and I still run into the same issue:
WKP_Test.ino:
#include "ints.h"
#include "application.h"
//ints::Ints intTest(D2); // I work if I'm uncommented
ints::Ints intTest(WKP);
void setup() {
Serial.begin(9600);
intTest.begin();
}
void loop() {
if(intTest.intPending){
Serial.println("Interrupted!");
intTest.intPending = false;
}
delay(100);
}
ints.cpp:
ints::Ints::Ints(int pin){
intPin = pin;
}
void ints::Ints::handleInt(void){
intPending = true;
}
void ints::Ints::begin(void){
Serial.println("I'll get printed");
delay(500);
pinMode(intPin, INPUT_PULLDOWN);
Serial.println("I will too.");
delay(500);
attachInterrupt(intPin, &Ints::handleInt, this, RISING);
Serial.println("I'll never be seen by anyone if intPin is WKP :(");
delay(500);
}
void ints::Ints::resetInt(void){
intPending = false;
}
ints.h
#include "application.h"
namespace ints {
class Ints {
public:
int intPin;
bool intPending;
Ints(int pin);
void begin(void);
void handleInt(void);
void resetInt(void);
};
}
Since the above works when using pin D2, but not WKP, I’m really stumped. Any ideas?
edit: Included ints.h