Skip to content

Commit

Permalink
Version 2.3.1 Fixed wrong timer selection for STM32F1xx / ARDUINO_ARC…
Browse files Browse the repository at this point in the history
…H_STM32.
  • Loading branch information
ArminJo committed Sep 3, 2020
1 parent 3b90cdc commit e6b834e
Show file tree
Hide file tree
Showing 22 changed files with 133 additions and 64 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# [ServoEasing](https://github.com/ArminJo/ServoEasing) - move your servo more natural
Available as Arduino library "ServoEasing"

### [Version 2.3.0](https://github.com/ArminJo/ServoEasing/releases)
### [Version 2.3.1](https://github.com/ArminJo/ServoEasing/releases)

[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
[![Installation instructions](https://www.ardu-badge.com/badge/ServoEasing.svg?)](https://www.ardu-badge.com/ServoEasing)
Expand Down Expand Up @@ -221,6 +221,10 @@ If you see strange behavior, you can open the library file *ServoEasing.h* and c
This will print internal information visible in the Arduino *Serial Monitor* which may help finding the reason for it.

# Revision History
### Version 2.3.1
- Fixed wrong timer selection for `STM32F1xx` / `ARDUINO_ARCH_STM32`.
- Documentation.

### Version 2.3.0
- Fixed EASE_LINEAR formula bug introduced with 2.0.0 for 32 bit CPU's. Thanks to [drifkind](https://github.com/drifkind).
- Added `stop()`, `continueWithInterrupts()` and `continueWithoutInterrupts()` functions.
Expand Down
2 changes: 1 addition & 1 deletion examples/AsymmetricEasing/PinDefinitionsAndMore.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
#elif defined(STM32F1xx) || defined(__STM32F1__)
// BluePill in 2 flavors
// STM32F1xx is for "Generic STM32F1 series / STM32:stm32" from STM32 Boards from STM32 cores of Arduino Board manager
// __STM32F1__is for "Generic STM32F103C series / stm32duino:STM32F1" from STM32F1 Boards (STM32duino.com) of manual installed hardware folder
// __STM32F1__is for "Generic STM32F103C series / stm32duino:STM32F1" from STM32F1 Boards (STM32duino.com) of Arduino Board manager
#define SERVO1_PIN PB7
#define SERVO2_PIN PB8
#define SERVO3_PIN PB9 // Needs timer 4 for Servo library
Expand Down
2 changes: 1 addition & 1 deletion examples/CatMover/PinDefinitionsAndMore.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
#elif defined(STM32F1xx) || defined(__STM32F1__)
// BluePill in 2 flavors
// STM32F1xx is for "Generic STM32F1 series / STM32:stm32" from STM32 Boards from STM32 cores of Arduino Board manager
// __STM32F1__is for "Generic STM32F103C series / stm32duino:STM32F1" from STM32F1 Boards (STM32duino.com) of manual installed hardware folder
// __STM32F1__is for "Generic STM32F103C series / stm32duino:STM32F1" from STM32F1 Boards (STM32duino.com) of Arduino Board manager
#define SERVO1_PIN PB7
#define SERVO2_PIN PB8
#define SERVO3_PIN PB9 // Needs timer 4 for Servo library
Expand Down
2 changes: 1 addition & 1 deletion examples/ContinuousRotatingServo/PinDefinitionsAndMore.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
#elif defined(STM32F1xx) || defined(__STM32F1__)
// BluePill in 2 flavors
// STM32F1xx is for "Generic STM32F1 series / STM32:stm32" from STM32 Boards from STM32 cores of Arduino Board manager
// __STM32F1__is for "Generic STM32F103C series / stm32duino:STM32F1" from STM32F1 Boards (STM32duino.com) of manual installed hardware folder
// __STM32F1__is for "Generic STM32F103C series / stm32duino:STM32F1" from STM32F1 Boards (STM32duino.com) of Arduino Board manager
#define SERVO1_PIN PB7
#define SERVO2_PIN PB8
#define SERVO3_PIN PB9 // Needs timer 4 for Servo library
Expand Down
2 changes: 1 addition & 1 deletion examples/EndPositionsTest/PinDefinitionsAndMore.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
#elif defined(STM32F1xx) || defined(__STM32F1__)
// BluePill in 2 flavors
// STM32F1xx is for "Generic STM32F1 series / STM32:stm32" from STM32 Boards from STM32 cores of Arduino Board manager
// __STM32F1__is for "Generic STM32F103C series / stm32duino:STM32F1" from STM32F1 Boards (STM32duino.com) of manual installed hardware folder
// __STM32F1__is for "Generic STM32F103C series / stm32duino:STM32F1" from STM32F1 Boards (STM32duino.com) of Arduino Board manager
#define SERVO1_PIN PB7
#define SERVO2_PIN PB8
#define SERVO3_PIN PB9 // Needs timer 4 for Servo library
Expand Down
2 changes: 1 addition & 1 deletion examples/LightweightServoExample/PinDefinitionsAndMore.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
#elif defined(STM32F1xx) || defined(__STM32F1__)
// BluePill in 2 flavors
// STM32F1xx is for "Generic STM32F1 series / STM32:stm32" from STM32 Boards from STM32 cores of Arduino Board manager
// __STM32F1__is for "Generic STM32F103C series / stm32duino:STM32F1" from STM32F1 Boards (STM32duino.com) of manual installed hardware folder
// __STM32F1__is for "Generic STM32F103C series / stm32duino:STM32F1" from STM32F1 Boards (STM32duino.com) of Arduino Board manager
#define SERVO1_PIN PB7
#define SERVO2_PIN PB8
#define SERVO3_PIN PB9 // Needs timer 4 for Servo library
Expand Down
2 changes: 1 addition & 1 deletion examples/OneServo/PinDefinitionsAndMore.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
#elif defined(STM32F1xx) || defined(__STM32F1__)
// BluePill in 2 flavors
// STM32F1xx is for "Generic STM32F1 series / STM32:stm32" from STM32 Boards from STM32 cores of Arduino Board manager
// __STM32F1__is for "Generic STM32F103C series / stm32duino:STM32F1" from STM32F1 Boards (STM32duino.com) of manual installed hardware folder
// __STM32F1__is for "Generic STM32F103C series / stm32duino:STM32F1" from STM32F1 Boards (STM32duino.com) of Arduino Board manager
#define SERVO1_PIN PB7
#define SERVO2_PIN PB8
#define SERVO3_PIN PB9 // Needs timer 4 for Servo library
Expand Down
20 changes: 18 additions & 2 deletions examples/PCA9685_Expander/PCA9685_Expander.ino
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,28 @@ void setup() {
/*
* Check if I2C communication is possible. If not, we will wait forever at endTransmission.
*/
// Initialize wire before checkI2CConnection()
Wire.begin(); // Starts with 100 kHz. Clock will eventually be increased at first attach() except for ESP32.
Serial.println(F("Try to communicate with PCA9685 Expander by TWI / I2C"));
Serial.flush();
// Initialize wire before checkI2CConnection()
Wire.begin(); // Starts with 100 kHz. Clock will eventually be increased at first attach() except for ESP32.
#if defined (ARDUINO_ARCH_AVR) // Other platforms do not have this new function
Wire.setWireTimeout(); // Sets default timeout of 25 ms.
do {
Wire.beginTransmission(PCA9685_DEFAULT_ADDRESS);
if (Wire.getWireTimeoutFlag()) {
Serial.println(F("Timeout accessing I2C bus. Wait for bus becoming available"));
Wire.clearWireTimeoutFlag();
delay(100);
} else {
break;
}
} while (true);

#else
Wire.beginTransmission(PCA9685_DEFAULT_ADDRESS);
#endif
uint8_t tWireReturnCode = Wire.endTransmission(true);

if (tWireReturnCode == 0) {
Serial.print(F("Found"));
} else {
Expand Down
20 changes: 18 additions & 2 deletions examples/PCA9685_ExpanderAndServo/PCA9685_ExpanderAndServo.ino
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,27 @@ void setup() {
/*
* Check if I2C communication is possible. If not, we will wait forever at endTransmission.
*/
// Initialize wire before checkI2CConnection()
Wire.begin(); // Starts with 100 kHz. Clock will eventually be increased at first attach() except for ESP32.
Serial.println(F("Try to communicate with PCA9685 Expander by TWI / I2C"));
Serial.flush();
// Initialize wire before checkI2CConnection()
Wire.begin(); // Starts with 100 kHz. Clock will eventually be increased at first attach() except for ESP32.
#if defined (ARDUINO_ARCH_AVR) // Other platforms do not have this new function
Wire.setWireTimeout(); // Sets default timeout of 25 ms.
do {
Wire.beginTransmission(PCA9685_DEFAULT_ADDRESS);
if (Wire.getWireTimeoutFlag()) {
Serial.println(F("Timeout accessing I2C bus. Wait for bus becoming available"));
Wire.clearWireTimeoutFlag();
delay(100);
} else {
break;
}
} while (true);

#else
Wire.beginTransmission(PCA9685_DEFAULT_ADDRESS);
#endif

uint8_t tWireReturnCode = Wire.endTransmission(true);
if (tWireReturnCode == 0) {
Serial.print(F("Found"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ void setup() {

// Initialize wire before checkI2CConnection()
Wire.begin(); // Starts with 100 kHz. Clock will be increased at first attach() except for ESP32.
#if defined (ARDUINO_ARCH_AVR) // Other platforms do not have this new function
Wire.setWireTimeout(); // Sets default timeout of 25 ms.
#endif
checkI2CConnection(FIRST_PCA9685_EXPANDER_ADDRESS);
getAndAttach16ServosToPCA9685Expander(FIRST_PCA9685_EXPANDER_ADDRESS);

Expand Down Expand Up @@ -162,8 +165,21 @@ bool checkI2CConnection(uint8_t aI2CAddress) {
Serial.print(F("Try to communicate with I2C device at address=0x"));
Serial.println(aI2CAddress, HEX);
Serial.flush();

#if defined (ARDUINO_ARCH_AVR) // Other platforms do not have this new function
do {
Wire.beginTransmission(aI2CAddress);
if (Wire.getWireTimeoutFlag()) {
Serial.println(F("Timeout accessing I2C bus. Wait for bus becoming available"));
Wire.clearWireTimeoutFlag();
delay(100);
} else {
break;
}
} while (true);
#else
Wire.beginTransmission(aI2CAddress);
#endif

uint8_t tWireReturnCode = Wire.endTransmission(true);
if (tWireReturnCode == 0) {
Serial.print(F("Found"));
Expand Down
3 changes: 3 additions & 0 deletions examples/RobotArmControl/EasyButtonAtInt01.cpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/gpl.html>.
*/

#if defined(__AVR__)
#include <Arduino.h>
#include "EasyButtonAtInt01.h"

Expand Down Expand Up @@ -675,3 +676,5 @@ ISR(INT1_vect)
}
# endif
#endif // not defined(USE_ATTACH_INTERRUPT)

#endif // defined(__AVR__)
2 changes: 2 additions & 0 deletions examples/RobotArmControl/EasyButtonAtInt01.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
* - Renamed to EasyButtonAtInt01.cpp.h
*/

#if defined(__AVR__)
#include <Arduino.h>

/*
Expand Down Expand Up @@ -378,6 +379,7 @@ void __attribute__ ((weak)) handleINT0Interrupt();
void __attribute__ ((weak)) handleINT1Interrupt();
#endif

#endif // defined(__AVR__)
#endif /* EASY_BUTTON_AT_INT01_H_ */

#pragma once
2 changes: 1 addition & 1 deletion examples/Simple/PinDefinitionsAndMore.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
#elif defined(STM32F1xx) || defined(__STM32F1__)
// BluePill in 2 flavors
// STM32F1xx is for "Generic STM32F1 series / STM32:stm32" from STM32 Boards from STM32 cores of Arduino Board manager
// __STM32F1__is for "Generic STM32F103C series / stm32duino:STM32F1" from STM32F1 Boards (STM32duino.com) of manual installed hardware folder
// __STM32F1__is for "Generic STM32F103C series / stm32duino:STM32F1" from STM32F1 Boards (STM32duino.com) of Arduino Board manager
#define SERVO1_PIN PB7
#define SERVO2_PIN PB8
#define SERVO3_PIN PB9 // Needs timer 4 for Servo library
Expand Down
2 changes: 1 addition & 1 deletion examples/SpeedTest/PinDefinitionsAndMore.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
#elif defined(STM32F1xx) || defined(__STM32F1__)
// BluePill in 2 flavors
// STM32F1xx is for "Generic STM32F1 series / STM32:stm32" from STM32 Boards from STM32 cores of Arduino Board manager
// __STM32F1__is for "Generic STM32F103C series / stm32duino:STM32F1" from STM32F1 Boards (STM32duino.com) of manual installed hardware folder
// __STM32F1__is for "Generic STM32F103C series / stm32duino:STM32F1" from STM32F1 Boards (STM32duino.com) of Arduino Board manager
#define SERVO1_PIN PB7
#define SERVO2_PIN PB8
#define SERVO3_PIN PB9 // Needs timer 4 for Servo library
Expand Down
2 changes: 1 addition & 1 deletion examples/SymmetricEasing/PinDefinitionsAndMore.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
#elif defined(STM32F1xx) || defined(__STM32F1__)
// BluePill in 2 flavors
// STM32F1xx is for "Generic STM32F1 series / STM32:stm32" from STM32 Boards from STM32 cores of Arduino Board manager
// __STM32F1__is for "Generic STM32F103C series / stm32duino:STM32F1" from STM32F1 Boards (STM32duino.com) of manual installed hardware folder
// __STM32F1__is for "Generic STM32F103C series / stm32duino:STM32F1" from STM32F1 Boards (STM32duino.com) of Arduino Board manager
#define SERVO1_PIN PB7
#define SERVO2_PIN PB8
#define SERVO3_PIN PB9 // Needs timer 4 for Servo library
Expand Down
2 changes: 1 addition & 1 deletion examples/ThreeServos/PinDefinitionsAndMore.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
#elif defined(STM32F1xx) || defined(__STM32F1__)
// BluePill in 2 flavors
// STM32F1xx is for "Generic STM32F1 series / STM32:stm32" from STM32 Boards from STM32 cores of Arduino Board manager
// __STM32F1__is for "Generic STM32F103C series / stm32duino:STM32F1" from STM32F1 Boards (STM32duino.com) of manual installed hardware folder
// __STM32F1__is for "Generic STM32F103C series / stm32duino:STM32F1" from STM32F1 Boards (STM32duino.com) of Arduino Board manager
#define SERVO1_PIN PB7
#define SERVO2_PIN PB8
#define SERVO3_PIN PB9 // Needs timer 4 for Servo library
Expand Down
2 changes: 1 addition & 1 deletion examples/TwoServos/PinDefinitionsAndMore.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
#elif defined(STM32F1xx) || defined(__STM32F1__)
// BluePill in 2 flavors
// STM32F1xx is for "Generic STM32F1 series / STM32:stm32" from STM32 Boards from STM32 cores of Arduino Board manager
// __STM32F1__is for "Generic STM32F103C series / stm32duino:STM32F1" from STM32F1 Boards (STM32duino.com) of manual installed hardware folder
// __STM32F1__is for "Generic STM32F103C series / stm32duino:STM32F1" from STM32F1 Boards (STM32duino.com) of Arduino Board manager
#define SERVO1_PIN PB7
#define SERVO2_PIN PB8
#define SERVO3_PIN PB9 // Needs timer 4 for Servo library
Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"type": "git",
"url": "https://github.com/ArminJo/ServoEasing"
},
"version": "2.3.0",
"version": "2.3.1",
"exclude": "pictures",
"authors": {
"name": "Armin Joachimsmeyer",
Expand Down
4 changes: 2 additions & 2 deletions library.properties
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name=ServoEasing
version=2.3.0
version=2.3.1
author=Armin Joachimsmeyer
maintainer=Armin Joachimsmeyer <[email protected]>
sentence=Enables smooth servo movement. <br/>Linear as well as other (Cubic, Circular, Bounce, etc.) ease movements for servos are provided. The Arduino Servo library or PCA9685 servo expanders are supported.<br/>
paragraph=Just use <b>myServo.easeTo()</b> instead of <b>myServo.write()</b> and you have smooth servo movement.<br/><b>Non blocking</b> movement for all servos attached to the Arduino Servo library is implemented by reusing the interrupts of the Arduino servo timer.<br/><b>All servos can move synchronized.</b><br/><br/>Includes the following <b>easing functions</b>:<ul><li><b>Linear</b>, <b>Quadratic</b>, <b>Cubic</b> and <b>Quartic</b></li><li><b>Sine</b>, <b>Circular</b>, <b>Back</b>, <b>Elastic</b> and <b>Bounce</b></li><li><b>User defined</b></li></ul>Each function supports the <b>easing types</b> <b>In</b>, <b>Out</b>, <b>InOut</b> and <b>BouncingOutIn</b><br/>Trim and reverse operations are supported as well as continuous rotating servos.<br/><br/><b>Requests for enhancements are welcome!</b><br/><br/><b>New: </b>Fixed 32 bit CPU bug for linear movement. Added stop(), continueWithInterrupts() and continueWithoutInterrupts() functions<br/>
paragraph=Just use <b>myServo.easeTo()</b> instead of <b>myServo.write()</b> and you have smooth servo movement.<br/><b>Non blocking</b> movement for all servos attached to the Arduino Servo library is implemented by reusing the interrupts of the Arduino servo timer.<br/><b>All servos can move synchronized.</b><br/><br/>Includes the following <b>easing functions</b>:<ul><li><b>Linear</b>, <b>Quadratic</b>, <b>Cubic</b> and <b>Quartic</b></li><li><b>Sine</b>, <b>Circular</b>, <b>Back</b>, <b>Elastic</b> and <b>Bounce</b></li><li><b>User defined</b></li></ul>Each function supports the <b>easing types</b> <b>In</b>, <b>Out</b>, <b>InOut</b> and <b>BouncingOutIn</b><br/>Trim and reverse operations are supported as well as continuous rotating servos.<br/><br/><b>Requests for enhancements are welcome!</b><br/><br/><b>New: </b>Fixed wrong timer selection for STM32F1xx / ARDUINO_ARCH_STM32.<br/>
category=Device Control
url=https://github.com/ArminJo/ServoEasing
includes=ServoEasing.h
Expand Down
Loading

0 comments on commit e6b834e

Please sign in to comment.