[SOLVED] Software Timer .isActive() returns false even when enabled

Okay, here’s an interesting update. It would appear that if I put similar code in the main loop() that I get a mixed result; timer.isActive() doesn’t work the first time through the loop, but timer.isActive() does work the second time through the loop. It would appear that timer.isActive() only switches to true in between loops.

Here is my code:

#include "Particle.h"

SYSTEM_MODE(SEMI_AUTOMATIC);

void timerCallback();  //Forward declaration of timer callback function

Timer myTimer(1000, timerCallback); //Declare/define the software timer

void timerCallback(){
  myTimer.stopFromISR();
  digitalWrite(D7, HIGH);
}

void setup(){

  //Start the serial monitor
  Serial.begin(9600);

  pinMode(D7, OUTPUT);
  digitalWrite(D7, LOW);

  //Wait for user to enter a character into the serial monitor before continuing
  while(!Serial.available()){};

  Serial.println("Detected your keystroke!");

}

void loop(){

  Serial.println("Configuring the timer...");

  //Configure the timer
  myTimer.changePeriod(5000);
  myTimer.reset();
  myTimer.start();

  Serial.println("Now loop until the timer is no longer active");

  //Loop until the myTimer.isActive() is false
  boolean keepLooping = true;

  while(keepLooping){

    if(myTimer.isActive()){
      Serial.println("Waiting for timer to expire");
      delay(1000);
    }
    else{
      Serial.println("myTimer.isActive() = false \n Now exiting loop!");
      keepLooping = false;
    }
  };

}

And here is the output to the serial monitor:

Detected your keystroke!
Configuring the timer...
Now loop until the timer is no longer active
myTimer.isActive() = false
                            Now exiting loop!
Configuring the timer...
Now loop until the timer is no longer active
Waiting for timer to expire
Waiting for timer to expire
Waiting for timer to expire
Waiting for timer to expire
Waiting for timer to expire
myTimer.isActive() = false
                            Now exiting loop!
Configuring the timer...
Now loop until the timer is no longer active
myTimer.isActive() = false
                            Now exiting loop!
Configuring the timer...
Now loop until the timer is no longer active
Waiting for timer to expire
Waiting for timer to expire
Waiting for timer to expire
Waiting for timer to expire
Waiting for timer to expire
myTimer.isActive() = false
                            Now exiting loop!