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

Commit 114dc0c

Browse files
authored
Update README.md and use allman astyle
1 parent 2fbea67 commit 114dc0c

19 files changed

+245
-110
lines changed

CONTRIBUTING.md

+23-2
Original file line numberDiff line numberDiff line change
@@ -29,24 +29,45 @@ Please ensure to specify the following:
2929
Arduino IDE version: 1.8.19
3030
ESP8266 Core Version v3.0.2
3131
OS: Ubuntu 20.04 LTS
32-
Linux xy-Inspiron-3593 5.4.0-100-generic #113-Ubuntu SMP Thu Feb 3 18:43:29 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
32+
Linux xy-Inspiron-3593 5.15.0-53-generic #59~20.04.1-Ubuntu SMP Thu Oct 20 15:10:22 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
3333
3434
Context:
35-
I encountered a crash while trying to use the Timer Interrupt.
35+
I encountered a crash while using this library
3636
3737
Steps to reproduce:
3838
1. ...
3939
2. ...
4040
3. ...
4141
4. ...
4242
```
43+
44+
---
45+
4346
### Sending Feature Requests
4447

4548
Feel free to post feature requests. It's helpful if you can explain exactly why the feature would be useful.
4649

4750
There are usually some outstanding feature requests in the [existing issues list](https://github.com/khoih-prog/ESP8266_ISR_Servo/issues?q=is%3Aopen+is%3Aissue+label%3Aenhancement), feel free to add comments to them.
4851

52+
---
53+
4954
### Sending Pull Requests
5055

5156
Pull Requests with changes and fixes are also welcome!
5257

58+
Please use the `astyle` to reformat the updated library code as follows (demo for Ubuntu Linux)
59+
60+
1. Change directory to the library GitHub
61+
62+
```
63+
xy@xy-Inspiron-3593:~$ cd Arduino/xy/ESP8266_ISR_Servo_GitHub/
64+
xy@xy-Inspiron-3593:~/Arduino/xy/ESP8266_ISR_Servo_GitHub$
65+
```
66+
67+
2. Issue astyle command
68+
69+
```
70+
xy@xy-Inspiron-3593:~/Arduino/xy/ESP8266_ISR_Servo_GitHub$ bash utils/restyle.sh
71+
```
72+
73+

README.md

+10-8
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@
66
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](#Contributing)
77
[![GitHub issues](https://img.shields.io/github/issues/khoih-prog/ESP8266_ISR_Servo.svg)](http://github.com/khoih-prog/ESP8266_ISR_Servo/issues)
88

9+
910
<a href="https://www.buymeacoffee.com/khoihprog6" title="Donate to my libraries using BuyMeACoffee"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Donate to my libraries using BuyMeACoffee" style="height: 50px !important;width: 181px !important;" ></a>
1011
<a href="https://www.buymeacoffee.com/khoihprog6" title="Donate to my libraries using BuyMeACoffee"><img src="https://img.shields.io/badge/buy%20me%20a%20coffee-donate-orange.svg?logo=buy-me-a-coffee&logoColor=FFDD00" style="height: 20px !important;width: 200px !important;" ></a>
12+
<a href="https://profile-counter.glitch.me/khoih-prog/count.svg" title="Total khoih-prog Visitor count"><img src="https://profile-counter.glitch.me/khoih-prog/count.svg" style="height: 30px;width: 200px;"></a>
13+
<a href="https://profile-counter.glitch.me/khoih-prog-ESP8266_ISR_Servo/count.svg" title="ESP8266_ISR_Servo Visitor count"><img src="https://profile-counter.glitch.me/khoih-prog-ESP8266_ISR_Servo/count.svg" style="height: 30px;width: 200px;"></a>
14+
1115

1216
---
1317
---
@@ -60,8 +64,6 @@
6064

6165
Please have a look at [HOWTO Fix `Multiple Definitions` Linker Error](#howto-fix-multiple-definitions-linker-error)
6266

63-
64-
6567
---
6668
---
6769

@@ -147,14 +149,14 @@ The current library implementation, using `xyz-Impl.h` instead of standard `xyz.
147149

148150
You can include this `.hpp` file
149151

