Преглед изворни кода

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

Scott Lahteine пре 6 година
родитељ
комит
9b9b62b218

+ 1
- 0
.travis.yml Прегледај датотеку

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

+ 2
- 2
Marlin/src/HAL/HAL_AVR/servo_AVR.cpp Прегледај датотеку

@@ -42,8 +42,8 @@
42 42
  *
43 43
  * write()               - Set the servo angle in degrees. (Invalid angles —over MIN_PULSE_WIDTH— are treated as µs.)
44 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 47
  * read()                - Get the last-written servo pulse width as an angle between 0 and 180.
48 48
  * readMicroseconds()    - Get the last-written servo pulse width in microseconds.
49 49
  * attached()            - Return true if a servo is attached.

+ 3
- 3
Marlin/src/HAL/HAL_LPC1768/LPC1768_Servo.cpp Прегледај датотеку

@@ -42,8 +42,8 @@
42 42
  *
43 43
  * write()               - Set the servo angle in degrees. (Invalid angles —over MIN_PULSE_WIDTH— are treated as µs.)
44 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 47
  * read()                - Get the last-written servo pulse width as an angle between 0 and 180.
48 48
  * readMicroseconds()    - Get the last-written servo pulse width in microseconds.
49 49
  * attached()            - Return true if a servo is attached.
@@ -148,7 +148,7 @@
148 148
     static_assert(COUNT(servo_delay) == NUM_SERVOS, "SERVO_DELAY must be an array NUM_SERVOS long.");
149 149
     if (this->attach(0) >= 0) {    // notice the pin number is zero here
150 150
       this->write(value);
151
-      delay(servo_delay[this->servoIndex]);
151
+      safe_delay(servo_delay[this->servoIndex]);
152 152
       #if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
153 153
         this->detach();
154 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 Прегледај датотеку

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

+ 3
- 1
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) {
39 39
 }
40 40
 
41 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 44
   if (this->attach(0) >= 0) {
43 45
     this->write(value);
44
-    delay(SERVO_DELAY);
46
+    safe_delay(servo_delay[this->servoIndex]);
45 47
     #if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
46 48
       this->detach();
47 49
     #endif

+ 9
- 2
Marlin/src/HAL/HAL_TEENSY35_36/HAL_Servo_Teensy.cpp Прегледај датотеку

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

+ 2
- 3
Marlin/src/HAL/servo.cpp Прегледај датотеку

@@ -42,8 +42,8 @@
42 42
  *
43 43
  * write()               - Set the servo angle in degrees. (Invalid angles —over MIN_PULSE_WIDTH— are treated as µs.)
44 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 47
  * read()                - Get the last-written servo pulse width as an angle between 0 and 180.
48 48
  * readMicroseconds()    - Get the last-written servo pulse width in microseconds.
49 49
  * attached()            - Return true if a servo is attached.
@@ -160,4 +160,3 @@ void Servo::move(const int value) {
160 160
 }
161 161
 
162 162
 #endif // HAS_SERVOS
163
-

Loading…
Откажи
Сачувај