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

Commit 9a87571

Browse files
authored
v1.3.0 to convert to h-only style, etc.
### Releases v1.3.0 1. Convert to `h-only` style. 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 f09a3b8 commit 9a87571

File tree

9 files changed

+89
-127
lines changed

9 files changed

+89
-127
lines changed

examples/ESP8266_ISR_MultiServos/ESP8266_ISR_MultiServos.ino

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,11 @@
1919
Loosely based on SimpleTimer - A timer library for Arduino.
2020
Author: mromani@ottotecnica.com
2121
Copyright (c) 2010 OTTOTECNICA Italy
22-
23-
Based on BlynkTimer.h
24-
Author: Volodymyr Shymanskyy
2522
2623
The ESP8266 timers are badly designed, using only 23-bit counter along with maximum 256 prescaler. They're only better than UNO / Mega.
2724
The ESP8266 has two hardware timers, but timer0 has been used for WiFi and it's not advisable to use. Only timer1 is available.
2825
The timer1's 23-bit counter terribly can count only up to 8,388,607. So the timer1 maximum interval is very short.
2926
Using 256 prescaler, maximum timer1 interval is only 26.843542 seconds !!!
30-
31-
Version: 1.2.0
32-
33-
Version Modified By Date Comments
34-
------- ----------- ---------- -----------
35-
1.0.0 K Hoang 04/12/2019 Initial coding
36-
1.0.1 K Hoang 05/12/2019 Add more features getPosition and getPulseWidth. Optimize.
37-
1.0.2 K Hoang 20/12/2019 Add more Blynk examples.Change example names to avoid duplication.
38-
1.1.0 K Hoang 03/01/2021 Fix bug. Add TOC and Version String.
39-
1.2.0 K Hoang 18/05/2021 Update to match new ESP8266 core v3.0.0
4027
*****************************************************************************************************************************/
4128

4229
/****************************************************************************************************************************
@@ -81,12 +68,13 @@
8168
*****************************************************************************************************************************/
8269

8370
#ifndef ESP8266
84-
#error This code is designed to run on ESP8266 platform, not Arduino nor ESP32! Please check your Tools->Board setting.
71+
#error This code is designed to run on ESP8266 platform! Please check your Tools->Board setting.
8572
#endif
8673

8774
#define TIMER_INTERRUPT_DEBUG 1
8875
#define ISR_SERVO_DEBUG 1
8976

77+
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
9078
#include "ESP8266_ISR_Servo.h"
9179

9280
// Published values for SG90 servos; adjust if needed

examples/ESP8266_MultipleRandomServos/ESP8266_MultipleRandomServos.ino

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,6 @@
1515
The accuracy is nearly perfect compared to software timers. The most important feature is they're ISR-based timers
1616
Therefore, their executions are not blocked by bad-behaving functions / tasks.
1717
This important feature is absolutely necessary for mission-critical tasks.
18-
19-
Loosely based on SimpleTimer - A timer library for Arduino.
20-
Author: mromani@ottotecnica.com
21-
Copyright (c) 2010 OTTOTECNICA Italy
22-
23-
Based on BlynkTimer.h
24-
Author: Volodymyr Shymanskyy
25-
26-
The ESP8266 timers are badly designed, using only 23-bit counter along with maximum 256 prescaler. They're only better than UNO / Mega.
27-
The ESP8266 has two hardware timers, but timer0 has been used for WiFi and it's not advisable to use. Only timer1 is available.
28-
The timer1's 23-bit counter terribly can count only up to 8,388,607. So the timer1 maximum interval is very short.
29-
Using 256 prescaler, maximum timer1 interval is only 26.843542 seconds !!!
30-
31-
Version: 1.2.0
32-
33-
Version Modified By Date Comments
34-
------- ----------- ---------- -----------
35-
1.0.0 K Hoang 04/12/2019 Initial coding
36-
1.0.1 K Hoang 05/12/2019 Add more features getPosition and getPulseWidth. Optimize.
37-
1.0.2 K Hoang 20/12/2019 Add more Blynk examples.Change example names to avoid duplication.
38-
1.1.0 K Hoang 03/01/2021 Fix bug. Add TOC and Version String.
39-
1.2.0 K Hoang 18/05/2021 Update to match new ESP8266 core v3.0.0
4018
*****************************************************************************************************************************/
4119