150-
```
152+
```cpp
151153
// Can be included as many times as necessary, without `Multiple Definitions` Linker Error
152154
#include "ESP8266_ISR_Servo.hpp" //https://github.com/khoih-prog/ESP8266_ISR_Servo
153155
```
154156

155157
in many files. But be sure to use the following `.h` file **in just 1 `.h`, `.cpp` or `.ino` file**, which must **not be included in any other file**, to avoid `Multiple Definitions` Linker Error
156158

157-
```
159+
```cpp
158160
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
159161
#include "ESP8266_ISR_Servo.h" //https://github.com/khoih-prog/ESP8266_ISR_Servo
160162
```
@@ -186,7 +188,7 @@ The timer1 counters can be configured to support automatic reload.
186188

187189
### New functions
188190

189-
```
191+
```cpp
190192
// returns last position in degrees if success, or -1 on wrong servoIndex
191193
int getPosition(unsigned servoIndex);
192194

@@ -249,7 +251,7 @@ https://github.com/khoih-prog/ESP8266_ISR_Servo/blob/9a8757117d2c901bed222990f11
249251
250252
### 1. ESP8266_MultipleRandomServos on ESP8266_NODEMCU_ESP12E
251253
252-
```
254+
```cpp
253255
Starting ESP8266_MultipleRandomServos on ESP8266_NODEMCU_ESP12E
254256
ESP8266_ISR_Servo v1.3.0
255257
[ISR_SERVO] ESP8266FastTimerInterrupt: _fre = 5000000.00 , _count = 50
@@ -353,7 +355,7 @@ Servos idx = 5, act. pos. (deg) = [ISR_SERVO] Idx = 5
353355
### 2. ESP8266_ISR_MultiServos on ESP8266_NODEMCU_ESP12E
354356

355357

356-
```
358+
```cpp
357359
Starting ESP8266_ISR_MultiServos on ESP8266_NODEMCU_ESP12E
358360
ESP8266_ISR_Servo v1.3.0
359361
[ISR_SERVO] ESP8266FastTimerInterrupt: _fre = 5000000.00 , _count = 50
@@ -480,4 +482,4 @@ If you want to contribute to this project:
480482

481483
## Copyright
482484

483-
Copyright 2019- Khoi Hoang
485+
Copyright (c) 2019- Khoi Hoang

