delay(SERVO_DELAY) => safe_delay(servo_delay[servo_index])

This commit is contained in:
Scott Lahteine 2018-05-27 23:45:01 -05:00
parent 1ce97f1f6d
commit 9b9b62b218
7 changed files with 23 additions and 12 deletions

View File

@ -392,6 +392,7 @@ script:
# #
- restore_configs - restore_configs
- opt_enable NUM_SERVOS Z_PROBE_SERVO_NR Z_SERVO_ANGLES DEACTIVATE_SERVOS_AFTER_MOVE - opt_enable NUM_SERVOS Z_PROBE_SERVO_NR Z_SERVO_ANGLES DEACTIVATE_SERVOS_AFTER_MOVE
- opt_set NUM_SERVOS 1
- opt_enable AUTO_BED_LEVELING_3POINT DEBUG_LEVELING_FEATURE EEPROM_SETTINGS - opt_enable AUTO_BED_LEVELING_3POINT DEBUG_LEVELING_FEATURE EEPROM_SETTINGS
- build_marlin_pio ${TRAVIS_BUILD_DIR} ${TEST_PLATFORM} - build_marlin_pio ${TRAVIS_BUILD_DIR} ${TEST_PLATFORM}
# #

View File

@ -42,8 +42,8 @@
* *
* write() - Set the servo angle in degrees. (Invalid angles over MIN_PULSE_WIDTH are treated as µs.) * write() - Set the servo angle in degrees. (Invalid angles over MIN_PULSE_WIDTH are treated as µs.)
* writeMicroseconds() - Set the servo pulse width in microseconds. * writeMicroseconds() - Set the servo pulse width in microseconds.
* move(pin, angle) - Sequence of attach(pin), write(angle), delay(SERVO_DELAY). * move(pin, angle) - Sequence of attach(pin), write(angle), safe_delay(servo_delay[servoIndex]).
* With DEACTIVATE_SERVOS_AFTER_MOVE it detaches after SERVO_DELAY. * With DEACTIVATE_SERVOS_AFTER_MOVE it detaches after servo_delay[servoIndex].
* read() - Get the last-written servo pulse width as an angle between 0 and 180. * read() - Get the last-written servo pulse width as an angle between 0 and 180.
* readMicroseconds() - Get the last-written servo pulse width in microseconds. * readMicroseconds() - Get the last-written servo pulse width in microseconds.
* attached() - Return true if a servo is attached. * attached() - Return true if a servo is attached.

View File