4220
/****************************************************************************************************************************
@@ -80,9 +58,14 @@
8058
Experimentally, 550 and 2350 are pretty close to 0 and 180.
8159
*****************************************************************************************************************************/
8260

61+
#ifndef ESP8266
62+
#error This code is designed to run on ESP8266 platform! Please check your Tools->Board setting.
63+
#endif
64+
8365
#define TIMER_INTERRUPT_DEBUG 1
8466
#define ISR_SERVO_DEBUG 0
8567

68+
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
8669
#include "ESP8266_ISR_Servo.h"
8770

8871
// Published values for SG90 servos; adjust if needed

examples/ESP8266_MultipleServos/ESP8266_MultipleServos.ino

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,6 @@
1515
The accuracy is nearly perfect compared to software timers. The most important feature is they're ISR-based timers
1616
Therefore, their executions are not blocked by bad-behaving functions / tasks.
1717
This important feature is absolutely necessary for mission-critical tasks.
18-
19-
Loosely based on SimpleTimer - A timer library for Arduino.
20-
Author: mromani@ottotecnica.com
21-
Copyright (c) 2010 OTTOTECNICA Italy
22-
23-
Based on BlynkTimer.h
24-
Author: Volodymyr Shymanskyy
25-
26-
The ESP8266 timers are badly designed, using only 23-bit counter along with maximum 256 prescaler. They're only better than UNO / Mega.
27-
The ESP8266 has two hardware timers, but timer0 has been used for WiFi and it's not advisable to use. Only timer1 is available.
28-
The timer1's 23-bit counter terribly can count only up to 8,388,607. So the timer1 maximum interval is very short.
29-
Using 256 prescaler, maximum timer1 interval is only 26.843542 seconds !!!
30-
31-
Version: 1.2.0
32-
33-
Version Modified By Date Comments
34-
------- ----------- ---------- -----------
35-
1.0.0 K Hoang 04/12/2019 Initial coding
36-
1.0.1 K Hoang 05/12/2019 Add more features getPosition and getPulseWidth. Optimize.
37-
1.0.2 K Hoang 20/12/2019 Add more Blynk examples.Change example names to avoid duplication.
38-
1.1.0 K Hoang 03/01/2021 Fix bug. Add TOC and Version String.
39-
1.2.0 K Hoang 18/05/2021 Update to match new ESP8266 core v3.0.0
4018
*****************************************************************************************************************************/
4119

4220
/****************************************************************************************************************************
@@ -81,12 +59,13 @@
8159
*****************************************************************************************************************************/
8260

8361
#ifndef ESP8266
84-
#error This code is designed to run on ESP8266 platform, not Arduino nor ESP32! Please check your Tools->Board setting.
62+
#error This code is designed to run on ESP8266 platform! Please check your Tools->Board setting.
8563
#endif
8664

8765
#define TIMER_INTERRUPT_DEBUG 1
8866
#define ISR_SERVO_DEBUG 1
8967

68+
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
9069
#include "ESP8266_ISR_Servo.h"
9170

9271
// Published values for SG90 servos; adjust if needed

examples/ISR_MultiServos/ISR_MultiServos.ino

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,6 @@
1414
The accuracy is nearly perfect compared to software timers. The most important feature is they're ISR-based timers
1515
Therefore, their executions are not blocked by bad-behaving functions / tasks.
1616
This important feature is absolutely necessary for mission-critical tasks.
17-
18-
Loosely based on SimpleTimer - A timer library for Arduino.
19-
Author: mromani@ottotecnica.com
20-
Copyright (c) 2010 OTTOTECNICA Italy
21-
22-
Based on BlynkTimer.h
23-
Author: Volodymyr Shymanskyy
24-
25-
The ESP8266 timers are badly designed, using only 23-bit counter along with maximum 256 prescaler. They're only better than UNO / Mega.
26-
The ESP8266 has two hardware timers, but timer0 has been used for WiFi and it's not advisable to use. Only timer1 is available.
27-
The timer1's 23-bit counter terribly can count only up to 8,388,607. So the timer1 maximum interval is very short.
28-
Using 256 prescaler, maximum timer1 interval is only 26.843542 seconds !!!
29-
30-
Version: 1.2.0
31-
32-
Version Modified By Date Comments
33-
------- ----------- ---------- -----------
34-
1.0.0 K Hoang 04/12/2019 Initial coding
35-
1.0.1 K Hoang 05/12/2019 Add more features getPosition and getPulseWidth. Optimize.
36-
1.0.2 K Hoang 20/12/2019 Add more Blynk examples.Change example names to avoid duplication.
37-
1.1.0 K Hoang 03/01/2021 Fix bug. Add TOC and Version String.
38-
1.2.0 K Hoang 18/05/2021 Update to match new ESP8266 core v3.0.0
3917
*****************************************************************************************************************************/
4018

4119
/****************************************************************************************************************************
@@ -80,12 +58,13 @@
8058
*****************************************************************************************************************************/
8159

8260
#ifndef ESP8266
83-
#error This code is designed to run on ESP8266 platform, not Arduino nor ESP32! Please check your Tools->Board setting.
61+
#error This code is designed to run on ESP8266 platform! Please check your Tools->Board setting.
8462
#endif
8563

8664
#define TIMER_INTERRUPT_DEBUG 1
8765
#define ISR_SERVO_DEBUG 1
8866

67+
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
8968
#include "ESP8266_ISR_Servo.h"
9069

9170
// Published values for SG90 servos; adjust if needed

examples/MultipleRandomServos/MultipleRandomServos.ino

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,6 @@
1515
The accuracy is nearly perfect compared to software timers. The most important feature is they're ISR-based timers
1616
Therefore, their executions are not blocked by bad-behaving functions / tasks.
1717
This important feature is absolutely necessary for mission-critical tasks.
18-
19-
Loosely based on SimpleTimer - A timer library for Arduino.
20-
Author: mromani@ottotecnica.com
21-
Copyright (c) 2010 OTTOTECNICA Italy
22-
23-
Based on BlynkTimer.h
24-
Author: Volodymyr Shymanskyy
25-
26-
The ESP8266 timers are badly designed, using only 23-bit counter along with maximum 256 prescaler. They're only better than UNO / Mega.
27-
The ESP8266 has two hardware timers, but timer0 has been used for WiFi and it's not advisable to use. Only timer1 is available.
28-
The timer1's 23-bit counter terribly can count only up to 8,388,607. So the timer1 maximum interval is very short.
29-
Using 256 prescaler, maximum timer1 interval is only 26.843542 seconds !!!
30-
31-
Version: 1.2.0
32-
33-
Version Modified By Date Comments
34-
------- ----------- ---------- -----------
35-
1.0.0 K Hoang 04/12/2019 Initial coding
36-
1.0.1 K Hoang 05/12/2019 Add more features getPosition and getPulseWidth. Optimize.
37-
1.0.2 K Hoang 20/12/2019 Add more Blynk examples.Change example names to avoid duplication.
38-
1.1.0 K Hoang 03/01/2021 Fix bug. Add TOC and Version String.
39-
1.2.0 K Hoang 18/05/2021 Update to match new ESP8266 core v3.0.0
4018
*****************************************************************************************************************************/
4119

4220
/****************************************************************************************************************************
@@ -81,12 +59,13 @@
8159
*****************************************************************************************************************************/
8260

8361
#ifndef ESP8266
84-
#error This code is designed to run on ESP8266 platform, not Arduino nor ESP32! Please check your Tools->Board setting.
62+
#error This code is designed to run on ESP8266 platform! Please check your Tools->Board setting.
8563
#endif
8664

8765
#define TIMER_INTERRUPT_DEBUG 1
8866
#define ISR_SERVO_DEBUG 0
8967

68+
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
9069
#include "ESP8266_ISR_Servo.h"
9170

9271
// Published values for SG90 servos; adjust if needed

