Skip to content

Commit 4a641e9

Browse files
committed
Version 3.2.0
1 parent ace416b commit 4a641e9

File tree

21 files changed

+448
-393
lines changed

21 files changed

+448
-393
lines changed

README.md

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -108,22 +108,22 @@ For instructions how to enable these alternatives, see [Compile options / macros
108108

109109

110110
### All easing functions can be used in the following variants:
111-
All ease functions are called internally with the value: `PercentageOfCompletion / 100` resulting in values from 0 and 1.
111+
All ease functions are called internally with the value: `PercentageOfCompletion / 100` giving a call value from 0 to 1.
112112

113-
- In (start the function with 0 and go to 1) for PRECISION, do a bounce if approaching from above (go in to origin), else linear.
114-
- Out (start the function with 1 and go to 0) for PRECISION, do a bounce if approaching from below (go out from origin), else linear.
115-
- InOut (start the function with 0 go to 1 and back to 0)
116-
- Bouncing (start with OUT, then return with IN to start degree) e.g. Bouncing of the Sine function results in the upper (positive) half of the sine.
113+
- In: Start the function with 0 and go to 1 linear. Except for PRECISION, where we do a bounce if approaching from above (go in to origin).
114+
- Out: Start the function with 1 and go to 0 linear. Except for PRECISION, where we do a bounce if approaching from below (go out from origin).
115+
- InOut: Start the function with 0 go to 1 and back to 0.
116+
- Bouncing: Start with OUT, then return with IN to start degree. E.g. Bouncing of the SINE function results in the upper (positive) half of the sine.
117117

118-
All easing types (starting in flavor IN_OUT, then IN, OUT and BOUNCE) in one plot.<br/>
118+
#### All easing types (starting in flavor IN_OUT, then IN, OUT and BOUNCE) in one plot.<br/>
119119
Since the values are computed in a fixed 20 ms raster, the last degree increment or decrement
120120
in an easing may be much smaller than the increment/decrement before,
121121
resulting in some small discontinuities between adjacent movements.<br/>
122122
![Arduino Plotter Output for Linear->Quadratic->Cubic->Quartic->Sine-Circular->Back->Elastic](https://github.com/ArminJo/ServoEasing/blob/master/pictures/NonlinearMovements.png)
123123

124124
### Constraints
125125
To restrict servo movements to a fixed range, you can specify constraints with `setMinMaxConstraint(int aMinDegreeOrMicrosecond, int aMaxDegreeOrMicrosecond)`.<br/>
126-
Arduino Plotter Output with constraints at 5 degree and 175 degree activated.
126+
#### Arduino Plotter Output with constraints at 5 degree and 175 degree activated.
127127
![Arduino Plotter Output with constraints at 5 degree and 175 degree activated](https://github.com/ArminJo/ServoEasing/blob/master/pictures/Constraints.png)
128128

129129
### Disable easing temporarily
@@ -160,7 +160,7 @@ Just call `myServo.startEaseTo()` instead of `myServo.write()` and you are done.
160160
<br/>
161161

162162
# Multiple servo handling
163-
You can handle multiple servos simultaneously by [special functions](https://github.com/ArminJo/ServoEasing/blob/master/src/ServoEasing.h#L667) like
163+
You can handle multiple servos simultaneously by [special functions](https://github.com/ArminJo/ServoEasing/blob/master/src/ServoEasing.h#L674) like
164164
`writeAllServos()`, `setSpeedForAllServos()`, `setDegreeForAllServos()`, `setEaseToDForAllServos()`, `updateAndWaitForAllServosToStop()`, `setEaseToForAllServosSynchronizeAndWaitForAllServosToStop()`, `setEaseToForAllServosSynchronizeAndStartInterrupt()` and much more.<br/>
165165
[See below](https://github.com/ArminJo/ServoEasing#handling-multiple-servos-with-the-internal-servoeasingarray).
166166

@@ -175,7 +175,7 @@ You can handle multiple servos simultaneously by [special functions](https://git
175175
# Useful resources
176176
- [Easings Cheat Sheet](https://easings.net/)
177177
- [Robert Penner](http://www.robertpenner.com/easing/)
178-
- [C functions on Github](https://github.com/warrenm/AHEasing/blob/master/AHEasing/easing.c)
178+
- [Easing C functions on Github](https://github.com/warrenm/AHEasing/blob/master/AHEasing/easing.c)
179179
- [Interactive cubic-bezier](http://cubic-bezier.com)
180180
- Servo signal gif from https://workshop.pglu.ch/arduino-servo/
181181
[![Servo signal gif from https://workshop.pglu.ch/arduino-servo/](pictures/ServoFunktion_workshop.pglu.ch.gif)](https://workshop.pglu.ch/arduino-servo/)
@@ -271,7 +271,7 @@ Modify them by enabling / disabling them, or change the values if applicable.
271271
| `PROVIDE_ONLY_LINEAR_MOVEMENT` | disabled | Disables all but LINEAR movement. Saves up to 1540 bytes program memory. |
272272
| `DISABLE_COMPLEX_FUNCTIONS` | disabled | Disables the SINE, CIRCULAR, BACK, ELASTIC, BOUNCE and PRECISION easings. Saves up to 1850 bytes program memory. |
273273
| `MAX_EASING_SERVOS` | 12, 16(for PCA9685) | Saves 4 byte RAM per servo. If this value is smaller than the amount of servos declared, attach() will return error and other library functions will not work as expected.<br/>Of course all *AllServos*() functions and isOneServoMoving() can't work correctly! |
274-
| `DISABLE_MICROS_AS_DEGREE_PARAMETER` | disabled | Disables passing also microsecond values as (target angle) parameter (see [OneServo example](https://github.com/ArminJo/ServoEasing/blob/master/examples/OneServo/OneServo.ino#L93)). Saves up to 128 bytes program memory. |
274+
| `DISABLE_MICROS_AS_DEGREE_PARAMETER` | disabled | Disables passing also microsecond values as (target angle) parameter. Saves up to 128 bytes program memory. |
275275
| `DISABLE_MIN_AND_MAX_CONSTRAINTS` | disabled | Disables servo movement constraints. Saves 4 bytes RAM per servo but strangely enough no program memory. |
276276
| `DISABLE_PAUSE_RESUME` | disabled | Disables pause and resume functionality. Saves 5 bytes RAM per servo. |
277277
| `PRINT_FOR_SERIAL_PLOTTER` | disabled | Generate serial output for Arduino Plotter (Ctrl-Shift-L). |
@@ -281,7 +281,7 @@ Modify them by enabling / disabling them, or change the values if applicable.
281281
<br/>
282282

283283
# Using PCA9685 16-Channel Servo Expander
284-
Using the expander makes the servo pulse generating immune to other libraries blocking interrupts for a longer time like SoftwareSerial, Adafruit_NeoPixel and DmxSimple.<br/>
284+
Using the PCA9685 expander makes the servo pulse generating immune to other libraries blocking interrupts for a longer time like SoftwareSerial, Adafruit_NeoPixel and DmxSimple.<br/>
285285
To enable the use of the expander, activate [the line `#define USE_PCA9685_SERVO_EXPANDER`](https://github.com/ArminJo/ServoEasing/blob/master/examples/OneServo/OneServo.ino#L28) before `#include <ServoEasing.hpp>`.<br/>
286286
In expander mode, timer1 is only required for the startEaseTo* functions and not for the blocking easeTo* functions, since no servo signal must be generated by it.
287287

@@ -316,14 +316,14 @@ The ServoEasing library provides two arrays to ease the handling of multiple ser
316316

317317
Every ServoEasing object is appended to the ServoEasingArray by the attach() function.
318318
**Only the order of the attach() statements determines the position in the array.**
319-
So you can access your servo, which you attached secondly, also by `ServoEasing::ServoEasingArray[1]->setEaseTo(135)` as it is done [here](https://github.com/ArminJo/ServoEasing/blob/master/examples/ThreeServos/ThreeServos.ino#L144).<br/>
319+
So you can access your servo, which you attached secondly, also by `ServoEasing::ServoEasingArray[1]->setEaseTo(135)` as it is done [here](https://github.com/ArminJo/ServoEasing/blob/master/examples/ThreeServos/ThreeServos.ino#L149).<br/>
320320
There are also many other `*AllServos*` functions like `stopAllServos()`.
321321

322322
To move multiple servo, you can fill up the `ServoEasing::ServoEasingNextPositionArray` with the desired positions and then use e.g. the function `setEaseToForAllServos()`.
323323
Then you must enable interrupt with `enableServoEasingInterrupt()` or call `updateAllServos()` in your main loop until it returns true.<br/>
324324
If you want to move all your servos synchronized, i.e. they all stop at the same time,
325325
you can use the `setEaseToForAllServosSynchronizeAndWaitForAllServosToStop()` or `setEaseToForAllServosSynchronizeAndStartInterrupt` function.<br/>
326-
An example can be found [here](https://github.com/ArminJo/ServoEasing/blob/master/examples/ThreeServos/ThreeServos.ino#L162).<br/>
326+
An example can be found [here](https://github.com/ArminJo/ServoEasing/blob/master/examples/ThreeServos/ThreeServos.ino#L174).<br/>
327327
The [Quadruped example](https://github.com/ArminJo/ServoEasing/blob/master/examples/QuadrupedControl/QuadrupedServoControl.hpp#L32) makes heavy use of the `*AllServos*` functions.
328328

329329
If you **detach** a servo and then attach another one, the latter will get the index of the former detached one.
@@ -357,7 +357,7 @@ The API accepts degrees or microseconds as float or integer values, but internal
357357

358358
# Supported Arduino architectures
359359
**Every Arduino architecture with a Servo library** will work without any modifications in blocking mode.<br/>
360-
Non blocking behavior can always be achieved manually by calling `update()` in a loop - see last movement in [Simple example](examples/Simple/Simple.ino).<br/>
360+
Non blocking behavior can always be achieved manually by calling `update()` or `updateAllServos()` in a loop - see [ThreeServos example](examples/ThreeServos/ThreeServos.ino#L153).<br/>
361361
Interrupt based movement (movement without calling `update()` manually in a loop) is supported for the following Arduino architectures:<br/>
362362
**avr, megaavr, sam, samd, esp8266, esp32, stm32, STM32F1 and apollo3.**<br/>
363363
**It is not planned to support the ATtiny architecture, but you are invited to [do it by yourself](https://github.com/ArminJo/ServoEasing#adding-a-new-platform--board) and send a pull request.**
@@ -379,7 +379,7 @@ On **AVR** Timer1 is used for the Arduino Servo library. To have non blocking ea
379379
| Teensy | | IntervalTimer |
380380
| apollo3 | timer 3 segment A | |
381381
| Mbed | mbed::Ticker | Ticker.h |
382-
| [RP2040 / Pi Pico](https://github.com/earlephilhower/arduino-pico | [default alarm pool](https://raspberrypi.github.io/pico-sdk-doxygen/group__repeating__timer.html) | time.h |
382+
| [RP2040 / Pi Pico](https://github.com/earlephilhower/arduino-pico) | [default alarm pool](https://raspberrypi.github.io/pico-sdk-doxygen/group__repeating__timer.html) | time.h |
383383

384384
<br/>
385385

@@ -404,7 +404,8 @@ This will print internal information visible in the Arduino *Serial Monitor* whi
404404
<br/>
405405

406406
# Revision History
407-
### Version 3.1.1
407+
### Version 3.2.0
408+
- ATmega4808 support added.
408409
- Added function `getCurrentMicroseconds()`.
409410
- Improved many and added workaround for ESP32 bug in while loops in examples.
410411
- Added `PCA9685_ACTUAL_CLOCK_FREQUENCY` macro.

examples/EndPositionsTest/ADCUtils.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -137,23 +137,23 @@ uint8_t checkAndWaitForReferenceAndChannelToSwitch(uint8_t aChannelNumber, uint8
137137
/*
138138
* readVCC*() functions store the result in sVCCVoltageMillivolt or sVCCVoltage
139139
*/
140-
float getVCCVoltageSimple();
141-
void readVCCVoltageSimple();
142-
uint16_t getVCCVoltageMillivoltSimple();
143-
void readVCCVoltageMillivoltSimple();
144-
float getVCCVoltage();
145-
void readVCCVoltage();
146-
uint16_t getVCCVoltageMillivolt();
147-
void readVCCVoltageMillivolt();
148-
uint16_t getVCCVoltageReadingFor1_1VoltReference();
140+
float getVCCVoltageSimple(void);
141+
void readVCCVoltageSimple(void);
142+
uint16_t getVCCVoltageMillivoltSimple(void);
143+
void readVCCVoltageMillivoltSimple(void);
144+
float getVCCVoltage(void);
145+
void readVCCVoltage(void);
146+
uint16_t getVCCVoltageMillivolt(void);
147+
void readVCCVoltageMillivolt(void);
148+
uint16_t getVCCVoltageReadingFor1_1VoltReference(void);
149149
uint16_t printVCCVoltageMillivolt(Print *aSerial);
150150
void readAndPrintVCCVoltageMillivolt(Print *aSerial);
151151

152152
uint16_t getVoltageMillivolt(uint16_t aVCCVoltageMillivolt, uint8_t aADCChannelForVoltageMeasurement);
153153
uint16_t getVoltageMillivolt(uint8_t aADCChannelForVoltageMeasurement);
154154
uint16_t getVoltageMillivoltWith_1_1VoltReference(uint8_t aADCChannelForVoltageMeasurement);
155-
float getTemperatureSimple();
156-
float getTemperature();
155+
float getTemperatureSimple(void);
156+
float getTemperature(void);
157157

158158
bool isVCCTooLowMultipleTimes();
159159
void resetVCCTooLowMultipleTimes();

examples/EndPositionsTest/ADCUtils.hpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ uint16_t readUntil4ConsecutiveValuesAreEqual(uint8_t aChannelNumber, uint8_t aDe
362362
* Use it ONLY if you only call getVCCVoltageSimple() or getVCCVoltageMillivoltSimple() in your program.
363363
* !!! Resolution is only 20 millivolt !!!
364364
*/
365-
float getVCCVoltageSimple() {
365+
float getVCCVoltageSimple(void) {
366366
// use AVCC with (optional) external capacitor at AREF pin as reference
367367
float tVCC = readADCChannelWithReferenceMultiSamples(ADC_1_1_VOLT_CHANNEL_MUX, DEFAULT, 4);
368368
return ((1023 * 1.1 * 4) / tVCC);
@@ -373,7 +373,7 @@ float getVCCVoltageSimple() {
373373
* Use it ONLY if you only call getVCCVoltageSimple() or getVCCVoltageMillivoltSimple() in your program.
374374
* !!! Resolution is only 20 millivolt !!!
375375
*/
376-
uint16_t getVCCVoltageMillivoltSimple() {
376+
uint16_t getVCCVoltageMillivoltSimple(void) {
377377
// use AVCC with external capacitor at AREF pin as reference
378378
uint16_t tVCC = readADCChannelWithReferenceMultiSamples(ADC_1_1_VOLT_CHANNEL_MUX, DEFAULT, 4);
379379
return ((1023L * ADC_INTERNAL_REFERENCE_MILLIVOLT * 4) / tVCC);
@@ -383,7 +383,7 @@ uint16_t getVCCVoltageMillivoltSimple() {
383383
* Gets the hypothetical 14 bit reading of VCC using 1.1 volt reference
384384
* Similar to getVCCVoltageMillivolt() * 1023 / 1100
385385
*/
386-
uint16_t getVCCVoltageReadingFor1_1VoltReference() {
386+
uint16_t getVCCVoltageReadingFor1_1VoltReference(void) {
387387
uint16_t tVCC = waitAndReadADCChannelWithReference(ADC_1_1_VOLT_CHANNEL_MUX, DEFAULT); // 225 for 1.1 V at 5 V VCC
388388
/*
389389
* Do not switch back ADMUX to enable checkAndWaitForReferenceAndChannelToSwitch() to work correctly for the next measurement
@@ -394,7 +394,7 @@ uint16_t getVCCVoltageReadingFor1_1VoltReference() {
394394
/*
395395
* !!! Resolution is only 20 millivolt !!!
396396
*/
397-
float getVCCVoltage() {
397+
float getVCCVoltage(void) {
398398
return (getVCCVoltageMillivolt() / 1000.0);
399399
}
400400

@@ -403,7 +403,7 @@ float getVCCVoltage() {
403403
* Handles reference and channel switching by introducing the appropriate delays.
404404
* !!! Resolution is only 20 millivolt !!!
405405
*/
406-
uint16_t getVCCVoltageMillivolt() {
406+
uint16_t getVCCVoltageMillivolt(void) {
407407
uint16_t tVCC = waitAndReadADCChannelWithReference(ADC_1_1_VOLT_CHANNEL_MUX, DEFAULT);
408408
/*
409409
* Do not switch back ADMUX to enable checkAndWaitForReferenceAndChannelToSwitch() to work correctly for the next measurement
@@ -430,7 +430,7 @@ void readAndPrintVCCVoltageMillivolt(Print *aSerial) {
430430
* Use it ONLY if you only call getVCCVoltageSimple() or getVCCVoltageMillivoltSimple() in your program.
431431
* !!! Resolution is only 20 millivolt !!!
432432
*/
433-
void readVCCVoltageSimple() {
433+
void readVCCVoltageSimple(void) {
434434
// use AVCC with (optional) external capacitor at AREF pin as reference
435435
float tVCC = readADCChannelWithReferenceMultiSamples(ADC_1_1_VOLT_CHANNEL_MUX, DEFAULT, 4);
436436
sVCCVoltage = (1023 * 1.1 * 4) / tVCC;
@@ -441,7 +441,7 @@ void readVCCVoltageSimple() {
441441
* Use it ONLY if you only call getVCCVoltageSimple() or getVCCVoltageMillivoltSimple() in your program.
442442
* !!! Resolution is only 20 millivolt !!!
443443
*/
444-
void readVCCVoltageMillivoltSimple() {
444+
void readVCCVoltageMillivoltSimple(void) {
445445
// use AVCC with external capacitor at AREF pin as reference
446446
uint16_t tVCCVoltageMillivoltRaw = readADCChannelWithReferenceMultiSamples(ADC_1_1_VOLT_CHANNEL_MUX, DEFAULT, 4);
447447
sVCCVoltageMillivolt = (1023L * ADC_INTERNAL_REFERENCE_MILLIVOLT * 4) / tVCCVoltageMillivoltRaw;
@@ -450,7 +450,7 @@ void readVCCVoltageMillivoltSimple() {
450450
/*
451451
* !!! Resolution is only 20 millivolt !!!
452452
*/
453-
void readVCCVoltage() {
453+
void readVCCVoltage(void) {
454454
sVCCVoltage = getVCCVoltageMillivolt() / 1000.0;
455455
}
456456

@@ -460,7 +460,7 @@ void readVCCVoltage() {
460460
* !!! Resolution is only 20 millivolt !!!
461461
* Sets also the sVCCVoltageMillivolt variable.
462462
*/
463-
void readVCCVoltageMillivolt() {
463+
void readVCCVoltageMillivolt(void) {
464464
uint16_t tVCCVoltageMillivoltRaw = waitAndReadADCChannelWithReference(ADC_1_1_VOLT_CHANNEL_MUX, DEFAULT);
465465
/*
466466
* Do not switch back ADMUX to enable checkAndWaitForReferenceAndChannelToSwitch() to work correctly for the next measurement
@@ -574,7 +574,7 @@ bool isVoltageTooLow(){
574574
* !!! Function without handling of switched reference and channel.!!!
575575
* Use it ONLY if you only use INTERNAL reference (call getTemperatureSimple()) in your program.
576576
*/
577-
float getTemperatureSimple() {
577+
float getTemperatureSimple(void) {
578578
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
579579
return 0.0;
580580
#else
@@ -587,7 +587,7 @@ float getTemperatureSimple() {
587587
/*
588588
* Handles reference and channel switching by introducing the appropriate delays.
589589
*/
590-
float getTemperature() {
590+
float getTemperature(void) {
591591
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
592592
return 0.0;
593593
#else

examples/OneServo/OneServo.ino

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ void loop() {
236236
#if !defined(DISABLE_PAUSE_RESUME)
237237
# if !defined(PRINT_FOR_SERIAL_PLOTTER)
238238
Serial.println(F("Interrupt movement with pause() for 1 second at 90 degree"));
239-
#endif
239+
# endif
240240
/*
241241
* Demonstrate pause and resume in the middle of a movement
242242
*/
@@ -247,6 +247,10 @@ void loop() {
247247
#endif
248248
while (Servo1.isMoving()); // wait for servo to stop
249249

250+
# if !defined(PRINT_FOR_SERIAL_PLOTTER)
251+
Serial.println(F("Detach the servo for 5 seconds. During this time you can move the servo manually."));
252+
# endif
253+
250254
Servo1.detach();
251255
/*
252256
* After detach the servo is "not powered" for 5 seconds, i.e. no servo signal is generated.

examples/QuadrupedControl/ADCUtils.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -137,23 +137,23 @@ uint8_t checkAndWaitForReferenceAndChannelToSwitch(uint8_t aChannelNumber, uint8
137137
/*
138138
* readVCC*() functions store the result in sVCCVoltageMillivolt or sVCCVoltage
139139
*/
140-
float getVCCVoltageSimple();
141-
void readVCCVoltageSimple();
142-
uint16_t getVCCVoltageMillivoltSimple();
143-
void readVCCVoltageMillivoltSimple();
144-
float getVCCVoltage();
145-
void readVCCVoltage();
146-
uint16_t getVCCVoltageMillivolt();
147-
void readVCCVoltageMillivolt();
148-
uint16_t getVCCVoltageReadingFor1_1VoltReference();
140+
float getVCCVoltageSimple(void);
141+
void readVCCVoltageSimple(void);
142+
uint16_t getVCCVoltageMillivoltSimple(void);
143+
void readVCCVoltageMillivoltSimple(void);
144+
float getVCCVoltage(void);
145+
void readVCCVoltage(void);
146+
uint16_t getVCCVoltageMillivolt(void);
147+
void readVCCVoltageMillivolt(void);
148+
uint16_t getVCCVoltageReadingFor1_1VoltReference(void);
149149
uint16_t printVCCVoltageMillivolt(Print *aSerial);
150150
void readAndPrintVCCVoltageMillivolt(Print *aSerial);
151151

152152
uint16_t getVoltageMillivolt(uint16_t aVCCVoltageMillivolt, uint8_t aADCChannelForVoltageMeasurement);
153153
uint16_t getVoltageMillivolt(uint8_t aADCChannelForVoltageMeasurement);
154154
uint16_t getVoltageMillivoltWith_1_1VoltReference(uint8_t aADCChannelForVoltageMeasurement);
155-
float getTemperatureSimple();
156-
float getTemperature();
155+
float getTemperatureSimple(void);
156+
float getTemperature(void);
157157

158158
bool isVCCTooLowMultipleTimes();
159159
void resetVCCTooLowMultipleTimes();

0 commit comments

Comments
 (0)