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

Commit de41551

Browse files
authored
v1.5.0 to add more features and fix bug
### Releases v1.5.0 1. Fix `multiple-definitions` linker error. Drop `src_cpp` and `src_h` directories 2. Add feature to select among highest, medium or lowest accuracy for Timers for shortest, medium or longest time 3. Fix reattachInterrupt() bug. Check [bugfix: reattachInterrupt() pass wrong frequency value to setFrequency() #19](#19)
1 parent 52ae95a commit de41551

19 files changed

+365
-190
lines changed

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ If you don't find anything, please [open a new issue](https://github.com/khoih-p
1414

1515
Please ensure to specify the following:
1616

17-
* Arduino IDE version (e.g. 1.8.16) or Platform.io version
17+
* Arduino IDE version (e.g. 1.8.19) or Platform.io version
1818
* `ESP8266` Core Version (e.g. ESP8266 core v3.0.2)
1919
* Contextual information (e.g. what you were trying to achieve)
2020
* Simplest possible steps to reproduce
@@ -26,11 +26,11 @@ Please ensure to specify the following:
2626
### Example
2727

2828
```
29-
Arduino IDE version: v1.8.16
29+
Arduino IDE version: v1.8.19
3030
ESP8266 Core Version v3.0.2
3131
ESP8266_NODEMCU
3232
OS: Ubuntu 20.04 LTS
33-
Linux xy-Inspiron-3593 5.4.0-90-generic #101-Ubuntu SMP Fri Oct 15 20:00:55 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
33+
Linux xy-Inspiron-3593 5.4.0-94-generic #106-Ubuntu SMP Thu Jan 6 23:58:14 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
3434
3535
Context:
3636
I encountered a crash while trying to use the Timer Interrupt.

README.md

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -161,24 +161,21 @@ Another way to install is to:
161161

162162
### HOWTO Fix `Multiple Definitions` Linker Error
163163

164-
The current library implementation, using **xyz-Impl.h instead of standard xyz.cpp**, possibly creates certain `Multiple Definitions` Linker error in certain use cases. Although it's simple to just modify several lines of code, either in the library or in the application, the library is adding 2 more source directories
164+
The current library implementation, using `xyz-Impl.h` instead of standard `xyz.cpp`, possibly creates certain `Multiple Definitions` Linker error in certain use cases.
165165

166-
1. **scr_h** for new h-only files
167-
2. **src_cpp** for standard h/cpp files
166+
You can use
168167

169-
besides the standard **src** directory.
170-
171-
To use the **old standard cpp** way, locate this library' directory, then just
168+
```
169+
#include <ESP8266_ISR_Timer.hpp> //https://github.com/khoih-prog/ESP8266TimerInterrupt
170+
```
172171

173-
1. **Delete the all the files in src directory.**
174-
2. **Copy all the files in src_cpp directory into src.**
175-
3. Close then reopen the application code in Arduino IDE, etc. to recompile from scratch.
172+
in many files. But be sure to use the following `#include <ESP8266_ISR_Timer.h>` **in just 1 `.h`, `.cpp` or `.ino` file**, which must **not be included in any other file**, to avoid `Multiple Definitions` Linker Error
176173

177-
To re-use the **new h-only** way, just
174+
```
175+
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
176+
#include <ESP8266_ISR_Timer.h> //https://github.com/khoih-prog/ESP8266TimerInterrupt
177+
```
178178

179-
1. **Delete the all the files in src directory.**
180-
2. **Copy the files in src_h directory into src.**
181-
3. Close then reopen the application code in Arduino IDE, etc. to recompile from scratch.
182179

183180
---
184181
---
@@ -245,6 +242,11 @@ Using 256 prescaler, maximum Timer1 interval is only 26.843542 seconds !!!
245242
### 1.1 Init Hardware Timer
246243

