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

Commit 2500e2e

Browse files
authored
v1.2.0 for new ESP32 core
### Releases v1.2.0 1. Update to use with ESP32 core v2.0.5+. 2. Convert to `h-only` style 3. Use `allman astyle` and add `utils`
1 parent 24e63e7 commit 2500e2e

22 files changed

+2051
-648
lines changed

CONTRIBUTING.md

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ If you don't find anything, please [open a new issue](https://github.com/khoih-p
1515
Please ensure to specify the following:
1616

1717
* Arduino IDE version (e.g. 1.8.19) or Platform.io version
18+
* `ESP32` Core Version (e.g. ESP32 core v2.0.5)
1819
* `ESP32-S2` Board type (e.g. ESP32S2_DEV Module, ESP32_S2_Saola, etc.)
1920
* Contextual information (e.g. what you were trying to achieve)
2021
* Simplest possible steps to reproduce
@@ -27,28 +28,50 @@ Please ensure to specify the following:
2728

2829
```
2930
Arduino IDE version: 1.8.19
30-
ESP32 core v2.0.3
31+
ESP32 core v2.0.5
3132
ESP32S2_DEV Module
3233
OS: Ubuntu 20.04 LTS
33-
Linux xy-Inspiron-3593 5.13.0-44-generic #49~20.04.1-Ubuntu SMP Wed May 18 18:44:28 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
34+
Linux xy-Inspiron-3593 5.15.0-52-generic #58~20.04.1-Ubuntu SMP Thu Oct 13 13:09:46 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
3435
3536
Context:
36-
I encountered a crash while trying to use the Timer Interrupt.
37-
37+
I encountered a crash while using this library
3838
Steps to reproduce:
3939
1. ...
4040
2. ...
4141
3. ...
4242
4. ...
4343
```
4444

45+
### Additional context
46+
47+
Add any other context about the problem here.
48+
49+
---
50+
4551
### Sending Feature Requests
4652

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

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

57+
---
58+
5159
### Sending Pull Requests
5260

5361
Pull Requests with changes and fixes are also welcome!
5462

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

README.md

Lines changed: 172 additions & 85 deletions
Large diffs are not rendered by default.

changelog.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,24 @@
22