examples/MultipleServos/MultipleServos.ino

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,6 @@
1515
The accuracy is nearly perfect compared to software timers. The most important feature is they're ISR-based timers
1616
Therefore, their executions are not blocked by bad-behaving functions / tasks.
1717
This important feature is absolutely necessary for mission-critical tasks.
18-
19-
Loosely based on SimpleTimer - A timer library for Arduino.
20-
Author: mromani@ottotecnica.com
21-
Copyright (c) 2010 OTTOTECNICA Italy
22-
23-
Based on BlynkTimer.h
24-
Author: Volodymyr Shymanskyy
25-
26-
The ESP8266 timers are badly designed, using only 23-bit counter along with maximum 256 prescaler. They're only better than UNO / Mega.
27-
The ESP8266 has two hardware timers, but timer0 has been used for WiFi and it's not advisable to use. Only timer1 is available.
28-
The timer1's 23-bit counter terribly can count only up to 8,388,607. So the timer1 maximum interval is very short.
29-
Using 256 prescaler, maximum timer1 interval is only 26.843542 seconds !!!
30-
31-
Version: 1.2.0
32-
33-
Version Modified By Date Comments
34-
------- ----------- ---------- -----------
35-
1.0.0 K Hoang 04/12/2019 Initial coding
36-
1.0.1 K Hoang 05/12/2019 Add more features getPosition and getPulseWidth. Optimize.
37-
1.0.2 K Hoang 20/12/2019 Add more Blynk examples.Change example names to avoid duplication.
38-
1.1.0 K Hoang 03/01/2021 Fix bug. Add TOC and Version String.
39-
1.2.0 K Hoang 18/05/2021 Update to match new ESP8266 core v3.0.0
4018
*****************************************************************************************************************************/
4119

4220
/****************************************************************************************************************************
@@ -80,9 +58,14 @@
8058
Experimentally, 550 and 2350 are pretty close to 0 and 180.
8159
*****************************************************************************************************************************/
8260

61+
#ifndef ESP8266
62+
#error This code is designed to run on ESP8266 platform! Please check your Tools->Board setting.
63+
#endif
64+
8365
#define TIMER_INTERRUPT_DEBUG 1
8466
#define ISR_SERVO_DEBUG 1
8567

68+
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
8669
#include "ESP8266_ISR_Servo.h"
8770

8871
// Published values for SG90 servos; adjust if needed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/****************************************************************************************************************************
2+
multiFileProject.cpp
3+
For ESP8266 boards
4+
Written by Khoi Hoang
5+
6+
Built by Khoi Hoang https://github.com/khoih-prog/ESP8266_ISR_Servo
7+
Licensed under MIT license
8+
*****************************************************************************************************************************/
9+
10+
// To demo how to include files in multi-file Projects
11+
12+
#include "multiFileProject.h"
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/****************************************************************************************************************************
2+
multiFileProject.h
3+
For ESP8266 boards
4+
Written by Khoi Hoang
5+
6+
Built by Khoi Hoang https://github.com/khoih-prog/ESP8266_ISR_Servo
7+
Licensed under MIT license
8+
*****************************************************************************************************************************/
9+
10+
// To demo how to include files in multi-file Projects
11+
12+
#pragma once
13+
14+
// Can be included as many times as necessary, without `Multiple Definitions` Linker Error
15+
#include "ESP8266_ISR_Servo.hpp"
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/****************************************************************************************************************************
2+
multiFileProject.ino
3+
For ESP8266 boards
4+
Written by Khoi Hoang
5+
6+
Built by Khoi Hoang https://github.com/khoih-prog/ESP8266_ISR_Servo
7+
Licensed under MIT license
8+
*****************************************************************************************************************************/
9+
10+
// To demo how to include files in multi-file Projects
11+
12+
#ifndef ESP8266
13+
#error This code is designed to run on ESP8266 platform! Please check your Tools->Board setting.
14+
#endif
15+
16+
#define ESP8266_ISR_SERVO_VERSION_MIN_TARGET "ESP8266_ISR_Servo v1.3.0"
17+
#define ESP8266_ISR_SERVO_VERSION_MIN 1003000
18+
19+
#include "multiFileProject.h"
20+
21+
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
22+
#include "ESP8266_ISR_Servo.h"
23+
24+
void setup()
25+
{
26+
Serial.begin(115200);
27+
while (!Serial);
28+
29+
Serial.println("\nStart multiFileProject");
30+
Serial.println(ESP8266_ISR_SERVO_VERSION);
31+
32+
#if defined(ESP8266_ISR_SERVO_VERSION_MIN)
33+
if (ESP8266_ISR_SERVO_VERSION_INT < ESP8266_ISR_SERVO_VERSION_MIN)
34+
{
35+
Serial.print("Warning. Must use this example on Version equal or later than : ");
36+
Serial.println(ESP8266_ISR_SERVO_VERSION_MIN_TARGET);
37+
}
38+
#endif
39+
}
40+
41+
void loop()
42+
{
43+
// put your main code here, to run repeatedly:
44+
}

0 commit comments

Comments
 (0)