Browse Source

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

Scott Lahteine 6 years ago
parent
commit
9b9b62b218

+ 1
- 0
.travis.yml View File

392
   #
392
   #
393
   - restore_configs
393
   - restore_configs
394
   - opt_enable NUM_SERVOS Z_PROBE_SERVO_NR Z_SERVO_ANGLES DEACTIVATE_SERVOS_AFTER_MOVE
394
   - opt_enable NUM_SERVOS Z_PROBE_SERVO_NR Z_SERVO_ANGLES DEACTIVATE_SERVOS_AFTER_MOVE
395
+  - opt_set NUM_SERVOS 1
395
   - opt_enable AUTO_BED_LEVELING_3POINT DEBUG_LEVELING_FEATURE EEPROM_SETTINGS
396
   - opt_enable AUTO_BED_LEVELING_3POINT DEBUG_LEVELING_FEATURE EEPROM_SETTINGS
396
   - build_marlin_pio ${TRAVIS_BUILD_DIR} ${TEST_PLATFORM}
397
   - build_marlin_pio ${TRAVIS_BUILD_DIR} ${TEST_PLATFORM}
397
   #
398
   #

+ 2
- 2
Marlin/src/HAL/HAL_AVR/servo_AVR.cpp View File

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

+ 3
- 3
Marlin/src/HAL/HAL_LPC1768/LPC1768_Servo.cpp View File

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

+ 3
- 1
Marlin/src/HAL/HAL_STM32F1/HAL_Servo_Stm32f1.cpp View File

39
 }
39
 }
40
 
40
 
41
 void libServo::move(const int value) {
41
 void libServo::move(const int value) {
42
+  constexpr uint16_t servo_delay[] = SERVO_DELAY;
43
+  static_assert(COUNT(servo_delay) == NUM_SERVOS, "SERVO_DELAY must be an array NUM_SERVOS long.");
42
   if (this->attach(0) >= 0) {
44
   if (this->attach(0) >= 0) {
43
     this->write(value);
45
     this->write(value);
44
-    delay(SERVO_DELAY);
46
+    safe_delay(servo_delay[this->servoIndex]);
45
     #if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
47
     #if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
46
       this->detach();
48
       this->detach();
47
     #endif
49
     #endif

+ 3
- 1
Marlin/src/HAL/HAL_STM32F7/HAL_Servo_STM32F7.cpp View File

39
 }
39
 }
40
 
40
 
41
 void libServo::move(const int value) {
41
 void libServo::move(const int value) {
42
+  constexpr uint16_t servo_delay[] = SERVO_DELAY;
43
+  static_assert(COUNT(servo_delay) == NUM_SERVOS, "SERVO_DELAY must be an array NUM_SERVOS long.");
42
   if (this->attach(0) >= 0) {
44
   if (this->attach(0) >= 0) {
43
     this->write(value);
45
     this->write(value);
44
-    delay(SERVO_DELAY);
46
+    safe_delay(servo_delay[this->servoIndex]);
45
     #if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
47
     #if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
46
       this->detach();
48
       this->detach();
47
     #endif
49
     #endif

+ 9
- 2
Marlin/src/HAL/HAL_TEENSY35_36/HAL_Servo_Teensy.cpp View File

1
 #if defined(__MK64FX512__) || defined(__MK66FX1M0__)
1
 #if defined(__MK64FX512__) || defined(__MK66FX1M0__)
2
 
2
 
3
-#include "HAL_Servo_Teensy.h"
4
 #include "../../inc/MarlinConfig.h"
3
 #include "../../inc/MarlinConfig.h"
5
 
4
 
5
+#if HAS_SERVOS
6
+
7
+#include "HAL_Servo_Teensy.h"
8
+
6
 int8_t libServo::attach(const int pin) {
9
 int8_t libServo::attach(const int pin) {
7
   if (this->servoIndex >= MAX_SERVOS) return -1;
10
   if (this->servoIndex >= MAX_SERVOS) return -1;
8
   return Servo::attach(pin);
11
   return Servo::attach(pin);
13
 }
16
 }
14
 
17
 
15
 void libServo::move(const int value) {
18
 void libServo::move(const int value) {
19
+  constexpr uint16_t servo_delay[] = SERVO_DELAY;
20
+  static_assert(COUNT(servo_delay) == NUM_SERVOS, "SERVO_DELAY must be an array NUM_SERVOS long.");
16
   if (this->attach(0) >= 0) {
21
   if (this->attach(0) >= 0) {
17
     this->write(value);
22
     this->write(value);
18
-    delay(SERVO_DELAY);
23
+    safe_delay(servo_delay[this->servoIndex]);
19
     #if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
24
     #if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
20
       this->detach();
25
       this->detach();
21
     #endif
26
     #endif
22
   }
27
   }
23
 }
28
 }
24
 
29
 
30
+#endif // HAS_SERVOS
31
+
25
 #endif // __MK64FX512__ || __MK66FX1M0__
32
 #endif // __MK64FX512__ || __MK66FX1M0__

+ 2
- 3
Marlin/src/HAL/servo.cpp View File

42
  *
42
  *
43
  * write()               - Set the servo angle in degrees. (Invalid angles —over MIN_PULSE_WIDTH— are treated as µs.)
43
  * write()               - Set the servo angle in degrees. (Invalid angles —over MIN_PULSE_WIDTH— are treated as µs.)
44
  * writeMicroseconds()   - Set the servo pulse width in microseconds.
44
  * writeMicroseconds()   - Set the servo pulse width in microseconds.
45
- * move(pin, angle)      - Sequence of attach(pin), write(angle), delay(SERVO_DELAY).
46
- *                         With DEACTIVATE_SERVOS_AFTER_MOVE it detaches after SERVO_DELAY.
45
+ * move(pin, angle)      - Sequence of attach(pin), write(angle), safe_delay(servo_delay[servoIndex]).
46
+ *                         With DEACTIVATE_SERVOS_AFTER_MOVE it detaches after servo_delay[servoIndex].
47
  * read()                - Get the last-written servo pulse width as an angle between 0 and 180.
47
  * read()                - Get the last-written servo pulse width as an angle between 0 and 180.
48
  * readMicroseconds()    - Get the last-written servo pulse width in microseconds.
48
  * readMicroseconds()    - Get the last-written servo pulse width in microseconds.
49
  * attached()            - Return true if a servo is attached.
49
  * attached()            - Return true if a servo is attached.
160
 }
160
 }
161
 
161
 
162
 #endif // HAS_SERVOS
162
 #endif // HAS_SERVOS
163
-

Loading…
Cancel
Save