247244
```
245+
// Select a Timer Clock
246+
#define USING_TIM_DIV1 false // for shortest and most accurate timer
247+
#define USING_TIM_DIV16 false // for medium time and medium accurate timer
248+
#define USING_TIM_DIV256 true // for longest timer but least accurate. Default
249+
248250
// Init ESP8266 only and only Timer 1
249251
ESP8266Timer ITimer;
250252
```
@@ -332,6 +334,11 @@ The 16 ISR_based Timers, designed for long timer intervals, only support using *
332334
### 2.2 Init Hardware Timer and ISR-based Timer
333335

334336
```
337+
// Select a Timer Clock
338+
#define USING_TIM_DIV1 false // for shortest and most accurate timer
339+
#define USING_TIM_DIV16 false // for medium time and medium accurate timer
340+
#define USING_TIM_DIV256 true // for longest timer but least accurate. Default
341+
335342
#include "ESP8266TimerInterrupt.h"
336343
#include "ESP8266_ISR_Timer.h"
337344
@@ -433,13 +440,17 @@ void setup()
433440
#define TIMER_INTERRUPT_DEBUG 0
434441
#define _TIMERINTERRUPT_LOGLEVEL_ 0
435442

443+
// Select a Timer Clock
444+
#define USING_TIM_DIV1 false // for shortest and most accurate timer
445+
#define USING_TIM_DIV16 false // for medium time and medium accurate timer
446+
#define USING_TIM_DIV256 true // for longest timer but least accurate. Default
447+
436448
#include "ESP8266TimerInterrupt.h"
437449

438450
#ifndef LED_BUILTIN
439451
#define LED_BUILTIN D4 // Pin D4 mapped to pin GPIO2/TXD1 of ESP8266, NodeMCU and WeMoS, control on-board LED
440452
#endif
441453

442-
443454
#define TIMER_INTERVAL_MS 500 //1000
444455

445456
volatile uint32_t TimerCount = 0;
@@ -530,7 +541,7 @@ The following is the sample terminal output when running example [TimerInterrupt
530541
531542
```
532543
Starting TimerInterruptTest on ESP8266_NODEMCU_ESP12E
533-
ESP8266TimerInterrupt v1.4.1
544+
ESP8266TimerInterrupt v1.5.0
534545
CPU Frequency = 160 MHz
535546
ESP8266TimerInterrupt: _fre = 312500.00, _count = 312500
536547
Starting ITimer OK, millis() = 262
@@ -562,7 +573,7 @@ The following is the sample terminal output when running example [Change_Interva
562573
563574
```
564575
Starting Change_Interval on ESP8266_NODEMCU_ESP12E
565-
ESP8266TimerInterrupt v1.4.1
576+
ESP8266TimerInterrupt v1.5.0
566577
CPU Frequency = 160 MHz
567578
Starting ITimer OK, millis() = 162
568579
Time = 10001, TimerCount = 19
@@ -601,7 +612,7 @@ The following is the sample terminal output when running example [ISR_16_Timers_
601612
602613
```
603614
Starting ISR_16_Timers_Array on ESP8266_NODEMCU_ESP12E
604-
ESP8266TimerInterrupt v1.4.1
615+
ESP8266TimerInterrupt v1.5.0
605616
CPU Frequency = 160 MHz
606617
Starting ITimer OK, millis() = 175
607618
1s: Delta ms = 1003, ms = 1178
@@ -674,7 +685,7 @@ The following is the sample terminal output when running example [ISR_16_Timers_
674685
675686
```
676687
Starting ISR_16_Timers_Array_Complex on ESP8266_NODEMCU_ESP12E
677-
ESP8266TimerInterrupt v1.4.1
688+
ESP8266TimerInterrupt v1.5.0
678689
CPU Frequency = 160 MHz
679690
Starting ITimer OK, millis() = 177
680691
SimpleTimer : 2, ms : 10179, Dms : 10000
@@ -868,18 +879,23 @@ Submit issues to: [ESP8266TimerInterrupt issues](https://github.com/khoih-prog/E
868879
6. Fix compiler errors due to conflict to some libraries.
869880
7. Add complex examples.
870881
5. Update to match new ESP8266 core v3.0.2
882+
6. Fix `multiple-definitions` linker error. Drop `src_cpp` and `src_h` directories
883+
7. Add feature to select among highest, medium or lowest accuracy for Timers for shortest, medium or longest time
884+
871885

872886
---
873887
---
874888

875889
## Contributions and thanks
876890

877891
1. Thanks to [Holger Lembke](https://github.com/holgerlembke) to report [ESP8266TimerInterrupt Issue 8: **ESP8266Timer and PWM --> wdt reset**](https://github.com/khoih-prog/ESP8266TimerInterrupt/issues/8), leading to the [HOWTO Use PWM analogWrite() with ESP8266 running Timer1 Interrupt](https://github.com/khoih-prog/ESP8266TimerInterrupt#howto-use-pwm-analogwrite-with-esp8266-running-timer1-interrupt) notes.
892+
2. Thanks to [Eugene](https://github.com/RushOnline) to make bug-fixing PR and discussion in [bugfix: reattachInterrupt() pass wrong frequency value to setFrequency() #19](https://github.com/khoih-prog/ESP8266TimerInterrupt/pull/19), leading to v1.5.0
878893

879894

880895
<table>
881896
<tr>
882897
<td align="center"><a href="https://github.com/holgerlembke"><img src="https://github.com/holgerlembke.png" width="100px;" alt="holgerlembke"/><br /><sub><b>Holger Lembke</b></sub></a><br /></td>
898+
<td align="center"><a href="https://github.com/RushOnline"><img src="https://github.com/RushOnline.png" width="100px;" alt="RushOnline"/><br /><sub><b>Eugene</b></sub></a><br /></td>
883899
</tr>
884900
</table>
885901

changelog.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
---
1111

1212
* [Changelog](#changelog)
13+
* [Releases v1.5.0](#releases-v150)
1314
* [Releases v1.4.1](#releases-v141)
1415
* [Releases v1.4.0](#releases-v140)
1516
* [Releases v1.3.0](#releases-v130)
@@ -24,6 +25,12 @@
2425

2526
## Changelog
2627

28+
### Releases v1.5.0
29+
30+
1. Fix `multiple-definitions` linker error. Drop `src_cpp` and `src_h` directories
31+
2. Add feature to select among highest, medium or lowest accuracy for Timers for shortest, medium or longest time
32+
3. Fix reattachInterrupt() bug. Check [bugfix: reattachInterrupt() pass wrong frequency value to setFrequency() #19](https://github.com/khoih-prog/ESP8266TimerInterrupt/pull/19)
33+
2734
### Releases v1.4.1
2835

2936
1. Examples modified and tested with core v3.0.2

examples/Argument_None/Argument_None.ino

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@
3838
#define TIMER_INTERRUPT_DEBUG 0
3939
#define _TIMERINTERRUPT_LOGLEVEL_ 0
4040

41+
// Select a Timer Clock
42+
#define USING_TIM_DIV1 false // for shortest and most accurate timer
43+
#define USING_TIM_DIV16 false // for medium time and medium accurate timer
44+
#define USING_TIM_DIV256 true // for longest timer but least accurate. Default
45+
4146
#include "ESP8266TimerInterrupt.h"
4247

4348
#ifndef LED_BUILTIN

examples/Change_Interval/Change_Interval.ino

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@
3939
#define TIMER_INTERRUPT_DEBUG 0
4040
#define _TIMERINTERRUPT_LOGLEVEL_ 0
4141

42+
// Select a Timer Clock
43+
#define USING_TIM_DIV1 false // for shortest and most accurate timer
44+
#define USING_TIM_DIV16 false // for medium time and medium accurate timer
45+
#define USING_TIM_DIV256 true // for longest timer but least accurate. Default
46+
4247
#include "ESP8266TimerInterrupt.h"
4348

4449
#ifndef LED_BUILTIN

examples/ISR_16_Timers_Array/ISR_16_Timers_Array.ino

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@
5656
#define TIMER_INTERRUPT_DEBUG 2
5757
#define _TIMERINTERRUPT_LOGLEVEL_ 0
5858

59+
// Select a Timer Clock
60+
#define USING_TIM_DIV1 false // for shortest and most accurate timer
61+
#define USING_TIM_DIV16 false // for medium time and medium accurate timer
62+
#define USING_TIM_DIV256 true // for longest timer but least accurate. Default
63+
5964
#include "ESP8266TimerInterrupt.h"
6065
#include "ESP8266_ISR_Timer.h"
6166

examples/ISR_16_Timers_Array_Complex/ISR_16_Timers_Array_Complex.ino

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,12 @@
4545
// Don't define _TIMERINTERRUPT_LOGLEVEL_ > 0. Only for special ISR debugging only. Can hang the system.
4646
// Don't define TIMER_INTERRUPT_DEBUG > 2. Only for special ISR debugging only. Can hang the system.
4747
#define TIMER_INTERRUPT_DEBUG 0
48-
#define _TIMERINTERRUPT_LOGLEVEL_ 0
48+
#define _TIMERINTERRUPT_LOGLEVEL_ 4
49+
50+
// Select a Timer Clock
51+
#define USING_TIM_DIV1 false // for shortest and most accurate timer
52+
#define USING_TIM_DIV16 false // for medium time and medium accurate timer
53+
#define USING_TIM_DIV256 true // for longest timer but least accurate. Default
4954

5055
#include "ESP8266TimerInterrupt.h"
5156
#include "ESP8266_ISR_Timer.h"

examples/ISR_RPM_Measure/ISR_RPM_Measure.ino

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@
4848
#define TIMER_INTERRUPT_DEBUG 2
4949
#define _TIMERINTERRUPT_LOGLEVEL_ 0
5050

51+
// Select a Timer Clock
52+
#define USING_TIM_DIV1 false // for shortest and most accurate timer
53+
#define USING_TIM_DIV16 false // for medium time and medium accurate timer
54+
#define USING_TIM_DIV256 true // for longest timer but least accurate. Default
55+
5156
#include "ESP8266TimerInterrupt.h"
5257

5358
#define PIN_D1 5 // Pin D1 mapped to pin GPIO5 of ESP8266

examples/RPM_Measure/RPM_Measure.ino

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@
4747
#define TIMER_INTERRUPT_DEBUG 2
4848
#define _TIMERINTERRUPT_LOGLEVEL_ 0
4949

50+
// Select a Timer Clock
51+
#define USING_TIM_DIV1 false // for shortest and most accurate timer
52+
#define USING_TIM_DIV16 false // for medium time and medium accurate timer
53+
#define USING_TIM_DIV256 true // for longest timer but least accurate. Default
54+
5055
#include "ESP8266TimerInterrupt.h"
5156

5257
#define PIN_D1 5 // Pin D1 mapped to pin GPIO5 of ESP8266

examples/SwitchDebounce/SwitchDebounce.ino

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@
4343
#define TIMER_INTERRUPT_DEBUG 1
4444
#define _TIMERINTERRUPT_LOGLEVEL_ 0
4545

46+
// Select a Timer Clock
47+
#define USING_TIM_DIV1 false // for shortest and most accurate timer
48+
#define USING_TIM_DIV16 false // for medium time and medium accurate timer
49+
#define USING_TIM_DIV256 true // for longest timer but least accurate. Default
50+
4651
#include "ESP8266TimerInterrupt.h"
4752

4853
#define PIN_D1 5 // Pin D1 mapped to pin GPIO5 of ESP8266

0 commit comments

Comments
 (0)