Skip to content

BUG when delayed a fire #2

Description

@DinoMesina

There is a BUG in reset() when the fire() function is called in delay it do not compute correctly the time between the calls.
Maybe its a features but when I need a correct time count between two calls it fails continuous

#include "FireTimer.h"
FireTimer timer0, timer1;
unsigned long start, diff;

void setup() {
  Serial.begin(115200);
  timer0.start();
  timer1.start();
  timer0.begin(1000);
  timer1.begin(1000);
  start = millis();
}

void loop() {
  if (timer0.fire()) {
    Serial.print("timer0.timeDiff = "); Serial.println(timer0.timeDiff);
  }
  diff = millis() - start;
  if (diff >= 1500) {
    start = millis();
    if (timer1.fire()) {
      Serial.println();
      Serial.print("millis() diff   = "); Serial.println(diff);
      Serial.print("timer1.timeDiff = "); Serial.println(timer1.timeDiff);
      Serial.println();
    }
  }
  delay(10);
}
13:43:59.142 -> timer0.timeDiff = 1000
13:43:59.640 -> 
13:43:59.640 -> millis() diff   = 1500
13:43:59.640 -> timer1.timeDiff = 1500
13:43:59.673 -> 
13:44:00.138 -> timer0.timeDiff = 1000
13:44:01.167 -> timer0.timeDiff = 1000
13:44:01.167 -> 
13:44:01.167 -> millis() diff   = 1500
13:44:01.167 -> timer1.timeDiff = 2000
13:44:01.167 -> 
13:44:02.163 -> timer0.timeDiff = 1000
13:44:02.661 -> 
13:44:02.661 -> millis() diff   = 1500
13:44:02.661 -> timer1.timeDiff = 2500
13:44:02.661 -> 
13:44:03.159 -> timer0.timeDiff = 1000
13:44:04.155 -> timer0.timeDiff = 1000
13:44:04.155 -> 
13:44:04.155 -> millis() diff   = 1500
13:44:04.155 -> timer1.timeDiff = 3000
13:44:04.155 -> 
13:44:05.151 -> timer0.timeDiff = 1000
13:44:05.649 -> 
13:44:05.649 -> millis() diff   = 1500
13:44:05.649 -> timer1.timeDiff = 3500
13:44:05.649 -> 

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions