Naguissa / uTimerLib

Arduino tiny and cross-device compatible timer library
https://www.foroelectro.net/electronica-digital-microcontroladores-f8/utimerlib-libreria-arduino-para-eventos-temporizad-t191.html
GNU Lesser General Public License v3.0
20 stars 9 forks source link

clearTimer() does not work in 1.6.5 ( it does in 1.6.4 ) #14

Closed mm108 closed 3 years ago

mm108 commented 3 years ago

hi,

TimerLib.clearTimer();

no longer works in 1.6.5. I have tried it with the below 2 sample programs. The test devices are ESP32.

clearTimer() works on version 1.6.4.

I have tried with both setInterval and setTimeout.

Example 1 (setInterval)

#include "Arduino.h"
#include "uTimerLib.h"

volatile unsigned long int prevMillis = 0;
volatile unsigned long int actMillis = 0;

void timed_function() {
  Serial.println(actMillis - prevMillis);
  prevMillis = actMillis;
  TimerLib.clearTimer();
}

void setup() {
  Serial.begin(115200);
  Serial.println("Timer started!");
  TimerLib.setInterval_s(timed_function, 2);
  prevMillis = millis();
}

void loop() {
  actMillis = millis();
}

Example 2 (setTimeout)

#include "Arduino.h"
#include "uTimerLib.h"

volatile unsigned long int prevMillis = 0;
volatile unsigned long int actMillis = 0;

void timed_function() {
  Serial.println(actMillis - prevMillis);
  TimerLib.clearTimer();
}

void setup() {
  Serial.begin(115200);
  Serial.println("Timer started!");
  TimerLib.setTimeout_s(timed_function, 2);
  prevMillis = millis();
}

void loop() {
  actMillis = millis();
}
Naguissa commented 3 years ago

Fixed! Created 1.6.6 release.

mm108 commented 3 years ago

Wow, fantastic! Thank you.

Naguissa commented 3 years ago

I just was on the computer and that notification arrived; it was quite easy... ;-)

mm108 commented 3 years ago

I just was on the computer and that notification arrived; it was quite easy... ;-)

Right place at the right time! ... :-D Cool, thanks once again.