bugfix: reattachInterrupt() pass wrong frequency value to setFrequency() by RushOnline · Pull Request #19 · khoih-prog/ESP8266TimerInterrupt (original) (raw)

I should have stored frequency as a class member, but this fix saves some memory without the need to do so.

I've do it this way to minify changes only. To save a memory we can do following changes:

diff --git a/src/ESP8266TimerInterrupt.h b/src/ESP8266TimerInterrupt.h index 06f941f..d2409d2 100644 --- a/src/ESP8266TimerInterrupt.h +++ b/src/ESP8266TimerInterrupt.h @@ -102,14 +102,12 @@ class ESP8266TimerInterrupt private: timer_callback _callback; // pointer to the callback function float _frequency; // Timer frequency

public:

 ESP8266TimerInterrupt()
 {
   _frequency  = 0;

@@ -121,10 +119,10 @@ class ESP8266TimerInterrupt

   // ESP8266 only has one usable timer1, max count is only 8,388,607. So to get longer time, we use max available 256 divider
   // Will use later if very low frequency is needed.

@@ -179,8 +177,8 @@ class ESP8266TimerInterrupt // Duration (in milliseconds). Duration = 0 or not specified => run indefinitely void reattachInterrupt() {