changelog.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](#Contributing)
77
[![GitHub issues](https://img.shields.io/github/issues/khoih-prog/ESP8266_ISR_Servo.svg)](http://github.com/khoih-prog/ESP8266_ISR_Servo/issues)
88

9+
10+
<a href="https://www.buymeacoffee.com/khoihprog6" title="Donate to my libraries using BuyMeACoffee"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Donate to my libraries using BuyMeACoffee" style="height: 50px !important;width: 181px !important;" ></a>
11+
<a href="https://www.buymeacoffee.com/khoihprog6" title="Donate to my libraries using BuyMeACoffee"><img src="https://img.shields.io/badge/buy%20me%20a%20coffee-donate-orange.svg?logo=buy-me-a-coffee&logoColor=FFDD00" style="height: 20px !important;width: 200px !important;" ></a>
12+
<a href="https://profile-counter.glitch.me/khoih-prog/count.svg" title="Total khoih-prog Visitor count"><img src="https://profile-counter.glitch.me/khoih-prog/count.svg" style="height: 30px;width: 200px;"></a>
13+
<a href="https://profile-counter.glitch.me/khoih-prog-ESP8266_ISR_Servo/count.svg" title="ESP8266_ISR_Servo Visitor count"><img src="https://profile-counter.glitch.me/khoih-prog-ESP8266_ISR_Servo/count.svg" style="height: 30px;width: 200px;"></a>
14+
915
---
1016
---
1117

@@ -31,7 +37,7 @@
3137

3238
### Releases v1.2.0
3339

34-
1. Update to match new ESP8266 core v3.0.0
40+
1. Update to match new ESP8266 core `v3.0.0`
3541

3642
### Releases v1.1.0
3743

examples/ESP8266_ISR_MultiServos/ESP8266_ISR_MultiServos.ino

+12-8
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
ESP8266_ISR_MultiServos.ino
33
For ESP8266 boards
44
Written by Khoi Hoang
5-
5+
66
Built by Khoi Hoang https://github.com/khoih-prog/ESP8266_ISR_Servo
77
Licensed under MIT license
8-
8+
99
The ESP8266 timers are badly designed, using only 23-bit counter along with maximum 256 prescaler. They're only better than UNO / Mega.
1010
The ESP8266 has two hardware timers, but timer0 has been used for WiFi and it's not advisable to use. Only timer1 is available.
1111
The timer1's 23-bit counter terribly can count only up to 8,388,607. So the timer1 maximum interval is very short.
@@ -19,7 +19,7 @@
1919
Loosely based on SimpleTimer - A timer library for Arduino.
2020
2121
Copyright (c) 2010 OTTOTECNICA Italy
22-
22+
2323
The ESP8266 timers are badly designed, using only 23-bit counter along with maximum 256 prescaler. They're only better than UNO / Mega.
2424
The ESP8266 has two hardware timers, but timer0 has been used for WiFi and it's not advisable to use. Only timer1 is available.
2525
The timer1's 23-bit counter terribly can count only up to 8,388,607. So the timer1 maximum interval is very short.
@@ -87,13 +87,15 @@ int servoIndex2 = -1;
8787
void setup()
8888
{
8989
Serial.begin(115200);
90+
9091
while (!Serial);
9192

9293
delay(200);
9394

94-
Serial.print(F("\nStarting ESP8266_ISR_MultiServos on ")); Serial.println(ARDUINO_BOARD);
95+
Serial.print(F("\nStarting ESP8266_ISR_MultiServos on "));
96+
Serial.println(ARDUINO_BOARD);
9597
Serial.println(ESP8266_ISR_SERVO_VERSION);
96-
98+
9799
servoIndex1 = ISR_Servo.setupServo(D8, MIN_MICROS, MAX_MICROS);
98100
servoIndex2 = ISR_Servo.setupServo(D7, MIN_MICROS, MAX_MICROS);
99101

@@ -121,10 +123,12 @@ void loop()
121123

122124
if (position % 30 == 0)
123125
{
124-
Serial.print(F("Servo1 pos = ")); Serial.print(position);
125-
Serial.print(F(", Servo2 pos = ")); Serial.println(180 - position);
126+
Serial.print(F("Servo1 pos = "));
127+
Serial.print(position);
128+
Serial.print(F(", Servo2 pos = "));
129+
Serial.println(180 - position);
126130
}
127-
131+
128132
ISR_Servo.setPosition(servoIndex1, position);
129133
ISR_Servo.setPosition(servoIndex2, 180 - position);
130134
// waits 15ms for the servo to reach the position

examples/ESP8266_MultipleRandomServos/ESP8266_MultipleRandomServos.ino

+27-23
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
ESP8266_MultipleRandomServos.ino
33
For ESP8266 boards
44
Written by Khoi Hoang
5-
5+
66
Built by Khoi Hoang https://github.com/khoih-prog/ESP8266_ISR_Servo
77
Licensed under MIT license
8-
8+
99
The ESP8266 timers are badly designed, using only 23-bit counter along with maximum 256 prescaler. They're only better than UNO / Mega.
1010
The ESP8266 has two hardware timers, but timer0 has been used for WiFi and it's not advisable to use. Only timer1 is available.
1111
The timer1's 23-bit counter terribly can count only up to 8,388,607. So the timer1 maximum interval is very short.
@@ -88,11 +88,13 @@ ISR_servo_t ISR_servo[NUM_SERVOS] =
8888
void setup()
8989
{
9090
Serial.begin(115200);
91+
9192
while (!Serial);
9293

9394
delay(200);
9495

95-
Serial.print(F("\nStarting ESP8266_MultipleRandomServos on ")); Serial.println(ARDUINO_BOARD);
96+
Serial.print(F("\nStarting ESP8266_MultipleRandomServos on "));
97+
Serial.println(ARDUINO_BOARD);
9698
Serial.println(ESP8266_ISR_SERVO_VERSION);
9799

98100
for (int index = 0; index < NUM_SERVOS; index++)
@@ -101,11 +103,13 @@ void setup()
101103

102104
if (ISR_servo[index].servoIndex != -1)
103105
{
104-
Serial.print(F("Setup OK Servo index = ")); Serial.println(ISR_servo[index].servoIndex);
106+
Serial.print(F("Setup OK Servo index = "));
107+
Serial.println(ISR_servo[index].servoIndex);
105108
}
106109
else
107110
{
108-
Serial.print(F("Setup Failed Servo index = ")); Serial.println(ISR_servo[index].servoIndex);
111+
Serial.print(F("Setup Failed Servo index = "));
112+
Serial.println(ISR_servo[index].servoIndex);
109113
}
110114
}
111115
}
@@ -126,42 +130,42 @@ void loop()
126130

127131
position = 0;
128132
Serial.println(F("Servos @ 0 degree"));
129-
133+
130134
for (int index = 0; index < NUM_SERVOS; index++)
131135
{
132136
ISR_Servo.setPosition(ISR_servo[index].servoIndex, position );
133137
printServoInfo(index);
134138
}
135-
139+
136140
// waits 5s between test
137141
delay(5000);
138142

139143
position = 90;
140144
Serial.println(F("Servos @ 90 degree"));
141-
145+
142146
for (int index = 0; index < NUM_SERVOS; index++)
143147
{
144148
ISR_Servo.setPosition(ISR_servo[index].servoIndex, position );
145149
printServoInfo(index);
146150
}
147-
151+
148152
// waits 5s between test
149153
delay(5000);
150154

151155
position = 180;
152156
Serial.println(F("Servos @ 180 degree"));
153-
157+
154158
for (int index = 0; index < NUM_SERVOS; index++)
155159
{
156160
ISR_Servo.setPosition(ISR_servo[index].servoIndex, position );
157161
printServoInfo(index);
158162
}
159-
163+
160164
// waits 5s between test
161165
delay(5000);
162166

163167
Serial.println(F("Servos sweeps from 0-180 degress"));
164-
168+
165169
for (position = 0; position <= 180; position += 1)
166170
{
167171
// goes from 0 degrees to 180 degrees
@@ -170,16 +174,16 @@ void loop()
170174
{
171175
ISR_Servo.setPosition(ISR_servo[index].servoIndex, position );
172176
}
173-
177+
174178
// waits 50ms for the servo to reach the position
175179
delay(50);
176180
}
177-
181+
178182
// waits 5s between test
179183
delay(5000);
180184

181185
Serial.println(F("Servos sweeps from 180-0 degress"));
182-
186+
183187
for (position = 180; position >= 0; position -= 1)
184188
{
185189
// goes from 0 degrees to 180 degrees
@@ -188,16 +192,16 @@ void loop()
188192
{
189193
ISR_Servo.setPosition(ISR_servo[index].servoIndex, position );
190194
}
191-
195+
192196
// waits 50ms for the servo to reach the position
193197
delay(50);
194198
}
195-
199+
196200
// waits 5s between test
197201
delay(5000);
198202

199203
Serial.println(F("Servos, index depending, be somewhere from 0-180 degress"));
200-
204+
201205
for (position = 0; position <= 180; position += 1)
202206
{
203207
// goes from 0 degrees to 180 degrees
@@ -206,15 +210,15 @@ void loop()
206210
{
207211
ISR_Servo.setPosition(ISR_servo[index].servoIndex, (position + index * (180 / NUM_SERVOS)) % 180 );
208212
}
209-
213+
210214
// waits 50ms for the servo to reach the position
211215
delay(50);
212216
}
213-
217+
214218
delay(5000);
215219

216220
Serial.println(F("Servos, index depending, be somewhere from 180-0 degress"));
217-
221+
218222
for (position = 180; position >= 0; position -= 1)
219223
{
220224
// goes from 0 degrees to 180 degrees
@@ -223,11 +227,11 @@ void loop()
223227
{
224228
ISR_Servo.setPosition(ISR_servo[index].servoIndex, (position + index * (180 / NUM_SERVOS)) % 180 );
225229
}
226-
230+
227231
// waits 50ms for the servo to reach the position
228232
delay(50);
229233
}
230-
234+
231235
// waits 5s between test
232236
delay(5000);
233237
}

0 commit comments

Comments
 (0)