Browse Source

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

pull/1/head
Scott Lahteine 6 years ago
parent
commit
9b9b62b218
  1. 1
      .travis.yml
  2. 4
      Marlin/src/HAL/HAL_AVR/servo_AVR.cpp
  3. 6
      Marlin/src/HAL/HAL_LPC1768/LPC1768_Servo.cpp
  4. 4
      Marlin/src/HAL/HAL_STM32F1/HAL_Servo_Stm32f1.cpp
  5. 4
      Marlin/src/HAL/HAL_STM32F7/HAL_Servo_STM32F7.cpp
  6. 11
      Marlin/src/HAL/HAL_TEENSY35_36/HAL_Servo_Teensy.cpp
  7. 5
      Marlin/src/HAL/servo.cpp

1
.travis.yml

@ -392,6 +392,7 @@ script:
#
- restore_configs
- 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
- build_marlin_pio ${TRAVIS_BUILD_DIR} ${TEST_PLATFORM}
#

4
Marlin/src/HAL/HAL_AVR/servo_AVR.cpp

@ -42,8 +42,8 @@
*
* 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.
* move(pin, angle) - Sequence of attach(pin), write(angle), delay(SERVO_DELAY).
* With DEACTIVATE_SERVOS_AFTER_MOVE it detaches after 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[servoIndex].
* 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.
* attached() - Return true if a servo is attached.

6
Marlin/src/HAL/HAL_LPC1768/LPC1768_Servo.cpp

@ -42,8 +42,8 @@
*
* 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.
* move(pin, angle) - Sequence of attach(pin), write(angle), delay(SERVO_DELAY).
* With DEACTIVATE_SERVOS_AFTER_MOVE it detaches after 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[servoIndex].
* 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.
* 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.");
if (this->attach(0) >= 0) { // notice the pin number is zero here
this->write(value);
delay(servo_delay[this->servoIndex]);
safe_delay(servo_delay[this->servoIndex]);
#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
this->detach();
LPC1768_PWM_detach_pin(servo_info[this->servoIndex].Pin.nbr); // shut down the PWM signal

4
Marlin/src/HAL/HAL_STM32F1/HAL_Servo_Stm32f1.cpp

@ -39,9 +39,11 @@ int8_t libServo::attach(const int pin, const int min, const int max) {
}
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) {
this->write(value);
delay(SERVO_DELAY);
safe_delay(servo_delay[this->servoIndex]);
#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
this->detach();
#endif

4
Marlin/src/HAL/HAL_STM32F7/HAL_Servo_STM32F7.cpp

@ -39,9 +39,11 @@ int8_t libServo::attach(const int pin, const int min, const int max) {
}
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) {
this->write(value);
delay(SERVO_DELAY);
safe_delay(servo_delay[this->servoIndex]);
#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
this->detach();
#endif

11
Marlin/src/HAL/HAL_TEENSY35_36/HAL_Servo_Teensy.cpp

@ -1,8 +1,11 @@
#if defined(__MK64FX512__) || defined(__MK66FX1M0__)
#include "HAL_Servo_Teensy.h"
#include "../../inc/MarlinConfig.h"
#if HAS_SERVOS
#include "HAL_Servo_Teensy.h"
int8_t libServo::attach(const int pin) {
if (this->servoIndex >= MAX_SERVOS) return -1;
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) {
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) {
this->write(value);
delay(SERVO_DELAY);
safe_delay(servo_delay[this->servoIndex]);
#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
this->detach();
#endif
}
}
#endif // HAS_SERVOS
#endif // __MK64FX512__ || __MK66FX1M0__

5
Marlin/src/HAL/servo.cpp

@ -42,8 +42,8 @@
*
* 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.
* move(pin, angle) - Sequence of attach(pin), write(angle), delay(SERVO_DELAY).
* With DEACTIVATE_SERVOS_AFTER_MOVE it detaches after 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[servoIndex].
* 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.
* attached() - Return true if a servo is attached.
@ -160,4 +160,3 @@ void Servo::move(const int value) {
}
#endif // HAS_SERVOS

Loading…
Cancel
Save