ServoEasing
|
#include <Servo.h>
#include <stdarg.h>
Go to the source code of this file.
Classes | |
class | ServoEasing |
Functions | |
void | writeAllServos (int aTargetDegreeOrMicrosecond) |
void | setSpeedForAllServos (uint_fast16_t aDegreesPerSecond) |
bool | setEaseToForAllServos () |
Sets target position using content of ServoEasingNextPositionArray. More... | |
bool | setEaseToForAllServos (uint_fast16_t aDegreesPerSecond) |
Sets target position using content of ServoEasingNextPositionArray and use aDegreesPerSecond instead of the one stored in mSpeed. More... | |
bool | setEaseToDForAllServos (uint_fast16_t aMillisForMove) |
Sets target position using content of ServoEasingNextPositionArray and use aMillisForMove instead of the speed stored in mSpeed. More... | |
void | setEaseToForAllServosSynchronizeAndStartInterrupt () |
void | setEaseToForAllServosSynchronizeAndStartInterrupt (uint_fast16_t aDegreesPerSecond) |
void | synchronizeAllServosAndStartInterrupt (bool aStartUpdateByInterrupt=START_UPDATE_BY_INTERRUPT) |
Take the longer duration in order to move all servos synchronously. More... | |
void | setEasingTypeForAllServos (uint_fast8_t aEasingType) |
60 us for single servo + 160 us per servo if using I2C e.g.for PCA9685 expander at 400 kHz or + 100 at 800 kHz 20 us for last interrupt The first servo pulse starts just after this interrupt routine has finished More... | |
void | setEasingTypeForMultipleServos (uint_fast8_t aNumberOfServos, uint_fast8_t aEasingType) |
Sets easing type aEasingType for the first aNumberOfServos in ServoEasingArray[]. More... | |
void | updateAndWaitForAllServosToStop () |
Blocking wait until all servos are stopped. More... | |
bool | delayAndUpdateAndWaitForAllServosToStop (unsigned long aMillisDelay, bool aTerminateDelayIfAllServosStopped=false) |
void | setEaseToForAllServosSynchronizeAndWaitForAllServosToStop () |
Synchronize and blocking wait until all servos are stopped. More... | |
void | setEaseToForAllServosSynchronizeAndWaitForAllServosToStop (uint_fast16_t aDegreesPerSecond) |
void | synchronizeAndEaseToArrayPositions () __attribute__((deprecated("Please use setEaseToForAllServosSynchronizeAndWait()."))) |
void | synchronizeAndEaseToArrayPositions (uint_fast16_t aDegreesPerSecond) __attribute__((deprecated("Please use setEaseToForAllServosSynchronizeAndWait()."))) |
void | synchronizeAllServosStartAndWaitForAllServosToStop () |
Synchronize and blocking wait until all servos are stopped. More... | |
void | printArrayPositions (Print *aSerial) |
Prints content of ServoNextPositionArray for debugging purposes. More... | |
bool | isOneServoMoving () |
void | stopAllServos () |
void | resumeWithInterruptsAllServos () |
void | resumeWithoutInterruptsAllServos () |
bool | updateAllServos () |
void | enableServoEasingInterrupt () |
Timer1 is used for the Arduino Servo library. More... | |
void | disableServoEasingInterrupt () |
int | clipDegreeSpecial (uint_fast8_t aDegreeToClip) |
Clips the unsigned degree value and handles unsigned underflow. More... | |
bool | checkI2CConnection (uint8_t aI2CAddress, Stream *aSerial) |
Variables | |
const char easeTypeLinear[] | PROGMEM |
#define areInterruptsActive | ( | ) | ServoEasing::areInterruptsActive() |
Definition at line 669 of file ServoEasing.h.
#define CALL_STYLE_BOUNCING_OUT_IN 0xC0 |
Definition at line 292 of file ServoEasing.h.
#define CALL_STYLE_DIRECT 0x00 |
Definition at line 288 of file ServoEasing.h.
#define CALL_STYLE_IN 0x00 |
Definition at line 289 of file ServoEasing.h.
#define CALL_STYLE_IN_OUT 0x80 |
Definition at line 291 of file ServoEasing.h.
#define CALL_STYLE_MASK 0xC0 |
Definition at line 294 of file ServoEasing.h.
#define CALL_STYLE_OUT 0x40 |
Definition at line 290 of file ServoEasing.h.
#define DEFAULT_MICROSECONDS_FOR_0_DEGREE 544 |
Definition at line 209 of file ServoEasing.h.
#define DEFAULT_MICROSECONDS_FOR_135_DEGREE (2400 - ((2400 - 544) / 4)) |
Definition at line 212 of file ServoEasing.h.
#define DEFAULT_MICROSECONDS_FOR_180_DEGREE 2400 |
Definition at line 213 of file ServoEasing.h.
#define DEFAULT_MICROSECONDS_FOR_45_DEGREE (544 + ((2400 - 544) / 4)) |
Definition at line 210 of file ServoEasing.h.
#define DEFAULT_MICROSECONDS_FOR_90_DEGREE (544 + ((2400 - 544) / 2)) |
Definition at line 211 of file ServoEasing.h.
#define DEFAULT_PCA9685_UNITS_FOR_0_DEGREE 111 |
Definition at line 216 of file ServoEasing.h.
#define DEFAULT_PCA9685_UNITS_FOR_135_DEGREE (491 - ((491 - 111) / 4)) |
Definition at line 219 of file ServoEasing.h.
#define DEFAULT_PCA9685_UNITS_FOR_180_DEGREE 491 |
Definition at line 220 of file ServoEasing.h.
#define DEFAULT_PCA9685_UNITS_FOR_45_DEGREE (111 + ((491 - 111) / 4)) |
Definition at line 217 of file ServoEasing.h.
#define DEFAULT_PCA9685_UNITS_FOR_90_DEGREE (111 + ((491 - 111) / 2)) |
Definition at line 218 of file ServoEasing.h.
#define DEFAULT_PULSE_WIDTH 1500 |
Definition at line 163 of file ServoEasing.h.
#define DO_NOT_START_UPDATE_BY_INTERRUPT false |
Definition at line 410 of file ServoEasing.h.
#define EASE_BACK_BOUNCING 0xCA |
Definition at line 348 of file ServoEasing.h.
#define EASE_BACK_IN 0x0A |
Definition at line 345 of file ServoEasing.h.
#define EASE_BACK_IN_OUT 0x8A |
Definition at line 347 of file ServoEasing.h.
#define EASE_BACK_OUT 0x4A |
Definition at line 346 of file ServoEasing.h.
#define EASE_BOUNCE_IN 0x4C |
Definition at line 360 of file ServoEasing.h.
#define EASE_BOUNCE_OUT 0x0C |
Definition at line 361 of file ServoEasing.h.
#define EASE_CIRCULAR_BOUNCING 0xC9 |
Definition at line 341 of file ServoEasing.h.
#define EASE_CIRCULAR_IN 0x09 |
Definition at line 338 of file ServoEasing.h.
#define EASE_CIRCULAR_IN_OUT 0x89 |
Definition at line 340 of file ServoEasing.h.
#define EASE_CIRCULAR_OUT 0x49 |
Definition at line 339 of file ServoEasing.h.
#define EASE_CUBIC_BOUNCING 0xC2 |
Definition at line 310 of file ServoEasing.h.
#define EASE_CUBIC_IN 0x02 |
Definition at line 307 of file ServoEasing.h.
#define EASE_CUBIC_IN_OUT 0x82 |
Definition at line 309 of file ServoEasing.h.
#define EASE_CUBIC_OUT 0x42 |
Definition at line 308 of file ServoEasing.h.
#define EASE_DUMMY_MOVE 0x07 |
Definition at line 328 of file ServoEasing.h.
#define EASE_ELASTIC_BOUNCING 0xCB |
Definition at line 355 of file ServoEasing.h.
#define EASE_ELASTIC_IN 0x0B |
Definition at line 352 of file ServoEasing.h.
#define EASE_ELASTIC_IN_OUT 0x8B |
Definition at line 354 of file ServoEasing.h.
#define EASE_ELASTIC_OUT 0x4B |
Definition at line 353 of file ServoEasing.h.
#define EASE_FUNCTION_DEGREE_INDICATOR_OFFSET 200 |
Definition at line 280 of file ServoEasing.h.
#define EASE_FUNCTION_DEGREE_THRESHOLD (EASE_FUNCTION_DEGREE_INDICATOR_OFFSET - 180) |
Definition at line 281 of file ServoEasing.h.
#define EASE_FUNCTION_MICROSECONDS_INDICATOR_OFFSET (EASE_FUNCTION_DEGREE_INDICATOR_OFFSET + 200) |
Definition at line 282 of file ServoEasing.h.
#define EASE_LINEAR 0x00 |
Definition at line 297 of file ServoEasing.h.
#define EASE_PRECISION_IN 0x0D |
Definition at line 365 of file ServoEasing.h.
#define EASE_PRECISION_OUT 0x4D |
Definition at line 366 of file ServoEasing.h.
#define EASE_QUADRATIC_BOUNCING 0xC1 |
Definition at line 303 of file ServoEasing.h.
#define EASE_QUADRATIC_IN 0x01 |
Definition at line 300 of file ServoEasing.h.
#define EASE_QUADRATIC_IN_OUT 0x81 |
Definition at line 302 of file ServoEasing.h.
#define EASE_QUADRATIC_OUT 0x41 |
Definition at line 301 of file ServoEasing.h.
#define EASE_QUARTIC_BOUNCING 0xC3 |
Definition at line 317 of file ServoEasing.h.
#define EASE_QUARTIC_IN 0x03 |
Definition at line 314 of file ServoEasing.h.
#define EASE_QUARTIC_IN_OUT 0x83 |
Definition at line 316 of file ServoEasing.h.
#define EASE_QUARTIC_OUT 0x43 |
Definition at line 315 of file ServoEasing.h.
#define EASE_SINE_BOUNCING 0xC8 |
Definition at line 334 of file ServoEasing.h.
#define EASE_SINE_IN 0x08 |
Definition at line 331 of file ServoEasing.h.
#define EASE_SINE_IN_OUT 0x88 |
Definition at line 333 of file ServoEasing.h.
#define EASE_SINE_OUT 0x48 |
Definition at line 332 of file ServoEasing.h.
#define EASE_TYPE_MASK 0x0F |
Definition at line 295 of file ServoEasing.h.
#define EASE_USER_BOUNCING 0xC6 |
Definition at line 325 of file ServoEasing.h.
#define EASE_USER_DIRECT 0x06 |
Definition at line 321 of file ServoEasing.h.
#define EASE_USER_IN 0x06 |
Definition at line 322 of file ServoEasing.h.
#define EASE_USER_IN_OUT 0x86 |
Definition at line 324 of file ServoEasing.h.
#define EASE_USER_OUT 0x46 |
Definition at line 323 of file ServoEasing.h.
#define ENABLE_EASE_BACK |
Definition at line 256 of file ServoEasing.h.
#define ENABLE_EASE_BOUNCE |
Definition at line 258 of file ServoEasing.h.
#define ENABLE_EASE_CIRCULAR |
Definition at line 255 of file ServoEasing.h.
#define ENABLE_EASE_CUBIC |
Definition at line 250 of file ServoEasing.h.
#define ENABLE_EASE_ELASTIC |
Definition at line 257 of file ServoEasing.h.
#define ENABLE_EASE_PRECISION |
Definition at line 259 of file ServoEasing.h.
#define ENABLE_EASE_QUADRATIC |
Definition at line 249 of file ServoEasing.h.
#define ENABLE_EASE_QUARTIC |
Definition at line 251 of file ServoEasing.h.
#define ENABLE_EASE_SINE |
Definition at line 254 of file ServoEasing.h.
#define ENABLE_EASE_USER |
Definition at line 252 of file ServoEasing.h.
#define INVALID_SERVO 255 |
Definition at line 169 of file ServoEasing.h.
#define MAX_EASING_SERVOS 12 |
Definition at line 158 of file ServoEasing.h.
#define MICROSECONDS_FOR_ROTATING_SERVO_CLOCKWISE_HALF (MICROSECONDS_FOR_ROTATING_SERVO_STOP - 100) |
Definition at line 238 of file ServoEasing.h.
#define MICROSECONDS_FOR_ROTATING_SERVO_CLOCKWISE_MAX (MICROSECONDS_FOR_ROTATING_SERVO_STOP - 200) |
Definition at line 237 of file ServoEasing.h.
#define MICROSECONDS_FOR_ROTATING_SERVO_CLOCKWISE_QUARTER (MICROSECONDS_FOR_ROTATING_SERVO_STOP - 50) |
Definition at line 239 of file ServoEasing.h.
#define MICROSECONDS_FOR_ROTATING_SERVO_COUNTER_CLOCKWISE_HALF (MICROSECONDS_FOR_ROTATING_SERVO_STOP + 100) |
Definition at line 241 of file ServoEasing.h.
#define MICROSECONDS_FOR_ROTATING_SERVO_COUNTER_CLOCKWISE_MAX (MICROSECONDS_FOR_ROTATING_SERVO_STOP + 200) |
Definition at line 240 of file ServoEasing.h.
#define MICROSECONDS_FOR_ROTATING_SERVO_COUNTER_CLOCKWISE_QUARTER (MICROSECONDS_FOR_ROTATING_SERVO_STOP + 50) |
Definition at line 242 of file ServoEasing.h.
#define MICROSECONDS_FOR_ROTATING_SERVO_STOP 1500 |
Definition at line 232 of file ServoEasing.h.
#define MILLIS_IN_ONE_SECOND 1000L |
Definition at line 41 of file ServoEasing.h.
#define PCA9685_ACTUAL_CLOCK_FREQUENCY 25000000L |
Definition at line 403 of file ServoEasing.h.
#define PCA9685_DEFAULT_ADDRESS 0x40 |
Definition at line 393 of file ServoEasing.h.
#define PCA9685_FIRST_PWM_REGISTER 0x06 |
Definition at line 399 of file ServoEasing.h.
#define PCA9685_GENERAL_CALL_ADDRESS 0x00 |
Definition at line 391 of file ServoEasing.h.
#define PCA9685_MAX_CHANNELS 16 |
Definition at line 394 of file ServoEasing.h.
#define PCA9685_MODE1_REGISTER 0x0 |
Definition at line 395 of file ServoEasing.h.
#define PCA9685_MODE_1_AUTOINCREMENT 5 |
Definition at line 397 of file ServoEasing.h.
#define PCA9685_MODE_1_RESTART 7 |
Definition at line 396 of file ServoEasing.h.
#define PCA9685_MODE_1_SLEEP 4 |
Definition at line 398 of file ServoEasing.h.
#define PCA9685_PRESCALE_REGISTER 0xFE |
Definition at line 400 of file ServoEasing.h.
#define PCA9685_PRESCALER_FOR_20_MS ((PCA9685_ACTUAL_CLOCK_FREQUENCY /(4096L * 50)) - 1) |
Definition at line 406 of file ServoEasing.h.
#define PCA9685_SOFTWARE_RESET 6 |
Definition at line 392 of file ServoEasing.h.
#define REFRESH_FREQUENCY (MILLIS_IN_ONE_SECOND/REFRESH_INTERVAL_MILLIS) |
Definition at line 173 of file ServoEasing.h.
#define REFRESH_INTERVAL 20000 |
Definition at line 166 of file ServoEasing.h.
#define REFRESH_INTERVAL_MICROS REFRESH_INTERVAL |
Definition at line 171 of file ServoEasing.h.
#define REFRESH_INTERVAL_MILLIS (REFRESH_INTERVAL/1000) |
Definition at line 172 of file ServoEasing.h.
#define sServoArray ServoEasing::ServoEasingArray |
Definition at line 670 of file ServoEasing.h.
#define sServoNextPositionArray ServoEasing::ServoEasingNextPositionArray |
Definition at line 671 of file ServoEasing.h.
#define START_EASE_TO_SPEED 5 |
Definition at line 46 of file ServoEasing.h.
#define START_UPDATE_BY_INTERRUPT true |
Definition at line 409 of file ServoEasing.h.
#define STR | ( | x | ) | STR_HELPER(x) |
Definition at line 734 of file ServoEasing.h.
#define STR_HELPER | ( | x | ) | #x |
Definition at line 733 of file ServoEasing.h.
#define THRESHOLD_VALUE_FOR_INTERPRETING_VALUE_AS_MICROSECONDS 360 |
Definition at line 199 of file ServoEasing.h.
#define VERSION_HEX_VALUE | ( | major, | |
minor, | |||
patch | |||
) | ((major << 16) | (minor << 8) | (patch)) |
Definition at line 38 of file ServoEasing.h.
#define VERSION_SERVO_EASING "3.2.0" |
Definition at line 28 of file ServoEasing.h.
#define VERSION_SERVO_EASING_HEX VERSION_HEX_VALUE(VERSION_SERVO_EASING_MAJOR, VERSION_SERVO_EASING_MINOR, VERSION_SERVO_EASING_PATCH) |
Definition at line 39 of file ServoEasing.h.
#define VERSION_SERVO_EASING_MAJOR 3 |
Definition at line 29 of file ServoEasing.h.
#define VERSION_SERVO_EASING_MINOR 2 |
Definition at line 30 of file ServoEasing.h.
#define VERSION_SERVO_EASING_PATCH 0 |
Definition at line 31 of file ServoEasing.h.
bool checkI2CConnection | ( | uint8_t | aI2CAddress, |
Stream * | aSerial | ||
) |
int clipDegreeSpecial | ( | uint_fast8_t | aDegreeToClip | ) |
Clips the unsigned degree value and handles unsigned underflow.
Definition at line 1821 of file ServoEasing.hpp.
bool delayAndUpdateAndWaitForAllServosToStop | ( | unsigned long | aMillisDelay, |
bool | aTerminateDelayIfAllServosStopped | ||
) |
aMillisDelay | the milliseconds for blocking wait and update |
aTerminateDelayIfAllServosStopped | if true, function returns before aMillisDelay if all servos are stopped |
Definition at line 2446 of file ServoEasing.hpp.
void disableServoEasingInterrupt | ( | ) |
Definition at line 2072 of file ServoEasing.hpp.
void enableServoEasingInterrupt | ( | ) |
Timer1 is used for the Arduino Servo library.
To have non blocking easing functions its unused channel B is used to generate an interrupt 100 us before the end of the 20 ms Arduino Servo refresh period. This interrupt then updates all servo values for the next refresh period. First interrupt is triggered not directly, but after 20 ms, since we are often called here at the time of the last interrupt of the preceding servo move.
Definition at line 1866 of file ServoEasing.hpp.
bool isOneServoMoving | ( | ) |
Definition at line 2366 of file ServoEasing.hpp.
void printArrayPositions | ( | Print * | aSerial | ) |
Prints content of ServoNextPositionArray for debugging purposes.
aSerial | The Print object on which to write, for Arduino you can use &Serial. |
Definition at line 2251 of file ServoEasing.hpp.
void resumeWithInterruptsAllServos | ( | ) |
Definition at line 2398 of file ServoEasing.hpp.
void resumeWithoutInterruptsAllServos | ( | ) |
Definition at line 2406 of file ServoEasing.hpp.
bool setEaseToDForAllServos | ( | uint_fast16_t | aMillisForMove | ) |
Sets target position using content of ServoEasingNextPositionArray and use aMillisForMove instead of the speed stored in mSpeed.
Does not start interrupt/movement!
Definition at line 2355 of file ServoEasing.hpp.
bool setEaseToForAllServos | ( | ) |
Sets target position using content of ServoEasingNextPositionArray.
Does not start interrupt/movement!
Definition at line 2322 of file ServoEasing.hpp.
bool setEaseToForAllServos | ( | uint_fast16_t | aDegreesPerSecond | ) |
Sets target position using content of ServoEasingNextPositionArray and use aDegreesPerSecond instead of the one stored in mSpeed.
Does not start interrupt/movement!
Definition at line 2339 of file ServoEasing.hpp.
void setEaseToForAllServosSynchronizeAndStartInterrupt | ( | ) |
Definition at line 2214 of file ServoEasing.hpp.
void setEaseToForAllServosSynchronizeAndStartInterrupt | ( | uint_fast16_t | aDegreesPerSecond | ) |
Definition at line 2219 of file ServoEasing.hpp.
void setEaseToForAllServosSynchronizeAndWaitForAllServosToStop | ( | ) |
Synchronize and blocking wait until all servos are stopped.
Definition at line 2227 of file ServoEasing.hpp.
void setEaseToForAllServosSynchronizeAndWaitForAllServosToStop | ( | uint_fast16_t | aDegreesPerSecond | ) |
Definition at line 2232 of file ServoEasing.hpp.
void setEasingTypeForAllServos | ( | uint_fast8_t | aEasingType | ) |
60 us for single servo + 160 us per servo if using I2C e.g.for PCA9685 expander at 400 kHz or + 100 at 800 kHz 20 us for last interrupt The first servo pulse starts just after this interrupt routine has finished
Definition at line 2198 of file ServoEasing.hpp.
void setEasingTypeForMultipleServos | ( | uint_fast8_t | aNumberOfServos, |
uint_fast8_t | aEasingType | ||
) |
Sets easing type aEasingType for the first aNumberOfServos in ServoEasingArray[].
Definition at line 2205 of file ServoEasing.hpp.
void setSpeedForAllServos | ( | uint_fast16_t | aDegreesPerSecond | ) |
Definition at line 2286 of file ServoEasing.hpp.
void stopAllServos | ( | ) |
Definition at line 2375 of file ServoEasing.hpp.
void synchronizeAllServosAndStartInterrupt | ( | bool | aStartUpdateByInterrupt = START_UPDATE_BY_INTERRUPT | ) |
Take the longer duration in order to move all servos synchronously.
Definition at line 2474 of file ServoEasing.hpp.
void synchronizeAllServosStartAndWaitForAllServosToStop | ( | ) |
Synchronize and blocking wait until all servos are stopped.
Definition at line 2466 of file ServoEasing.hpp.
void synchronizeAndEaseToArrayPositions | ( | ) |
Definition at line 2237 of file ServoEasing.hpp.
void synchronizeAndEaseToArrayPositions | ( | uint_fast16_t | aDegreesPerSecond | ) |
Definition at line 2242 of file ServoEasing.hpp.
bool updateAllServos | ( | ) |
Definition at line 2417 of file ServoEasing.hpp.
void updateAndWaitForAllServosToStop | ( | ) |
Blocking wait until all servos are stopped.
Definition at line 2434 of file ServoEasing.hpp.
void writeAllServos | ( | int | aTargetDegreeOrMicrosecond | ) |
Definition at line 2278 of file ServoEasing.hpp.
const char* const easeTypeStrings [] PROGMEM |
Definition at line 372 of file ServoEasing.h.