Skip to content
This repository was archived by the owner on Jan 29, 2023. It is now read-only.

Commit 9238f6e

Browse files
authored
v1.6.0 to optimize code, etc.
### Releases v1.6.0 1. Add example [ISR_16_Timers_Array_OneShot](examples/ISR_16_Timers_Array_OneShot) to demo how to use `one-shot ISR-based timer` 2. Add example [multiFileProject](examples/multiFileProject) to demo for multiple-file project 3. Optimize code by using passing by `reference` instead of by `value`
1 parent a47ff40 commit 9238f6e

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/ESP8266TimerInterrupt.h

+11-8
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@
6666
#define TIMER_INTERRUPT_DEBUG 0
6767
#endif
6868

69+
#if defined(ARDUINO)
70+
#if ARDUINO >= 100
71+
#include <Arduino.h>
72+
#else
73+
#include <WProgram.h>
74+
#endif
75+
#endif
76+
6977
#include "TimerInterrupt_Generic_Debug.h"
7078

7179
/* From /arduino-1.8.10/hardware/esp8266com/esp8266/cores/esp8266/esp8266_peri.h
@@ -144,8 +152,7 @@ class ESP8266TimerInterrupt
144152
_callback = NULL;
145153
};
146154

147-
// frequency (in hertz) and duration (in milliseconds). Duration = 0 or not specified => run indefinitely
148-
// No params and duration now. To be addes in the future by adding similar functions here or to esp32-hal-timer.c
155+
// frequency (in hertz)
149156
bool setFrequency(const float& frequency, const timer_callback& callback)
150157
{
151158
bool isOKFlag = true;
@@ -188,8 +195,7 @@ class ESP8266TimerInterrupt
188195
return isOKFlag;
189196
}
190197

191-
// interval (in microseconds) and duration (in milliseconds). Duration = 0 or not specified => run indefinitely
192-
// No params and duration now. To be addes in the future by adding similar functions here or to esp32-hal-timer.c
198+
// interval (in microseconds)
193199
bool setInterval(const unsigned long& interval, const timer_callback& callback)
194200
{
195201
return setFrequency((float) (1000000.0f / interval), callback);
@@ -200,8 +206,7 @@ class ESP8266TimerInterrupt
200206
return setFrequency(frequency, callback);
201207
}
202208

203-
// interval (in microseconds) and duration (in milliseconds). Duration = 0 or not specified => run indefinitely
204-
// No params and duration now. To be addes in the future by adding similar functions here or to esp32-hal-timer.c
209+
// interval (in microseconds)
205210
bool attachInterruptInterval(const unsigned long& interval, const timer_callback& callback)
206211
{
207212
return setFrequency( (float) ( 1000000.0f / interval), callback);
@@ -217,14 +222,12 @@ class ESP8266TimerInterrupt
217222
timer1_disable();
218223
}
219224

220-
// Duration (in milliseconds). Duration = 0 or not specified => run indefinitely
221225
void reattachInterrupt()
222226
{
223227
if ( (_frequency > 0) && (_timerCount > 0) && (_callback != NULL) )
224228
setFrequency(_frequency, _callback);
225229
}
226230

227-
// Duration (in milliseconds). Duration = 0 or not specified => run indefinitely
228231
void enableTimer()
229232
{
230233
reattachInterrupt();

0 commit comments

Comments
 (0)