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

Commit

Permalink
Update README.md and use allman astyle
Browse files Browse the repository at this point in the history
  • Loading branch information
khoih-prog authored Nov 24, 2022
1 parent 2fbea67 commit 114dc0c
Show file tree
Hide file tree
Showing 19 changed files with 245 additions and 110 deletions.
25 changes: 23 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,45 @@ Please ensure to specify the following:
Arduino IDE version: 1.8.19
ESP8266 Core Version v3.0.2
OS: Ubuntu 20.04 LTS
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
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
Context:
I encountered a crash while trying to use the Timer Interrupt.
I encountered a crash while using this library
Steps to reproduce:
1. ...
2. ...
3. ...
4. ...
```

---

### Sending Feature Requests

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

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.

---

### Sending Pull Requests

Pull Requests with changes and fixes are also welcome!

Please use the `astyle` to reformat the updated library code as follows (demo for Ubuntu Linux)

1. Change directory to the library GitHub

```
xy@xy-Inspiron-3593:~$ cd Arduino/xy/ESP8266_ISR_Servo_GitHub/
xy@xy-Inspiron-3593:~/Arduino/xy/ESP8266_ISR_Servo_GitHub$
```

2. Issue astyle command

```
xy@xy-Inspiron-3593:~/Arduino/xy/ESP8266_ISR_Servo_GitHub$ bash utils/restyle.sh
```


18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](#Contributing)
[![GitHub issues](https://img.shields.io/github/issues/khoih-prog/ESP8266_ISR_Servo.svg)](http://github.com/khoih-prog/ESP8266_ISR_Servo/issues)


<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>
<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>
<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>
<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>


---
---
Expand Down Expand Up @@ -60,8 +64,6 @@

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



---
---

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

You can include this `.hpp` file

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

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

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

### New functions

```
```cpp
// returns last position in degrees if success, or -1 on wrong servoIndex
int getPosition(unsigned servoIndex);

Expand Down Expand Up @@ -249,7 +251,7 @@ https://github.com/khoih-prog/ESP8266_ISR_Servo/blob/9a8757117d2c901bed222990f11
### 1. ESP8266_MultipleRandomServos on ESP8266_NODEMCU_ESP12E
```
```cpp
Starting ESP8266_MultipleRandomServos on ESP8266_NODEMCU_ESP12E
ESP8266_ISR_Servo v1.3.0
[ISR_SERVO] ESP8266FastTimerInterrupt: _fre = 5000000.00 , _count = 50
Expand Down Expand Up @@ -353,7 +355,7 @@ Servos idx = 5, act. pos. (deg) = [ISR_SERVO] Idx = 5
### 2. ESP8266_ISR_MultiServos on ESP8266_NODEMCU_ESP12E


```
```cpp
Starting ESP8266_ISR_MultiServos on ESP8266_NODEMCU_ESP12E
ESP8266_ISR_Servo v1.3.0
[ISR_SERVO] ESP8266FastTimerInterrupt: _fre = 5000000.00 , _count = 50
Expand Down Expand Up @@ -480,4 +482,4 @@ If you want to contribute to this project:

## Copyright

Copyright 2019- Khoi Hoang
Copyright (c) 2019- Khoi Hoang
8 changes: 7 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](#Contributing)
[![GitHub issues](https://img.shields.io/github/issues/khoih-prog/ESP8266_ISR_Servo.svg)](http://github.com/khoih-prog/ESP8266_ISR_Servo/issues)


<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>
<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>
<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>
<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>

---
---

Expand All @@ -31,7 +37,7 @@

### Releases v1.2.0

1. Update to match new ESP8266 core v3.0.0
1. Update to match new ESP8266 core `v3.0.0`

### Releases v1.1.0

Expand Down
20 changes: 12 additions & 8 deletions examples/ESP8266_ISR_MultiServos/ESP8266_ISR_MultiServos.ino
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
ESP8266_ISR_MultiServos.ino
For ESP8266 boards
Written by Khoi Hoang
Built by Khoi Hoang https://github.com/khoih-prog/ESP8266_ISR_Servo
Licensed under MIT license
The ESP8266 timers are badly designed, using only 23-bit counter along with maximum 256 prescaler. They're only better than UNO / Mega.
The ESP8266 has two hardware timers, but timer0 has been used for WiFi and it's not advisable to use. Only timer1 is available.
The timer1's 23-bit counter terribly can count only up to 8,388,607. So the timer1 maximum interval is very short.
Expand All @@ -19,7 +19,7 @@
Loosely based on SimpleTimer - A timer library for Arduino.
Author: [email protected]
Copyright (c) 2010 OTTOTECNICA Italy
The ESP8266 timers are badly designed, using only 23-bit counter along with maximum 256 prescaler. They're only better than UNO / Mega.
The ESP8266 has two hardware timers, but timer0 has been used for WiFi and it's not advisable to use. Only timer1 is available.
The timer1's 23-bit counter terribly can count only up to 8,388,607. So the timer1 maximum interval is very short.
Expand Down Expand Up @@ -87,13 +87,15 @@ int servoIndex2 = -1;
void setup()
{
Serial.begin(115200);

while (!Serial);

delay(200);

Serial.print(F("\nStarting ESP8266_ISR_MultiServos on ")); Serial.println(ARDUINO_BOARD);
Serial.print(F("\nStarting ESP8266_ISR_MultiServos on "));
Serial.println(ARDUINO_BOARD);
Serial.println(ESP8266_ISR_SERVO_VERSION);

servoIndex1 = ISR_Servo.setupServo(D8, MIN_MICROS, MAX_MICROS);
servoIndex2 = ISR_Servo.setupServo(D7, MIN_MICROS, MAX_MICROS);

Expand Down Expand Up @@ -121,10 +123,12 @@ void loop()

if (position % 30 == 0)
{
Serial.print(F("Servo1 pos = ")); Serial.print(position);
Serial.print(F(", Servo2 pos = ")); Serial.println(180 - position);
Serial.print(F("Servo1 pos = "));
Serial.print(position);
Serial.print(F(", Servo2 pos = "));
Serial.println(180 - position);
}

ISR_Servo.setPosition(servoIndex1, position);
ISR_Servo.setPosition(servoIndex2, 180 - position);
// waits 15ms for the servo to reach the position
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
ESP8266_MultipleRandomServos.ino
For ESP8266 boards
Written by Khoi Hoang
Built by Khoi Hoang https://github.com/khoih-prog/ESP8266_ISR_Servo
Licensed under MIT license
The ESP8266 timers are badly designed, using only 23-bit counter along with maximum 256 prescaler. They're only better than UNO / Mega.
The ESP8266 has two hardware timers, but timer0 has been used for WiFi and it's not advisable to use. Only timer1 is available.
The timer1's 23-bit counter terribly can count only up to 8,388,607. So the timer1 maximum interval is very short.
Expand Down Expand Up @@ -88,11 +88,13 @@ ISR_servo_t ISR_servo[NUM_SERVOS] =
void setup()
{
Serial.begin(115200);

while (!Serial);

delay(200);

Serial.print(F("\nStarting ESP8266_MultipleRandomServos on ")); Serial.println(ARDUINO_BOARD);
Serial.print(F("\nStarting ESP8266_MultipleRandomServos on "));
Serial.println(ARDUINO_BOARD);
Serial.println(ESP8266_ISR_SERVO_VERSION);

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

if (ISR_servo[index].servoIndex != -1)
{
Serial.print(F("Setup OK Servo index = ")); Serial.println(ISR_servo[index].servoIndex);
Serial.print(F("Setup OK Servo index = "));
Serial.println(ISR_servo[index].servoIndex);
}
else
{
Serial.print(F("Setup Failed Servo index = ")); Serial.println(ISR_servo[index].servoIndex);
Serial.print(F("Setup Failed Servo index = "));
Serial.println(ISR_servo[index].servoIndex);
}
}
}
Expand All @@ -126,42 +130,42 @@ void loop()

position = 0;
Serial.println(F("Servos @ 0 degree"));

for (int index = 0; index < NUM_SERVOS; index++)
{
ISR_Servo.setPosition(ISR_servo[index].servoIndex, position );
printServoInfo(index);
}

// waits 5s between test
delay(5000);

position = 90;
Serial.println(F("Servos @ 90 degree"));

for (int index = 0; index < NUM_SERVOS; index++)
{
ISR_Servo.setPosition(ISR_servo[index].servoIndex, position );
printServoInfo(index);
}

// waits 5s between test
delay(5000);

position = 180;
Serial.println(F("Servos @ 180 degree"));

for (int index = 0; index < NUM_SERVOS; index++)
{
ISR_Servo.setPosition(ISR_servo[index].servoIndex, position );
printServoInfo(index);
}

// waits 5s between test
delay(5000);

Serial.println(F("Servos sweeps from 0-180 degress"));

for (position = 0; position <= 180; position += 1)
{
// goes from 0 degrees to 180 degrees
Expand All @@ -170,16 +174,16 @@ void loop()
{
ISR_Servo.setPosition(ISR_servo[index].servoIndex, position );
}

// waits 50ms for the servo to reach the position
delay(50);
}

// waits 5s between test
delay(5000);

Serial.println(F("Servos sweeps from 180-0 degress"));

for (position = 180; position >= 0; position -= 1)
{
// goes from 0 degrees to 180 degrees
Expand All @@ -188,16 +192,16 @@ void loop()
{
ISR_Servo.setPosition(ISR_servo[index].servoIndex, position );
}

// waits 50ms for the servo to reach the position
delay(50);
}

// waits 5s between test
delay(5000);

Serial.println(F("Servos, index depending, be somewhere from 0-180 degress"));

for (position = 0; position <= 180; position += 1)
{
// goes from 0 degrees to 180 degrees
Expand All @@ -206,15 +210,15 @@ void loop()
{
ISR_Servo.setPosition(ISR_servo[index].servoIndex, (position + index * (180 / NUM_SERVOS)) % 180 );
}

// waits 50ms for the servo to reach the position
delay(50);
}

delay(5000);

Serial.println(F("Servos, index depending, be somewhere from 180-0 degress"));

for (position = 180; position >= 0; position -= 1)
{
// goes from 0 degrees to 180 degrees
Expand All @@ -223,11 +227,11 @@ void loop()
{
ISR_Servo.setPosition(ISR_servo[index].servoIndex, (position + index * (180 / NUM_SERVOS)) % 180 );
}

// waits 50ms for the servo to reach the position
delay(50);
}

// waits 5s between test
delay(5000);
}
Loading

0 comments on commit 114dc0c

Please sign in to comment.