@ -42,8 +42,8 @@
* *
* write() - Set the servo angle in degrees. (Invalid angles over MIN_PULSE_WIDTH are treated as µs.) * write() - Set the servo angle in degrees. (Invalid angles over MIN_PULSE_WIDTH are treated as µs.)
* writeMicroseconds() - Set the servo pulse width in microseconds. * writeMicroseconds() - Set the servo pulse width in microseconds.
* move(pin, angle) - Sequence of attach(pin), write(angle), delay(SERVO_DELAY). * move(pin, angle) - Sequence of attach(pin), write(angle), safe_delay(servo_delay[servoIndex]).
* With DEACTIVATE_SERVOS_AFTER_MOVE it detaches after SERVO_DELAY. * With DEACTIVATE_SERVOS_AFTER_MOVE it detaches after servo_delay[servoIndex].
* read() - Get the last-written servo pulse width as an angle between 0 and 180. * read() - Get the last-written servo pulse width as an angle between 0 and 180.
* readMicroseconds() - Get the last-written servo pulse width in microseconds. * readMicroseconds() - Get the last-written servo pulse width in microseconds.
* attached() - Return true if a servo is attached. * attached() - Return true if a servo is attached.
@ -148,7 +148,7 @@
static_assert(COUNT(servo_delay) == NUM_SERVOS, "SERVO_DELAY must be an array NUM_SERVOS long."); static_assert(COUNT(servo_delay) == NUM_SERVOS, "SERVO_DELAY must be an array NUM_SERVOS long.");
if (this->attach(0) >= 0) { // notice the pin number is zero here if (this->attach(0) >= 0) { // notice the pin number is zero here
this->write(value); this->write(value);
delay(servo_delay[this->servoIndex]); safe_delay(servo_delay[this->servoIndex]);
#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE) #if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
this->detach(); this->detach();
LPC1768_PWM_detach_pin(servo_info[this->servoIndex].Pin.nbr); // shut down the PWM signal LPC1768_PWM_detach_pin(servo_info[this->servoIndex].Pin.nbr); // shut down the PWM signal

View File

@ -39,9 +39,11 @@ int8_t libServo::attach(const int pin, const int min, const int max) {
} }
void libServo::move(const int value) { void libServo::move(const int value) {
constexpr uint16_t servo_delay[] = SERVO_DELAY;
static_assert(COUNT(servo_delay) == NUM_SERVOS, "SERVO_DELAY must be an array NUM_SERVOS long.");
if (this->attach(0) >= 0) { if (this->attach(0) >= 0) {
this->write(value); this->write(value);
delay(SERVO_DELAY); safe_delay(servo_delay[this->servoIndex]);
#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE) #if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
this->detach(); this->detach();
#endif #endif

View File

@ -39,9 +39,11 @@ int8_t libServo::attach(const int pin, const int min, const int max) {
} }
void libServo::move(const int value) { void libServo::move(const int value) {
constexpr uint16_t servo_delay[] = SERVO_DELAY;
static_assert(COUNT(servo_delay) == NUM_SERVOS, "SERVO_DELAY must be an array NUM_SERVOS long.");
if (this->attach(0) >= 0) { if (this->attach(0) >= 0) {
this->write(value); this->write(value);
delay(SERVO_DELAY); safe_delay(servo_delay[this->servoIndex]);
#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE) #if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
this->detach(); this->detach();
#endif #endif

View File

@ -1,8 +1,11 @@
#if defined(__MK64FX512__) || defined(__MK66FX1M0__) #if defined(__MK64FX512__) || defined(__MK66FX1M0__)
#include "HAL_Servo_Teensy.h"
#include "../../inc/MarlinConfig.h" #include "../../inc/MarlinConfig.h"
#if HAS_SERVOS
#include "HAL_Servo_Teensy.h"
int8_t libServo::attach(const int pin) { int8_t libServo::attach(const int pin) {
if (this->servoIndex >= MAX_SERVOS) return -1; if (this->servoIndex >= MAX_SERVOS) return -1;
return Servo::attach(pin); return Servo::attach(pin);
@ -13,13 +16,17 @@ int8_t libServo::attach(const int pin, const int min, const int max) {
} }
void libServo::move(const int value) { void libServo::move(const int value) {
constexpr uint16_t servo_delay[] = SERVO_DELAY;
static_assert(COUNT(servo_delay) == NUM_SERVOS, "SERVO_DELAY must be an array NUM_SERVOS long.");
if (this->attach(0) >= 0) { if (this->attach(0) >= 0) {
this->write(value); this->write(value);
delay(SERVO_DELAY); safe_delay(servo_delay[this->servoIndex]);
#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE) #if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
this->detach(); this->detach();
#endif #endif
} }
} }
#endif // HAS_SERVOS
#endif // __MK64FX512__ || __MK66FX1M0__ #endif // __MK64FX512__ || __MK66FX1M0__

View File

@ -42,8 +42,8 @@
* *
* write() - Set the servo angle in degrees. (Invalid angles over MIN_PULSE_WIDTH are treated as µs.) * write() - Set the servo angle in degrees. (Invalid angles over MIN_PULSE_WIDTH are treated as µs.)
* writeMicroseconds() - Set the servo pulse width in microseconds. * writeMicroseconds() - Set the servo pulse width in microseconds.
* move(pin, angle) - Sequence of attach(pin), write(angle), delay(SERVO_DELAY). * move(pin, angle) - Sequence of attach(pin), write(angle), safe_delay(servo_delay[servoIndex]).
* With DEACTIVATE_SERVOS_AFTER_MOVE it detaches after SERVO_DELAY. * With DEACTIVATE_SERVOS_AFTER_MOVE it detaches after servo_delay[servoIndex].
* read() - Get the last-written servo pulse width as an angle between 0 and 180. * read() - Get the last-written servo pulse width as an angle between 0 and 180.
* readMicroseconds() - Get the last-written servo pulse width in microseconds. * readMicroseconds() - Get the last-written servo pulse width in microseconds.
* attached() - Return true if a servo is attached. * attached() - Return true if a servo is attached.
@ -160,4 +160,3 @@ void Servo::move(const int value) {
} }
#endif // HAS_SERVOS #endif // HAS_SERVOS