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 committed Nov 24, 2022
1 parent a06eed6 commit 14eb3a4
Show file tree
Hide file tree
Showing 16 changed files with 365 additions and 239 deletions.
27 changes: 24 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ If you don't find anything, please [open a new issue](https://github.com/khoih-p
Please ensure to specify the following:

* Arduino IDE version (e.g. 1.8.19) or Platform.io version
* `SAMD` Core Version (e.g. Arduino SAMD core v1.8.13, Adafruit SAMD core v1.7.9, Seeed Studio SAMD v1.8.2, Sparkfun SAMD v1.8.3)
* `SAMD` Core Version (e.g. Arduino SAMD core v1.8.13, Adafruit SAMD core v1.7.11, Seeed Studio SAMD v1.8.3, Sparkfun SAMD v1.8.3)
* Board type and relevant info
* Contextual information (e.g. what you were trying to achieve)
* Simplest possible steps to reproduce
Expand All @@ -31,10 +31,10 @@ Arduino IDE version: 1.8.19
Arduino SAMD Core Version 1.8.13
SAMD_NANO_33_IOT
OS: Ubuntu 20.04 LTS
Linux xy-Inspiron-3593 5.13.0-35-generic #40~20.04.1-Ubuntu SMP Mon Mar 7 09:18:32 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. ...
Expand All @@ -43,13 +43,34 @@ Steps to reproduce:
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/SAMD_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/SAMD_ISR_Servo_GitHub/
xy@xy-Inspiron-3593:~/Arduino/xy/SAMD_ISR_Servo_GitHub$
```

2. Issue astyle command

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



44 changes: 24 additions & 20 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/SAMD_ISR_Servo.svg)](http://github.com/khoih-prog/SAMD_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-SAMD_ISR_Servo/count.svg" title="SAMD_ISR_Servo Visitor count"><img src="https://profile-counter.glitch.me/khoih-prog-SAMD_ISR_Servo/count.svg" style="height: 30px;width: 200px;"></a>


---
---
Expand Down Expand Up @@ -114,8 +118,8 @@ This library enables you to use `1 Hardware Timer` on an SAMD-based board to con

1. [`Arduino IDE 1.8.19+` for Arduino](https://github.com/arduino/Arduino). [![GitHub release](https://img.shields.io/github/release/arduino/Arduino.svg)](https://github.com/arduino/Arduino/releases/latest)
2. [`Arduino SAMD core 1.8.13+`](https://github.com/arduino/ArduinoCore-samd) for SAMD ARM Cortex-M0+ boards. [![GitHub release](https://img.shields.io/github/release/arduino/ArduinoCore-samd.svg)](https://github.com/arduino/ArduinoCore-samd/releases/latest)
3. [`Adafruit SAMD core 1.7.9+`](https://github.com/adafruit/ArduinoCore-samd) for SAMD ARM Cortex-M0+ and M4 boards (Nano 33 IoT, etc.). [![GitHub release](https://img.shields.io/github/release/adafruit/ArduinoCore-samd.svg)](https://github.com/adafruit/ArduinoCore-samd/releases/latest)
4. [`Seeeduino SAMD core 1.8.2+`](https://github.com/Seeed-Studio/ArduinoCore-samd) for SAMD21/SAMD51 boards (XIAO M0, Wio Terminal, etc.). [![Latest release](https://img.shields.io/github/release/Seeed-Studio/ArduinoCore-samd.svg)](https://github.com/Seeed-Studio/ArduinoCore-samd/releases/latest/)
3. [`Adafruit SAMD core 1.7.11+`](https://github.com/adafruit/ArduinoCore-samd) for SAMD ARM Cortex-M0+ and M4 boards (Nano 33 IoT, etc.). [![GitHub release](https://img.shields.io/github/release/adafruit/ArduinoCore-samd.svg)](https://github.com/adafruit/ArduinoCore-samd/releases/latest)
4. [`Seeeduino SAMD core 1.8.3+`](https://github.com/Seeed-Studio/ArduinoCore-samd) for SAMD21/SAMD51 boards (XIAO M0, Wio Terminal, etc.). [![Latest release](https://img.shields.io/github/release/Seeed-Studio/ArduinoCore-samd.svg)](https://github.com/Seeed-Studio/ArduinoCore-samd/releases/latest/)
5. [`Sparkfun SAMD core 1.8.1+`](https://github.com/sparkfun/Arduino_Boards) for SAMD21/SAMD51 boards (SparkFun_RedBoard_Turbo, SparkFun_SAMD51_Thing_Plus, etc.).

---
Expand Down Expand Up @@ -190,13 +194,13 @@ Whenever the above-mentioned compiler error issue is fixed with the new Arduino

#### 2. For Adafruit SAMD boards

***To be able to compile without error and automatically detect and display BOARD_NAME on Adafruit SAMD (Itsy-Bitsy M4, etc) boards***, you have to copy the files in [Adafruit SAMD Packages_Patches](Packages_Patches/adafruit/hardware/samd/1.7.9) into Adafruit samd directory (~/.arduino15/packages/adafruit/hardware/samd/1.7.9).
***To be able to compile without error and automatically detect and display BOARD_NAME on Adafruit SAMD (Itsy-Bitsy M4, etc) boards***, you have to copy the files in [Adafruit SAMD Packages_Patches](Packages_Patches/adafruit/hardware/samd/1.7.11) into Adafruit samd directory (~/.arduino15/packages/adafruit/hardware/samd/1.7.11).

Supposing the Adafruit SAMD core version is 1.7.9. This file must be copied into the directory:
Supposing the Adafruit SAMD core version is 1.7.11. This file must be copied into the directory:

- `~/.arduino15/packages/adafruit/hardware/samd/1.7.9/platform.txt`
- `~/.arduino15/packages/adafruit/hardware/samd/1.7.9/cores/arduino/Print.h`
- `~/.arduino15/packages/adafruit/hardware/samd/1.7.9/cores/arduino/Print.cpp`
- `~/.arduino15/packages/adafruit/hardware/samd/1.7.11/platform.txt`
- `~/.arduino15/packages/adafruit/hardware/samd/1.7.11/cores/arduino/Print.h`
- `~/.arduino15/packages/adafruit/hardware/samd/1.7.11/cores/arduino/Print.cpp`

Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz
This file must be copied into the directory:
Expand All @@ -207,14 +211,14 @@ This file must be copied into the directory:

#### 3. For Seeeduino SAMD boards

***To be able to compile without error and automatically detect and display BOARD_NAME on Seeeduino SAMD (XIAO M0, Wio Terminal, etc) boards***, you have to copy the files in [Seeeduino SAMD Packages_Patches](Packages_Patches/Seeeduino/hardware/samd/1.8.2) into Seeeduino samd directory (~/.arduino15/packages/Seeeduino/hardware/samd/1.8.2).
***To be able to compile without error and automatically detect and display BOARD_NAME on Seeeduino SAMD (XIAO M0, Wio Terminal, etc) boards***, you have to copy the files in [Seeeduino SAMD Packages_Patches](Packages_Patches/Seeeduino/hardware/samd/1.8.3) into Seeeduino samd directory (~/.arduino15/packages/Seeeduino/hardware/samd/1.8.3).

Supposing the Seeeduino SAMD core version is 1.8.2. This file must be copied into the directory:
Supposing the Seeeduino SAMD core version is 1.8.3. This file must be copied into the directory:

- `~/.arduino15/packages/Seeeduino/hardware/samd/1.8.2/platform.txt`
- `~/.arduino15/packages/Seeeduino/hardware/samd/1.8.2/cores/arduino/Arduino.h`
- `~/.arduino15/packages/Seeeduino/hardware/samd/1.8.2/cores/arduino/Print.h`
- `~/.arduino15/packages/Seeeduino/hardware/samd/1.8.2/cores/arduino/Print.cpp`
- `~/.arduino15/packages/Seeeduino/hardware/samd/1.8.3/platform.txt`
- `~/.arduino15/packages/Seeeduino/hardware/samd/1.8.3/cores/arduino/Arduino.h`
- `~/.arduino15/packages/Seeeduino/hardware/samd/1.8.3/cores/arduino/Print.h`
- `~/.arduino15/packages/Seeeduino/hardware/samd/1.8.3/cores/arduino/Print.cpp`

Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz
This file must be copied into the directory:
Expand Down Expand Up @@ -253,14 +257,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 "SAMD_ISR_Servo.hpp" //https://github.com/khoih-prog/SAMD_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 "SAMD_ISR_Servo.h" //https://github.com/khoih-prog/SAMD_ISR_Servo
```
Expand Down Expand Up @@ -323,7 +327,7 @@ https://github.com/khoih-prog/SAMD_ISR_Servo/blob/f3b18bbd495be4f2a2e88f3534e76a
### 1. SAMD_MultipleRandomServos on Adafruit SAMD51 ITSYBITSY_M4