33
[![arduino-library-badge](https://www.ardu-badge.com/badge/ESP32_S2_ISR_Servo.svg?)](https://www.ardu-badge.com/ESP32_S2_ISR_Servo)
44
[![GitHub release](https://img.shields.io/github/release/khoih-prog/ESP32_S2_ISR_Servo.svg)](https://github.com/khoih-prog/ESP32_S2_ISR_Servo/releases)
5-
[![GitHub](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/khoih-prog/ESP32_S2_ISR_Servo/blob/master/LICENSE)
5+
[![GitHub](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/khoih-prog/ESP32_S2_ISR_Servo/blob/main/LICENSE)
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/ESP32_S2_ISR_Servo.svg)](http://github.com/khoih-prog/ESP32_S2_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-ESP32_S2_ISR_Servo/count.svg" title="ESP32_S2_ISR_Servo Visitor count"><img src="https://profile-counter.glitch.me/khoih-prog-ESP32_S2_ISR_Servo/count.svg" style="height: 30px;width: 200px;"></a>
14+
15+
916
---
1017
---
1118

1219
## Table of Contents
1320

1421
* [Changelog](#changelog)
22+
* [Releases v1.2.0](#releases-v120)
1523
* [Releases v1.1.1](#releases-v111)
1624
* [Releases v1.1.0](#releases-v110)
1725

@@ -20,6 +28,12 @@
2028

2129
## Changelog
2230

31+
### Releases v1.2.0
32+
33+
1. Update to use with ESP32 core v2.0.5+.
34+
2. Convert to `h-only` style
35+
3. Use `allman astyle` and add `utils`
36+
2337
### Releases v1.1.1
2438

2539
1. Add support to new Adafruit board QTPY_ESP32S2

examples/ESP32_S2_ISR_MultiServos/ESP32_S2_ISR_MultiServos.ino

Lines changed: 67 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22
ESP32_S2_ISR_MultiServos.ino
33
For ESP32_S2 boards
44
Written by Khoi Hoang
5-
6-
Built by Khoi Hoang https://github.com/khoih-prog/ESP32_ISR_Servo
5+
6+
Built by Khoi Hoang https://github.com/khoih-prog/ESP32_S2_ISR_Servo
77
Licensed under MIT license
88
99
The ESP32 has two timer groups, each one with two general purpose hardware timers. All the timers
1010
are based on 64 bits counters and 16 bit prescalers
1111
The timer counters can be configured to count up or down and support automatic reload and software reload
1212
They can also generate alarms when they reach a specific value, defined by the software.
1313
The value of the counter can be read by the software program.
14-
14+
1515
Now these new 16 ISR-based PWM servo contro uses only 1 hardware timer.
1616
The accuracy is nearly perfect compared to software timers. The most important feature is they're ISR-based timers
1717
Therefore, their executions are not blocked by bad-behaving functions / tasks.
1818
This important feature is absolutely necessary for mission-critical tasks.
19-
19+
2020
Notes:
2121
Special design is necessary to share data between interrupt code and the rest of your program.
2222
Variables usually need to be "volatile" types. Volatile tells the compiler to avoid optimizations that assume
@@ -78,7 +78,6 @@
7878
#include "ESP32_S2_ISR_Servo.h"
7979

8080
//See file .../hardware/espressif/esp32/variants/(esp32|doitESP32devkitV1)/pins_arduino.h
81-
#define LED_BUILTIN 2 // Pin D2 mapped to pin GPIO2/ADC12 of ESP32, control on-board LED
8281
#define PIN_LED 2 // Pin D2 mapped to pin GPIO2/ADC12 of ESP32, control on-board LED
8382

8483
#define PIN_D0 0 // Pin D0 mapped to pin GPIO0/BOOT/ADC11/TOUCH1 of ESP32
@@ -133,71 +132,77 @@ int servoIndex2 = -1;
133132

134133
void setup()
135134
{
136-
Serial.begin(115200);
137-
while (!Serial);
135+
Serial.begin(115200);
136+
137+
while (!Serial && millis() < 5000);
138138

139139
delay(500);
140140

141-
Serial.print(F("\nStarting ESP32_S2_ISR_MultiServos on ")); Serial.println(ARDUINO_BOARD);
142-
Serial.println(ESP32_S2_ISR_SERVO_VERSION);
143-
144-
//Select ESP32 timer USE_ESP32_TIMER_NO
145-
ESP32_ISR_Servos.useTimer(USE_ESP32_TIMER_NO);
141+
Serial.print(F("\nStarting ESP32_S2_ISR_MultiServos on "));
142+
Serial.println(ARDUINO_BOARD);
143+
Serial.println(ESP32_S2_ISR_SERVO_VERSION);
144+
145+
//Select ESP32 timer USE_ESP32_TIMER_NO
146+
ESP32_ISR_Servos.useTimer(USE_ESP32_TIMER_NO);
146147

147-
servoIndex1 = ESP32_ISR_Servos.setupServo(PIN_D3, MIN_MICROS, MAX_MICROS);
148-
servoIndex2 = ESP32_ISR_Servos.setupServo(PIN_D4, MIN_MICROS, MAX_MICROS);
148+
servoIndex1 = ESP32_ISR_Servos.setupServo(PIN_D3, MIN_MICROS, MAX_MICROS);
149+
servoIndex2 = ESP32_ISR_Servos.setupServo(PIN_D4, MIN_MICROS, MAX_MICROS);
149150

150-
if (servoIndex1 != -1)
151-
Serial.println(F("Setup Servo1 OK"));
152-
else
153-
Serial.println(F("Setup Servo1 failed"));
151+
if (servoIndex1 != -1)
152+
Serial.println(F("Setup Servo1 OK"));
153+
else
154+
Serial.println(F("Setup Servo1 failed"));
154155

155-
if (servoIndex2 != -1)
156-
Serial.println(F("Setup Servo2 OK"));
157-
else
158-
Serial.println(F("Setup Servo2 failed"));
156+
if (servoIndex2 != -1)
157+
Serial.println(F("Setup Servo2 OK"));
158+
else
159+
Serial.println(F("Setup Servo2 failed"));
159160
}
160161

161162
void loop()
162163
{
163-
int position;
164-
165-
if ( ( servoIndex1 != -1) && ( servoIndex2 != -1) )
166-
{
167-
for (position = 0; position <= 180; position++)
168-
{
169-
// goes from 0 degrees to 180 degrees
170-
// in steps of 1 degree
171-
172-
if (position % 30 == 0)
173-
{
174-
Serial.print(F("Servo1 pos = ")); Serial.print(position);
175-
Serial.print(F(", Servo2 pos = ")); Serial.println(180 - position);
176-
}
177-
178-
ESP32_ISR_Servos.setPosition(servoIndex1, position);
179-
ESP32_ISR_Servos.setPosition(servoIndex2, 180 - position);
180-
// waits 30ms for the servo to reach the position
181-
delay(30);
182-
}
183-
184-
delay(5000);
185-
186-
for (position = 180; position >= 0; position--)
187-
{
188-
// goes from 180 degrees to 0 degrees
189-
if (position % 30 == 0)
190-
{
191-
Serial.print(F("Servo1 pos = ")); Serial.print(position);
192-
Serial.print(F(", Servo2 pos = ")); Serial.println(180 - position);
193-
}
194-
195-
ESP32_ISR_Servos.setPosition(servoIndex1, position);
196-
ESP32_ISR_Servos.setPosition(servoIndex2, 180 - position);
197-
// waits 30ms for the servo to reach the position
198-
delay(30);
199-
}
200-
201-
delay(5000);
202-
}
164+
int position;
165+
166+
if ( ( servoIndex1 != -1) && ( servoIndex2 != -1) )
167+
{
168+
for (position = 0; position <= 180; position++)
169+
{
170+
// goes from 0 degrees to 180 degrees
171+
// in steps of 1 degree
172+
173+
if (position % 30 == 0)
174+
{
175+
Serial.print(F("Servo1 pos = "));
176+
Serial.print(position);
177+
Serial.print(F(", Servo2 pos = "));
178+
Serial.println(180 - position);
179+
}
180+
181+
ESP32_ISR_Servos.setPosition(servoIndex1, position);
182+
ESP32_ISR_Servos.setPosition(servoIndex2, 180 - position);
183+
// waits 30ms for the servo to reach the position
184+
delay(30);
185+
}
186+
187+
delay(5000);
188+
189+
for (position = 180; position >= 0; position--)
190+
{
191+
// goes from 180 degrees to 0 degrees
192+
if (position % 30 == 0)
193+
{
194+
Serial.print(F("Servo1 pos = "));
195+
Serial.print(position);
196+
Serial.print(F(", Servo2 pos = "));
197+
Serial.println(180 - position);
198+
}
199+
200+
ESP32_ISR_Servos.setPosition(servoIndex1, position);
201+
ESP32_ISR_Servos.setPosition(servoIndex2, 180 - position);
202+
// waits 30ms for the servo to reach the position
203+
delay(30);
204+
}
205+
206+
delay(5000);
207+
}
203208
}

0 commit comments

Comments
 (0)