So it seems that if I block out a piece of code with noInterrupts(), and attempt to interrupt, that it does interrupt.
Near as I can tell, does noInterrupts() not turn interrupts off, but just keeps the code from executing until interrupts() is called?
As in, it queues up, but doesn’t execute?
Here is the code I’m playing with, where I turn on the Argon’s light at D7, and enter a 10 second loop. If I hit my button while the light is on, I’ll get serial output, after the light goes out, of Button Presses: 1
Which makes me think it queues up the interrupt, but doesn’t execute it. If so, how I would not even let it queue up?
I’ve had some struggle with detachInterrupt and then attachInterrupt.
#include "application.h"
SYSTEM_THREAD(ENABLED);
SYSTEM_MODE(MANUAL);
uint8_t ButtonPressCount = 0;
system_tick_t LastButtonPress = 0;
void DoButtonPressEvent(void)
{
if ((millis() - LastButtonPress) > 250)
ButtonPressCount++;
}
void setup(void)
{
pinMode(D7, PinMode::OUTPUT);
digitalWrite(D7, PinState::LOW);
LastButtonPress = millis();
Serial.begin();
noInterrupts();
pinMode(D6, PinMode::INPUT);
attachInterrupt(D6, DoButtonPressEvent, InterruptMode::RISING);
digitalWrite(D7, PinState::HIGH);
do
{
// kill time for 10 seconds
} while((millis() - LastButtonPress) < 10000);
digitalWrite(D7, PinState::LOW);
interrupts();
}
void loop(void)
{
if (ButtonPressCount > 0)
Serial.printlnf("Button presses: %d", ButtonPressCount);
}