```
```cpp
Starting SAMD_MultipleRandomServos on ITSYBITSY_M4
SAMD_ISR_Servo v1.1.0
Setup OK, Servo index = 0
Expand Down Expand Up @@ -455,7 +459,7 @@ Servos idx = 2, act. pos. (deg) = [ISR_SERVO] Idx = 2

### 2. SAMD_MultipleRandomServos on Arduino SAMD21 SAMD_NANO_33_IOT

```
```cpp
Starting SAMD_MultipleRandomServos on SAMD_NANO_33_IOT
SAMD_ISR_Servo v1.1.0
Setup OK Servo index = 0
Expand Down Expand Up @@ -572,7 +576,7 @@ Servos @ 0 degree

### 3. SAMD_MultipleRandomServos on Seeeduino SAMD21 SEEED_XIAO_M0

```
```cpp
Starting SAMD_MultipleRandomServos on SEEED_XIAO_M0
SAMD_ISR_Servo v1.1.0
[ISR_SERVO] _period = 20 , frequency = 50000.00
Expand Down Expand Up @@ -700,7 +704,7 @@ Submit issues to: [SAMD_ISR_Servo issues](https://github.com/khoih-prog/SAMD_ISR
6. Optimize library code by using `reference-passing` instead of `value-passing`
7. Display informational warning only when `ISR_SERVO_DEBUG` > 1
8. Add support to many more boards, such as `SAMD21E1xA`, `SAMD21G1xA` and`SAMD21J1xA`

9. Add astyle using `allman` style. Restyle the library

---
---
Expand Down Expand Up @@ -730,4 +734,4 @@ If you want to contribute to this project:

## Copyright

Copyright 2021- Khoi Hoang
Copyright(c) 2021- Khoi Hoang
7 changes: 7 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
[![GitHub issues](https://img.shields.io/github/issues/khoih-prog/SAMD_ISR_Servo.svg)](http://github.com/khoih-prog/SAMD_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-SAMD_ISR_Servo/count.svg" title="SAMD_ISR_Servo Visitor count"><img src="https://profile-counter.glitch.me/khoih-prog-SAMD_ISR_Servo/count.svg" style="height: 30px;width: 200px;"></a>


---
---

Expand Down
37 changes: 21 additions & 16 deletions examples/SAMD_MultipleRandomServos/SAMD_MultipleRandomServos.ino
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
For :
- SAMD21-based boards such as Nano-33-IoT, SAMD Zero, Seeeduino XIAO, etc.
- SAMD51-based boards such as Adafruit Itsy-Bitsy M4, Metro M4, Seeeduino WIO-Terminal, etc.
Written by Khoi Hoang
Built by Khoi Hoang https://github.com/khoih-prog/SAMD_ISR_Servo
Expand All @@ -30,7 +30,7 @@
considerable power, we will connect servo power to the VBat pin of the SAMD (located
near the USB connector). THIS IS ONLY APPROPRIATE FOR SMALL SERVOS.
We could also connect servo power to a separate external power source (as long as we connect all of
We could also connect servo power to a separate external power source (as long as we connect all of
the grounds (SAMD, servo, and external power).
In this example, we just connect SAMD ground to servo ground. The servo signal pins
connect to any available GPIO pins on the SAMD (in this example, we use pins (D1-D6).
Expand All @@ -50,7 +50,7 @@
|| defined(__SAMD21E15A__) || defined(__SAMD21E16A__) || defined(__SAMD21E17A__) || defined(__SAMD21E18A__) \
|| defined(__SAMD21G15A__) || defined(__SAMD21G16A__) || defined(__SAMD21G17A__) || defined(__SAMD21G18A__) \
|| defined(__SAMD21J15A__) || defined(__SAMD21J16A__) || defined(__SAMD21J17A__) || defined(__SAMD21J18A__) )
#error This code is designed to run on SAMD21/SAMD51 platform! Please check your Tools->Board setting.
#error This code is designed to run on SAMD21/SAMD51 platform! Please check your Tools->Board setting.
#endif

#define ISR_SERVO_DEBUG 1
Expand All @@ -63,7 +63,7 @@

// Published values for SG90 servos; adjust if needed
#define MIN_MICROS 800
#define MAX_MICROS 2450
#define MAX_MICROS 2450

#define SERVO_PIN_1 A0
#define SERVO_PIN_2 A1
Expand Down Expand Up @@ -93,13 +93,15 @@ void setup()
pinMode(ISR_servo[index].servoPin, OUTPUT);
digitalWrite(ISR_servo[index].servoPin, LOW);
}

Serial.begin(115200);

while (!Serial);

delay(200);

Serial.print(F("\nStarting SAMD_MultipleRandomServos on ")); Serial.println(BOARD_NAME);
Serial.print(F("\nStarting SAMD_MultipleRandomServos on "));
Serial.println(BOARD_NAME);
Serial.println(SAMD_ISR_SERVO_VERSION);

// SAMD51 always uses TIMER_TC3
Expand All @@ -111,11 +113,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 @@ -138,41 +142,42 @@ void loop()

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

for (int index = 0; index < NUM_SERVOS; index++)
{
SAMD_ISR_Servos.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++)
{
SAMD_ISR_Servos.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++)
{
SAMD_ISR_Servos.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 += 5)
{
// goes from 0 degrees to 180 degrees
Expand All @@ -181,11 +186,11 @@ void loop()
{
SAMD_ISR_Servos.setPosition(ISR_servo[index].servoIndex, position );
}

// waits 0.1s for the servo to reach the position
delay(100);
}

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

0 comments on commit 14eb3a4

Please sign in to comment.